-
Notifications
You must be signed in to change notification settings - Fork 35
Problem with saving DataFrames to root files when they contain dtype object #38
Comments
You need to convert the str columns to the numpy string type However, there seems to be a bug in pandas which is preventing that on reassigment, In the mean time, you might need to copy your data:
The |
They actually consider it a bug that the dtype on new assignments is not |
Hi, thanks for taking the time. Unfortunately your way of circumventing this issue does not work for me :( import pandas as pd is just simply object for df['b'] aswell. |
Hi All, has this been resolved at all? I arrived to the same issue of saving string to the root file.
Best, |
@MatousVozak What is the contents of the column that is an object? Strings, arrays or something else? The issue is inside That said, a better question is you need to save to a ROOT file? You might be better served using a file format natively supported by |
Hi @chrisburr, yes it is a string and I needed to save into a root file. I simply wanted to change entries of one branch which was of a type char/string. As this was a hot fix and I couldn't find a quick work around I Eventually turned into a pyroot to do the job. Best, |
Was a workaround ever found for this? |
Kind ping to @chrisburr ... though you may want to look at the |
As explicitly written in the README since a while, root_pandas, and root_numpy on which it depends, has been deprecated and effectively unmaintained for quite a while. We decided to close anthing outstanding as "won't do" and archive the package at this point. |
Uh oh!
There was an error while loading. Please reload this page.
Hi,
i have several textfiles with strings and floats in them. I can load them into a panda dataframe nicely.
I also need to save them in root format and wanted to use this library.
However, when i call the to_root function on my dataframe i got the following:
UserWarning: converter for dtype('O') is not implemented skipping
And indeed, if I load the rootfile later with read_root later the columns with strings in them miss.
I then tried this:
>>> for c in df.columns:
... if df[c].dtype == object:
... df[c] = df[c].astype(str)
Now i did not get any error message using to_root. However, when i load the root file later to a pandas dataframe it still misses the columns where strings are supposed to be.
How to fix this?
Thank you very much
The text was updated successfully, but these errors were encountered: