Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Data Science by (17.6k points)

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

1 Answer

0 votes
by (41.4k points)

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 wish to learn more about how to use python for data science, then go through this data science python course by Intellipaat for more insights.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...