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

Add feature: import from/export to Pandas dataframe #32

Open
PFython opened this issue Feb 2, 2022 · 3 comments
Open

Add feature: import from/export to Pandas dataframe #32

PFython opened this issue Feb 2, 2022 · 3 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@PFython
Copy link
Owner

PFython commented Feb 2, 2022

No description provided.

@PFython PFython added enhancement New feature or request good first issue Good for newcomers labels Feb 2, 2022
@gouravkr
Copy link

gouravkr commented Feb 5, 2022

This can be achieved using built-in Pandas functions.

To convert DataFrame to CleverDict

>>> df.to_dict(orient='index', into=CleverDict())

To convert CleverDict to DataFrame

>>> pd.DataFrame.from_dict(cleverdict_data, orient='index')

Hence this functionality will not add a lot of value to this library.
If you had something else in mind, please add a description with an example of expected input/output.

@PFython
Copy link
Owner Author

PFython commented Feb 6, 2022

@gouravkr Many thanks for being so helpful and specific - much appreciated! Since it's an easy one-liner (each way) I think it'll be helpful to just add these examples to the README. I'm happy to do this or if you'd like to be credited as a contributor, feel free to fork and submit a pull request adding to README. All the best, Pete.

@gouravkr
Copy link

gouravkr commented Feb 9, 2022

While it would be a good idea to add these examples to the readme, I think there's some scope to implement better support for it. For instance, consider the following table:

name price
ice cream $2.50
pastry $3.50

Converting this to CleverDict using >>> c_dict = df.to_dict(orient='index', into=CleverDict()) would not allow me to refer to a column using the header. So I would not be able to use c_dict._0.name

Adding support for this would be a good idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants