I have been using the python package
I would like to know if it is possible to create tabular data from this xarray.Dataset
and export it as a single .csv
or .txt
file, following the data structure below:
long lat ur2m time variable datetime
-47.8 -21.2 0 1 ur2m 2001-01-13 12:00:00
-47.4 -21.2 0 1 ur2m 2001-01-13 12:00:00
-47.0 -21.2 0 1 ur2m 2001-01-13 12:00:00
-46.6 -21.2 0 1 ur2m 2001-01-13 12:00:00
... ... ... ... <NA> ... <NA>
-37.4 -7.2 0 553 ur2m 2001-05-31 12:00:00
-37.0 -7.2 0 553 ur2m 2001-05-31 12:00:00
-36.6 -7.2 0 553 ur2m 2001-05-31 12:00:00
-36.2 -7.2 0 553 ur2m 2001-05-31 12:00:00
The original data are available here
CodePudding user response:
Try this: Convert netcdf to dataframe
df = ds.to_dataframe()
Save dataframe to csv
df = df.to_csv('df.csv')