Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to serialize queryset? #34

Open
ghost opened this issue Jul 16, 2019 · 1 comment
Open

How to serialize queryset? #34

ghost opened this issue Jul 16, 2019 · 1 comment

Comments

@ghost
Copy link

ghost commented Jul 16, 2019

Hey there. I've been using django-neomodel for a long time and am starting to get into Pandas/GraphFrames and Pandas/Scikit. How can I serialize my nodeset into a generic data type like a python dictionary or JSON?

I know I could just grab the data with Cypher or a JSONresponse API call, but that kind of defeats the purpose of the library.

I've attempted all sorts of conversions and iterations: json and dict and dataframe attempts.

How to unlazily load values?

a = MyModel.nodes.all()[0].defined_properties().copy
pd.DataFrame.from_dict([a()])

image

Trying to iterate over a node in every row of a df I just keep winding up back at the django-neomodel class.

list_bucket = []
all_rows = raw_df.iloc[:,0]
for r in all_rows:
    row_as_series = pd.Series(r)
    list_bucket.append(row_as_series)

type(list_bucket[0][0])

[2]  my_app.my_models.MyModel

Perhaps I could somehow super() into the parent class neomodel nodeset.__properties__ ?

MyModel.__class__

[3] neomodel.core.NodeMeta
@marcusvcsacramento
Copy link

a = MyModel.nodes.all()

pd.DataFrame([i.__dict__ for i in a])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant