Repository navigation
Pandas 0.24.0 compat - #4374
Pandas 0.24.0 compat#4374
Conversation
|
|
||
| def test_meta_nonempty_empty_categories(): | ||
| for dtype in ['O', 'f8', 'M8']: | ||
| for dtype in ['O', 'f8', 'M8[ns]']: |
There was a problem hiding this comment.
I think this worked by accident previously: pandas-dev/pandas#24753
Not sure if pandas will put in a compat layer for now, or whether we'll just raise.
| res = dd.get_dummies(ds, sparse=True) | ||
| assert_eq(exp, res) | ||
|
|
||
| assert res.compute().a.dtype == 'uint8' |
There was a problem hiding this comment.
This was a deliberate break by pandas.
|
Thank you for doing this @TomAugspurger I'll be especially happy to see dask dataframe support IntegerNA when Pandas does :) It's a nice example of gaining features for free from playing nicely with the ecosystem. |
Stay tuned for a future blogpost :) I'm also working on getting support for 3rd party extension dtypes working. I suspect that we'll get decently far by providing a |
|
Looking into the groupby segfault... Good news, it's easy to reproduce. Bad news, I'm not sure what the solution is... In [4]: import numpy as np
In [5]: np.dtype(dask.delayed(3))(segfault). Pandas hits this in ops like |
|
Running under lldb, I see a whole lot of calls to frame #131026: 0x00000001043df616 _multiarray_umath.cpython-37m-darwin.so`PyArray_DescrConverter + 1030
frame #131027: 0x00000001043df616 _multiarray_umath.cpython-37m-darwin.so`PyArray_DescrConverter + 1030
frame #131028: 0x00000001043e21f1 _multiarray_umath.cpython-37m-darwin.so`arraydescr_new + 145
frame #131029: 0x00000001000f6a30 Python`type_call + 50
frame #131030: 0x00000001000bb5a1 Python`_PyObject_FastCallKeywords + 359
frame #131031: 0x000000010015140a Python`call_function + 746
frame #131032: 0x0000000100149fdd Python`_PyEval_EvalFrameDefault + 7016
frame #131033: 0x0000000100151ca3 Python`_PyEval_EvalCodeWithName + 1835
frame #131034: 0x00000001001483ed Python`PyEval_EvalCode + 42
frame #131035: 0x0000000100177195 Python`run_mod + 54
frame #131036: 0x00000001001761b0 Python`PyRun_FileExFlags + 164
frame #131037: 0x000000010017586a Python`PyRun_SimpleFileExFlags + 266
frame #131038: 0x000000010018e5f7 Python`pymain_main + 5665
frame #131039: 0x000000010018ec1b Python`_Py_UnixMain + 75
frame #131040: 0x00007fff732c5015 libdyld.dylib`start + 1
frame #131041: 0x00007fff732c5015 libdyld.dylib`start + 1everything less that frame 131026 is the same as far back as my terminal history goes. |
|
@jcrist do you have any thoughts on the |
Calling `np.dtype(dask.delayed(...))` used to result in a segfault, as numpy recursively tries to get `dtype` from the object. This is likely a bug in numpy. For now, we can do a dumb for if `x.dtype().dtype()` is called (which shouldn't ever show up in real code). See dask#4374 (comment).
|
Should be fixed by #4387 |
* Calling np.dtype on a delayed object works Calling `np.dtype(dask.delayed(...))` used to result in a segfault, as numpy recursively tries to get `dtype` from the object. This is likely a bug in numpy. For now, we can do a dumb for if `x.dtype().dtype()` is called (which shouldn't ever show up in real code). See #4374 (comment). * Add test that dtype attribute still works if computed
|
This is passing now. How should we proceed? I don't really think we should include the CI changes here, since they'll go stale after the pandas release. Instead, I think that I'll revert the CI changes, and in theory the upstream-dev build should be passing again with these changes. |
|
Actually, spoke too soon, as I don't think this was tested against the RC. Need to remove the pin. |
|
The latest should fix all the remaining failures, expect dask/dataframe/io/tests/test_csv.py:308: AssertionError
________________________ test_rearrange[threads-tasks] _________________________
shuffle = 'tasks', scheduler = 'threads'
@pytest.mark.parametrize('shuffle', ['tasks', 'disk'])
@pytest.mark.parametrize('scheduler', ['threads', 'processes'])
def test_rearrange(shuffle, scheduler):
df = pd.DataFrame({'x': np.random.random(10)})
ddf = dd.from_pandas(df, npartitions=4)
ddf2 = ddf.assign(y=ddf.x % 4)
result = rearrange_by_column(ddf2, 'y', max_branch=32, shuffle=shuffle)
assert result.npartitions == ddf.npartitions
assert set(ddf.dask).issubset(result.dask)
# Every value in exactly one partition
a = result.compute(scheduler=scheduler)
get = dask.base.get_scheduler(scheduler=scheduler)
parts = get(result.dask, result.__dask_keys__())
for i in a.y.drop_duplicates():
> assert sum(i in part.y for part in parts) == 1
E assert 0 == 1
E + where 0 = sum(<generator object test_rearrange.<locals>.<genexpr> at 0x7f24a8a2bbf8>)
dask/dataframe/tests/test_shuffle.py:263: AssertionError
_______________________ test_rearrange[processes-tasks] ________________________
shuffle = 'tasks', scheduler = 'processes'
@pytest.mark.parametrize('shuffle', ['tasks', 'disk'])
@pytest.mark.parametrize('scheduler', ['threads', 'processes'])
def test_rearrange(shuffle, scheduler):
df = pd.DataFrame({'x': np.random.random(10)})
ddf = dd.from_pandas(df, npartitions=4)
ddf2 = ddf.assign(y=ddf.x % 4)
result = rearrange_by_column(ddf2, 'y', max_branch=32, shuffle=shuffle)
assert result.npartitions == ddf.npartitions
assert set(ddf.dask).issubset(result.dask)
# Every value in exactly one partition
a = result.compute(scheduler=scheduler)
get = dask.base.get_scheduler(scheduler=scheduler)
parts = get(result.dask, result.__dask_keys__())
for i in a.y.drop_duplicates():
> assert sum(i in part.y for part in parts) == 1
E assert 0 == 1
E + where 0 = sum(<generator object test_rearrange.<locals>.<genexpr> at 0x7f24ab7132b0>)Haven't had time to debug that yet. Some of the doctests will fail. The bad docstrings are in pandas and have been fixed on master. |
|
8474bde fixes the test in I believe that all the tests will now pass aside from the failing doctests in pandas. Skipping just those proved difficult, so I'm going to verify that just those doctests fail and revert the CI changes. |
|
https://travis-ci.org/dask/dask/jobs/480356385 is the build, here are the failures Detailsso just the expected doctest failures. |
TomAugspurger
left a comment
There was a problem hiding this comment.
All green. Planning to merge later today if there are no objections.
| elif is_integer_na_dtype(dtype): | ||
| data = pd.array([1, None], dtype=dtype) | ||
| elif is_period_dtype(dtype): | ||
| # pandas 0.24.0+ should infer this to be Series[Period[freq]] |
There was a problem hiding this comment.
It's not clear from the comment, but for pandas<0.24.0, it's impossible to have a period-dtype Series. So pandas 0.24.0+ is the only case we need to worry about here.
| freq = dtype.freq | ||
| data = [pd.Period('2000', freq), pd.Period('2001', freq)] | ||
| elif is_sparse(dtype): | ||
| # TODO: pandas <0.24 |
There was a problem hiding this comment.
Grr this is out of date. But I'm planning to rewrite all this soon, so just going to leave it for now.
* Calling np.dtype on a delayed object works Calling `np.dtype(dask.delayed(...))` used to result in a segfault, as numpy recursively tries to get `dtype` from the object. This is likely a bug in numpy. For now, we can do a dumb for if `x.dtype().dtype()` is called (which shouldn't ever show up in real code). See dask#4374 (comment). * Add test that dtype attribute still works if computed
No description provided.