Repository navigation
Closed
Labels
Description
As part of #2190 we'll need something like df.index > pd.Timestamp('2016-01-01'), which hasn't been implemented yet.
In [3]: import dask.dataframe as dd
In [4]: import pandas as pd
In [5]: s = dd.from_pandas(pd.Series(range(10)), 2)
In [6]: s.index > 5---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-6-86de14943cf2> in <module>()
----> 1 s.index > 5
/Users/taugspurger/Envs/dask-dev/lib/python3.6/site-packages/dask/dask/dataframe/core.py in <lambda>(self, other)
968 return lambda self, other: elemwise(op, other, self)
969 else:
--> 970 return lambda self, other: elemwise(op, self, other)
971
972 def rolling(self, window, min_periods=None, freq=None, center=False,
/Users/taugspurger/Envs/dask-dev/lib/python3.6/site-packages/dask/dask/dataframe/core.py in elemwise(op, *args, **kwargs)
2819 meta = _emulate(op, *args, **kwargs)
2820
-> 2821 return new_dd_object(dsk, _name, meta, divisions)
2822
2823
/Users/taugspurger/Envs/dask-dev/lib/python3.6/site-packages/dask/dask/dataframe/core.py in new_dd_object(dsk, _name, meta, divisions)
77 Decides the appropriate output class based on the type of `meta` provided.
78 """
---> 79 return _get_return_type(meta)(dsk, _name, meta, divisions)
80
81
/Users/taugspurger/Envs/dask-dev/lib/python3.6/site-packages/dask/dask/dataframe/core.py in __init__(self, dsk, name, meta, divisions)
101 self.dask = dsk
102 self._name = name
--> 103 meta = make_meta(meta)
104 if isinstance(meta, (pd.DataFrame, pd.Series, pd.Index)):
105 raise TypeError("Expected meta to specify scalar, got "
/Users/taugspurger/Envs/dask-dev/lib/python3.6/site-packages/dask/dask/dataframe/utils.py in make_meta(x, index)
304 return _nonempty_scalar(x)
305
--> 306 raise TypeError("Don't know how to create metadata from {0}".format(x))
307
308
TypeError: Don't know how to create metadata from [False False]This isn't completely trivial, since pandas.Index comparisons return an array instead of an Index, so I've split it off into a separate issue.
Activity
mrocklin commentedon Apr 10, 2017
I think it is reasonable to break with Pandas here. We do this for other operations that return numpy arrays.
jcrist commentedon Apr 10, 2017
Related comment: #1877 (comment) and responses afterwards. I think this is a good solution, and apparently one pandas is moving towards as well.
mrocklin commentedon Oct 23, 2018
Seems to work ok today