ENH: Converting to Nullable integer should take NA into account

This issue has been created 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-09-29
Star Count 35374
Watcher Count 1122
Fork Count 15034
Issue Count 3579

YOU MAY BE INTERESTED

Issue Title Created Date Comment Count Updated Date
Documentation missing Requiement Information for Microsoft Build Tools 1 2022-09-15 2022-09-18
Error at startup: "not enough memory" 0 2022-09-15 2022-09-18
bug: no debug binaries 2 2022-03-13 2022-09-21
One way audio issue for video call 0 2021-10-28 2022-05-01
Add versioned docs with doctr_versions_menu 0 2020-08-28 2022-09-20
ValueError: cannot infer dimensions from zero sized index arrays 10 2020-07-30 2022-08-31
Fish shell completions not working 2 2021-06-04 2022-08-03
Pi Zero W works inverse 0 2021-06-01 2022-09-12
Electrodes with number of channels below 16 2 2021-08-24 2022-09-09
saving results to phy not working: "Error using - Invalid type of input arguments (should be uint64)" 1 2022-01-03 2022-09-09
The `go-install.sh` can be used for installing packages in tools.go 1 2021-11-16 2022-09-22
linting workflow form markdown 0 2022-01-14 2022-09-22
Hidden field is not working by using slug 0 2022-04-01 2022-09-06
Значение marketOrderStartTime. 3 2022-02-10 2022-08-27
how to add vertical lines per row 3 2018-01-22 2022-09-19
[OTHER] Fix vulnerable packages and remove tslint 1 2022-06-13 2022-09-03
barh() all zero vals results in ZeroDivisionError 0 2021-07-08 2022-09-15
The log file is not generated 2 2021-10-26 2022-09-29
[Database] Sometimes some columns has null value. 2 2021-10-22 2022-07-20
[Request] EverythingToolbar 1 2022-07-31 2022-08-12
Backbone API docs seem incomplete and/or out of date 0 2022-04-19 2022-09-21
dock 双屏时,dock会互相切换,如何固定在一屏 9 2020-09-03 2022-07-19
Upgrade Sonarqube from 8.5.1 to 9.0 0 2021-11-12 2022-08-05
Search OpenCTI based on an STIX indicator patter 8 2021-09-29 2022-09-10
Error installing numba 0.51.2 3 2021-12-28 2022-09-27
ksql查询报如下日志报错ERROR - Parser kafka sql has error 1 2021-10-23 2022-09-24
Auto-closing paired symbols 13 2019-12-18 2022-07-31
Dropwizard-migrations: Is there a way to pass property to changeset ? 4 2021-11-05 2022-09-09
Fuchas "Concert" desktop UI 0 2019-12-14 2022-08-18
The code for creating a service principal with PowerShell is wrong 1 2021-12-08 2022-09-13
Cosmos DB emulator should provide a read-only key 4 2021-10-18 2022-08-20
能写一个lottie动画的demo吗?我这边遇到一些问题 1 2022-05-18 2022-09-19
7544 - Construct Tuple 0 2022-04-30 2022-08-01
Panic on shutdown prevents flush 2 2021-05-25 2022-09-08
should remove ng-monitoring /info key in PD(etcd) after ng-monitoring has been deleted. 3 2022-02-10 2022-09-15
[Feature Request] Add extra annotation field for configmap in helm chart 5 2021-12-02 2022-09-26
DOC: don't suggest melt instead of lookup 2 2022-01-24 2022-09-01
CreateOrUpdate should not be called for existing zone 7 2021-11-17 2022-08-21
File Limit Request: sagemaker-pyspark - 200 MB 6 2022-08-24 2022-09-09
Implement UpdatePolicy() API (aka UpdatableAdapter interface) 1 2021-01-22 2022-09-17
Node pool name is typed as optional, but is required 2 2021-12-22 2022-09-06
Confusing cache behavior 2 2017-01-27 2022-09-15
[BUG] OpenSearch 1.0.1 root endpoint reports version as 1.0.0 2 2021-09-02 2022-07-14
Bump spring-boot-dependencies from 2.4.5 to 2.5.1 1 2021-06-11 2022-09-29
Bump codecov from 2.1.11 to 2.1.12 0 2021-08-03 2022-09-11
arm build fails? 1 2021-12-03 2021-12-05
IntelliJ plugin instantiates specs excluded by tags 3 2020-10-30 2022-09-04
Possible bug with scale gradient between two values and zoom level 2 2022-09-12 2022-09-28
zooming/scaling question 3 2022-09-04 2022-09-10
ContinuousRectangleBorder doesn't match iOS implementation 9 2021-10-08 2022-09-25