Skip to content

Add Series.array #5001

Open
Open

Description

@TomAugspurger

Pandas 0.24.0 added a new recommended API for extracting the array (NumPy array or extension array) from a Series or index: http://pandas.pydata.org/pandas-docs/stable/whatsnew/v0.24.0.html#accessing-the-values-in-a-series-or-index

In [15]: idx = pd.period_range('2000', periods=4)

In [16]: idx.array
Out[16]: 
<PeriodArray>
['2000-01-01', '2000-01-02', '2000-01-03', '2000-01-04']
Length: 4, dtype: period[D]

In [17]: pd.Series(idx).array
Out[17]: 
<PeriodArray>
['2000-01-01', '2000-01-02', '2000-01-03', '2000-01-04']
Length: 4, dtype: period[D]

What does this look like for dask dataframe?

For regular, NumPy dtypes, this is the same as .values.

For extension types, I think any array-like thing that implements dask collections interface is reasonable: https://github.com/ContinuumIO/cyberpandas/pull/39/files has a rough example. We should think about what dask.dataframe can provide to make that easier (perhaps not much).

Activity

  1. mrocklin commented on Jun 25, 2019

    @mrocklin
    Member

    Hrm, is the expectation that it's more Dask Array-like or Dask Dataframe-like?

    If the answer is "array-like" then this might also provide another perspective for the Array _meta work, and force us to establish some expectations around that convention.

    Perhaps this motivates the creation of an Array/DataFrame superclass? It might make sense to investigate if it makes sense to share functionality (though I think that a reasonable answer to this question is "nope, not worth the complexity").

  2. TomAugspurger commented on Jun 25, 2019

    @TomAugspurger
    MemberAuthor

    Hrm, is the expectation that it's more Dask Array-like or Dask Dataframe-like?

    I think the answer is (pandas) ExtensionArray-like, which is closer to Array-Like than DataFrame-like. Essentially a delayed version of https://github.com/pandas-dev/pandas/blob/master/pandas/core/arrays/base.py.

    FWIW, this is still pretty hazy in my head. I opened since I'm writing a blogpost (I wonder why 😄), and needed somewhere to link to :)

  3. mrocklin commented on Jun 25, 2019

    @mrocklin
    Member

    I opened since I'm writing a blogpost (I wonder why 😄)

    Ah ha! Progress. Those were some of the most indirectly productive 38 minutes of my life :)

  4. mrocklin commented on Jun 25, 2019

    @mrocklin
    Member

    I think the answer is (pandas) ExtensionArray-like, which is closer to Array-Like that DataFrame-like.

    One differentiating question here might be "does it have an index?"

  5. quasiben commented on Jul 16, 2019

    @quasiben
    Member

    @kkraus14 you might be interested in following this issue

  6. xhochy commented on Jun 25, 2020

    @xhochy
    Contributor

    I think the answer is (pandas) ExtensionArray-like, which is closer to Array-Like that DataFrame-like.

    One differentiating question here might be "does it have an index?"

    No, it doesn't have an index.

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