Skip to content

CLN: core.generic.NDFrame.astype #28828

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 8, 2019

Conversation

simonjayhawkins
Copy link
Member

mypy error: pandas\core\generic.py:5902: error: "append" of "list" does not return a value

This does not actually manifest as a bug with the current implementation since pd.concat ignores None.

>>> import pandas as pd
>>>
>>> pd.__version__
'0.26.0.dev0+498.gaf498fe8f'
>>>
>>> d = {'col1': [1, 2], 'col2': [3, 4]}
>>>
>>> df = pd.DataFrame(data=d)
>>>
>>> df
   col1  col2
0     1     3
1     2     4
>>>
>>> df.astype({'col1': 'int32'}).dtypes
col1    int32
col2    int64
dtype: object
>>>
>>> results = []
>>> results.append(df['col1'].astype('int32'))
>>> results.append(results.append(df['col2']))
>>> results
[0    1
1    2
Name: col1, dtype: int32, 0    3
1    4
Name: col2, dtype: int64, None]
>>>
>>> pd.concat(results, axis=1)
   col1  col2
0     1     3
1     2     4
>>>

@simonjayhawkins simonjayhawkins added Dtype Conversions Unexpected or buggy dtype conversions Clean labels Oct 7, 2019
@jreback jreback added this to the 1.0 milestone Oct 8, 2019
@jreback jreback merged commit 48d2dca into pandas-dev:master Oct 8, 2019
@jreback
Copy link
Contributor

jreback commented Oct 8, 2019

thanks @simonjayhawkins

@jreback
Copy link
Contributor

jreback commented Oct 8, 2019

way to go typing! lol

@simonjayhawkins simonjayhawkins deleted the astype-error branch October 8, 2019 12:58
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
bongolegend pushed a commit to bongolegend/pandas that referenced this pull request Jan 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Clean Dtype Conversions Unexpected or buggy dtype conversions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants