ENH: Converting to Nullable integer should take NA into account

This issue has been tracked since 2022-09-19.

Feature Type

  • Adding new functionality to pandas

  • Changing existing functionality in pandas

  • Removing existing functionality in pandas

Problem Description

It is better described with code:

#!/usr/bin/env python3
import pandas as pd

df = pd.DataFrame({'val': ['8', pd.NA]})

df.val = df.val.astype('Int16')

This doesn't work currently because pd.NA is not converted to Int16.

Feature Description

Don't raise that error.
Int16 is nullable and columns of that type are able to have NA values.

Alternative Solutions

none

Additional Context

No response

phofl wrote this answer on 2022-09-19

Hi, thanks for your report. Please provide information on your environment. This works on main

buhtzz wrote this answer on 2022-09-19

It was 1.3.0. The error also occur in 1.3.5.
I confirm this works on 1.4.4.

Sorry for wasting your time. To many environments here.

btw: IMHO this is a bug. So it could be backported to the 1.3. series.

phofl wrote this answer on 2022-09-19

We don’t update the 1.3. series anymore. We are releasing 1.5.0 today

More Details About Repo
Owner Name pandas-dev
Repo Name pandas
Full Name pandas-dev/pandas
Language Python
Created Date 2010-08-24
Updated Date 2022-10-04
Star Count 35430
Watcher Count 1120
Fork Count 15089
Issue Count 3589

YOU MAY BE INTERESTED

Issue Title Created Date Updated Date