You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I updated my enviorment to new starfile and pandas version and the starfile.read() behaviour with respect NaNs has changed. Now, the columns with some NANs are parsed as object, but before they were treated as floats (starfile==0.4.2 pandas=2.0 numpy==1.26.3).
Minimal example to reproduce it
importtempfileimportstarfileimportpandasaspdimportnumpyasnpparts=pd.DataFrame({"property1":np.arange(10), "property2": np.random.rand(10)})
parts["property2"].values[-1] *=np.nanprint(parts)
data= {
"particles":parts
}
withtempfile.NamedTemporaryFile(mode="w") astmpfile:
starfile.write(data, tmpfile.name)
tmpfile.seek(0)
data=starfile.read(tmpfile.name)
print(data["property2"].dtype) #This should be a float, not object
Ok, I have a temporary fix in #69, could you try that out? I also copy and pasted your example code as a unit test, is that ok?
The main problem was that the default list of possible NaN values includes an empty string, which we/I before had decided should be parsed as a string/object. Now we manually add back strings that should be considered a NaN.
Description
I updated my enviorment to new starfile and pandas version and the starfile.read() behaviour with respect NaNs has changed. Now, the columns with some NANs are parsed as object, but before they were treated as floats (starfile==0.4.2 pandas=2.0 numpy==1.26.3).
Minimal example to reproduce it
Potential fixes?
Perhaps, it is as easy as change this line
starfile/src/starfile/parser.py
Line 130 in a2e9927
The text was updated successfully, but these errors were encountered: