Skip to content

ENH: support apply method for ExtensionArray backed DataFrame #54584

Open
@andrewgsavage

Description

@andrewgsavage

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

Following on from #28955, there's an issue in pint-pandas for apply with DataFrames. Ideally res would be a PintArray rather than an array of objects.

import pandas as pd
import pint
import pint_pandas
ureg = pint.get_application_registry()


def g(x):
    return x[0]
df = pd.DataFrame({'A':pd.Series([1,2,3,4], dtype='pint[day]'),'B':pd.Series([5,6,7,8], dtype='pint[day]')})
res = df.apply(g)
res

A    1 day
B    5 day
dtype: object

Feature Description

This may require the same solution as #27995. Alternatively a dtype arguement for apply.

Alternative Solutions

N/A

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    ApplyApply, Aggregate, Transform, MapEnhancementExtensionArrayExtending pandas with custom dtypes or arrays.Needs DiscussionRequires discussion from core team before further action

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions