.to_xarray(): a 9Mb dataframe requires 30Gb ram
See original GitHub issueds1 = df.set_index(['lat','lon']).stack()
ds1.index.names = ['lat', 'lon', 'time']
ds1 = ds1.sort_index()
ds1.columns = ['T']
xr.Dataset(ds1)
I tried to transform a dataset with 2D latitude and longitude into Xarray dataset, however I failed to do so, because ram error occurred during process.
I also tried to set lat and lon as coordination directly, however it is complex to plotting and conducting geographic manipulation in the following work. This dataset is a non-rectangular area, lat and lon can not be replaced by the corner values.
In all, I hope this data can be transformed into xarray and resampled into traditional rectangle data, which can be easily dealt with.
Any codes and suggestions are sincerely welcomed.
Issue Analytics
- State:
- Created 3 years ago
- Comments:6
Top Results From Across the Web
Panda 800MB csv causing memory errors ( 32GB RAM)
I have a 32GB machine, the csv file is 1 million rows by 4 columns (800MB). When I run the code Python only...
Read more >pandas.DataFrame.to_xarray — pandas 1.5.2 documentation
Return an xarray object from the pandas object. Returns. xarray.DataArray or xarray.Dataset. Data in the pandas structure converted to Dataset if the object...
Read more >Optimizing the size of a pandas dataframe for low memory ...
In a previous post I was going through loading csv in dataframes using chunks to filter the only rows we need. However in...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
thanks, that helps. First of all (unless I did something wrong with the
read_csv
call), there’s aUnnamed: 0
column that has to be removed.Other than that, your data seems to be quite sparse so that’s an ideal fit for
sparse
:Thanks for help!I found
sparse
grids are not easy to plot, so I changed my code like Colab code, which is similar with the ‘rasm’ example in xr. Maybe you can show how to create this example datasets (more than thetoy weather
) in tutorial, which would be helpful.