Skip to content

BUG: update should try harder to preserve dtypes #4094

Closed
@jreback

Description

@jreback

more examples in #13957

http://stackoverflow.com/questions/17398216/unwanted-type-conversion-in-pandas-dataframe-update

df = pd.DataFrame({'int': [1, 2], 'float': [np.nan, np.nan]})

print('Integer column:')
print(df['int'])

for _, df_sub in df.groupby('int'):
    df_sub['float'] = float(df_sub['int'])
    df.update(df_sub)

print('NO integer column:')
print(df['int']) 

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions