Skip to content

Make is_monotonic work when some partitions are empty#8897

Merged
jrbourbeau merged 3 commits intodask:mainfrom
jsignell:empty-is-monotonic
Apr 11, 2022
Merged

Make is_monotonic work when some partitions are empty#8897
jrbourbeau merged 3 commits intodask:mainfrom
jsignell:empty-is-monotonic

Conversation

@jsignell
Copy link
Copy Markdown
Member

@jsignell jsignell commented Apr 7, 2022

Comment thread dask/dataframe/methods.py
else:
data = x if is_index_like(x) else x.iloc
data = [[x.is_monotonic_increasing, data[0], data[-1]]]
return pd.DataFrame(data=data, columns=["monotonic", "first", "last"])
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will default to object dtype for all columns, does this have any adverse affects in the aggregate function? From reading the code I'd guess this would result in all columns being promoted to object dtype during concatenation, which may be undesired.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh good point! I just did a little test and it looks like the dtype of the columns after concatenation is not object. I'm not 100% sure how this works. But I did try calling .is_monotonic on a series with dtype=object, and it throws a warning before coercing to numeric, so we would know if that were happening.

Copy link
Copy Markdown
Member

@jrbourbeau jrbourbeau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jsignell

Comment thread dask/dataframe/methods.py Outdated
Comment thread dask/dataframe/methods.py Outdated
Comment thread dask/dataframe/tests/test_dataframe.py Outdated
Comment thread dask/dataframe/tests/test_dataframe.py Outdated
Copy link
Copy Markdown
Member

@jrbourbeau jrbourbeau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jsignell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

is_monotonic fails with empty partitions

3 participants