I have multiple files with bits to analyse. First i read them into a list of BitString.Bits. Then i split each file bits into the specific parts i want to see and save them into a list of Pandas.DataFrames. One DF for each file.
Now for further plotting and analysis purposes i want to store all data in one Xarray.Dataset, where i have the DataFrames stacked along the third axis with the name "dataset".
I have tried to concat each DataFrame together to an DataSet:
xr.concat(data_df[:], dim="dataset")
but i got an error saying that i cant concatenate other than DataArray or DataSets. Can i convert the DataFrames on the fly to DataArrays?
Thanks for your help!
Greetings from Germany
Jan
you can use DataFrame.to_xarray() method:
xr.concat([df.to_xarray() for df in data_df], dim="dataset")
where data_df
is a list of DataFrames
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With