The following read-write sequence through feather throws with error:
ArrowInvalid: Ran out of field metadata, likely malformed
dg = pd.DataFrame({'A': pd.cut((1, 2, 3), bins=[0, 1, 2])})
file_name = 'myfile.feather'
dg.to_feather(file_name)
dg=pd.read_feather(file_name)
(it's surprising to me that the to_feather
step doesn't complain).
I checked that the following works fine, which suggests it's not just a categorical variable limitation - must be something related to the type returned by pd.cut
.
dg = pd.DataFrame({"A": list("123321")}, dtype="category")
file_name = 'myfile.feather'
dg.to_feather(file_name)
dg=pd.read_feather(file_name)
I really want to not lose the categorical meta-data resulting from my cut as I persist the df through feather. Any recommendations?
I am using pandas 1.5.3, pyarrow 11.0.0 and python 3.8.13 on linux.