Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

BUG: .map & .apply would convert element type for extension array. #60766

Copy link
Copy link
Open
@colinfang

Description

@colinfang
Issue body actions

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

s = pd.Series([1, 2, None], dtype="Int32")
s.apply(lambda x: print(x))
s.map(lambda x: print(x))
# print 1.0 2.0 nan instead of 1 2 <NA>

Issue Description

s has dtype Int32Dtype which can encode nullable integers

However, when we use .apply(f) or .map(f), the element passed to f becomes float, and pd.NA becomes np.nan

Expected Behavior

f should receive unconverted value, as if we are doing f(s.iloc[0]), f(s.iloc[1]), ...

Installed Versions

tested with Pandas 2.2.3

Metadata

Metadata

Assignees

Labels

ApplyApply, Aggregate, Transform, MapApply, Aggregate, Transform, MapBugNA - MaskedArraysRelated to pd.NA and nullable extension arraysRelated to pd.NA and nullable extension arrays

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.