Closed philipstarkey closed 8 years ago
Original comment by Russell Anderson (Bitbucket: rpanderson, GitHub: rpanderson).
The error derives from the call to concat_with_padding
that attempts to concatenate an initially empty DataFrame with the first non-empty DataFrame of added shots. Specifically, this is due to columns with timezone aware datetimes, e.g. the run time
column.
Minimal breaking example (pandas 0.18.1, numpy 1.11.0):
#!python
df1 = pd.DataFrame(columns=['filepath'])
df2 = pd.DataFrame(data=[['C:\\test.h5', pandas.Timestamp('2016-08-18 16:04:59+1000', tz='Australia/Sydney')]],
columns=['filepath', 'run time'])
pd.concat([df1, df2], ignore_index=True)
This fails as above, at the call to np.empty
. Explicitly,
#!python
In [151]: df2.dtypes[1]
Out[151]: datetime64[ns, Australia/Sydney]
In [152]: np.empty((0, 1), df2.dtypes[1])
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
C:\labscript_suite\lyse\dataframe_utilities.py in <module>()
----> 1 np.empty((0, 1), df2.dtypes[1])
TypeError: data type not understood
The error does not occur for naive datetimes.
If the columns of the empty DataFrame are not specified, there is no such problem, i.e. the following works.
#!python
df1 = pd.DataFrame()
df2 = pd.DataFrame(data=[['C:\\test.h5', pandas.Timestamp('2016-08-18 16:04:59+1000', tz='Australia/Sydney')]],
columns=['filepath', 'run time'])
pd.concat([df1, df2], ignore_index=True)
Original comment by Russell Anderson (Bitbucket: rpanderson, GitHub: rpanderson).
This is resolved by only concatenating non-empty DataFrames, as per pull request #5.
Original comment by Russell Anderson (Bitbucket: rpanderson, GitHub: rpanderson).
Looks related to these pandas bugs:
Original comment by Russell Anderson (Bitbucket: rpanderson, GitHub: rpanderson).
Fixes issue #18, where adding shots to lyse failed with pandas >= 0.18. concat_with_padding now only tries to concatenate non-empty DataFrames.
Modified pandas requirement accordingly, with no upper limit on version. Modified labscript_utils requirement to allow above version specification.
→ \<\<cset f1b822e8432e3a6730a20252ce1bb263a772e551>>
Original report (archived issue) by Russell Anderson (Bitbucket: rpanderson, GitHub: rpanderson).
Since pandas 0.18, adding shots to the lyse GUI fails with: