Skip to content

Update dataframe.describe for pandas 1.1 #6434

Closed

Description

@TomAugspurger

In pandas 1.1, the default behavior of handling datetimes has been deprecated. Previously they were treated like categoricals (gave things like unique). In the future they'll be treated like numerics (will give things like quantiles).

In [15]: df = pd.DataFrame({"A": pd.date_range("2000", periods=2)})

In [16]: ddf = dd.from_pandas(df, npartitions=1)

In [17]: df.describe()
/Users/taugspurger/.virtualenvs/dask-dev/bin/ipython:1: FutureWarning: Treating datetime data as categorical rather than numeric in `.describe` is deprecated and will be removed in a future version of pandas. Specify `datetime_is_numeric=True` to silence this warning and adopt the future behavior now.
  #!/Users/taugspurger/Envs/dask-dev/bin/python
Out[17]:
                          A
count                     2
unique                    2
top     2000-01-01 00:00:00
freq                      1
first   2000-01-01 00:00:00
last    2000-01-02 00:00:00

In [18]: ddf.describe()
/Users/taugspurger/sandbox/dask/dask/dataframe/core.py:2230: FutureWarning: Treating datetime data as categorical rather than numeric in `.describe` is deprecated and will be removed in a future version of pandas. Specify `datetime_is_numeric=True` to silence this warning and adopt the future behavior now.
  meta = data._meta_nonempty.describe()
/Users/taugspurger/sandbox/dask/dask/dataframe/core.py:2128: FutureWarning: Treating datetime data as categorical rather than numeric in `.describe` is deprecated and will be removed in a future version of pandas. Specify `datetime_is_numeric=True` to silence this warning and adopt the future behavior now.
  meta = self._meta_nonempty.describe(include=include, exclude=exclude)
Out[18]:
Dask DataFrame Structure:
                    A
npartitions=1
               object
                  ...
Dask Name: describe, 19 tasks

In [19]: _.compute()
Out[19]:
                          A
unique                    2
count                     2
top     2000-01-02 00:00:00
freq                      1
first   2000-01-01 00:00:00
last    2000-01-02 00:00:00

To silence this warning, we'll need to use datetime_is_numeric

In [21]: df.describe(datetime_is_numeric=True)
Out[21]:
                         A
count                    2
mean   2000-01-01 12:00:00
min    2000-01-01 00:00:00
25%    2000-01-01 06:00:00
50%    2000-01-01 12:00:00
75%    2000-01-01 18:00:00
max    2000-01-02 00:00:00

I don't know if we'll want to add that to our API or not.

Activity

  1. quasiben commented on Jul 21, 2020

    @quasiben
    Member

    cc @shwina who might care about these changes as well

  2. ideaguy3d commented on Jun 17, 2021

    @ideaguy3d

    NO. This is not a problem. I like this behavior

    # Good ^_^
    df_in_date_range.describe()

    date file
    1808 1808
    66 1806
    2021-06-08 21:25:35 aiml_file_0101b.mp4
    67 2
    2021-06-07 13:24:53 NaN
    2021-06-11 20:31:42 NaN

    VS

    # BAD >:(
    df_in_date_range.describe(datetime_is_numeric=True)

    date
    1808
    2021-06-09 14:11:13.823561984
    2021-06-07 13:24:53
    2021-06-08 11:19:54
    2021-06-09 13:43:42
    2021-06-10 16:41:39
    2021-06-11 20:31:42

    I lose the file column in Jupyter Notebooks

    ... It took me hours upon hours to figure out how to read the files from disk and parse them correctly in pandas and now I'm dealing with this damn warning:

    FutureWarning: Treating datetime data as categorical rather than numeric in .describeis deprecated and will be removed in a future version of pandas. Specifydatetime_is_numeric=True to silence this warning and adopt the future behavior now.

    We should have the freedom to use datetime data as a categorical. Do NOT force us to convert it to a numeric!

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions