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

[Feature request] Read CSV #114

Open
adri0 opened this issue Nov 5, 2022 · 2 comments
Open

[Feature request] Read CSV #114

adri0 opened this issue Nov 5, 2022 · 2 comments
Labels
feature New feature or request
Milestone

Comments

@adri0
Copy link

adri0 commented Nov 5, 2022

I thought it could be a nice thing to have a read_csv class method in a pandas_dataclass. For example, suppose I have a CSV like the one below and I'd like to load it into a Weather dataclass defined at the beginning of the README. I could just call a Weather.read_csv(path) and it would cast values, name columns and indexes automatically.

id year month temp wind pressure
1 2020 1 7.1 2.4 101
2 2020 7 24.3 3.1 103
3 2021 1 5.4 2.3 102
4 2021 7 25.9 2.4 100
df_weather = Weather.read_csv("weather_data.csv")
> df_weather
            temp  wind
year month
2020 1       7.1   2.4
     7      24.3   3.1
2021 1       5.4   2.3
     7      25.9   2.4
@astropenguin astropenguin added the feature New feature or request label Nov 6, 2022
@astropenguin
Copy link
Owner

@adri0 Thank you for the idea! Let me think a while about how I can implement the proposed function.

@astropenguin astropenguin added this to the v1.0 milestone Dec 7, 2022
@Mjboothaus
Copy link

Really like the idea of your package and will experiment - also agree with the proposed feature although probably worth supporting all read/write methods - not sure if there is an easy way to “wrap” the underlying Pandas methods? Also wondering about version 2.x of Pandas support?

Keep up the great work!

@astropenguin astropenguin modified the milestones: v1, v2 Jan 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants