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
The comparison methods (lt, gt, etc...) return incorrect dtypes for empty dataframes. Interestingly, using the operators instead results in correct dtypes. Correct dtypes are also returned for empty series.
In [1]: importpandasaspdIn [2]: df=pd.DataFrame({'x': [1, 2, 3], 'y': [1., 2., 3.]})
In [3]: empty=df.iloc[:0]
In [4]: df.lt(2).dtypesOut[4]:
xboolybooldtype: objectIn [5]: empty.lt(2).dtypes# Should be all bool, but isn'tOut[5]:
xint64yfloat64dtype: objectIn [6]: (df<2).dtypesOut[6]:
xboolybooldtype: objectIn [7]: (empty<2).dtypes# Things do work if you use the operator thoughOut[7]:
xboolybooldtype: objectIn [8]: df.x.lt(2).dtypeOut[8]: dtype('bool')
In [9]: empty.x.lt(2).dtype# Correct dtype for empty seriesOut[9]: dtype('bool')
In [10]: pd.__version__Out[10]: '0.19.2'
The text was updated successfully, but these errors were encountered:
The comparison methods (
lt
,gt
, etc...) return incorrect dtypes for empty dataframes. Interestingly, using the operators instead results in correct dtypes. Correct dtypes are also returned for empty series.The text was updated successfully, but these errors were encountered: