Skip to content

BUG/ENH: dtype change on enlargement #6485

Open
@jreback

Description

@jreback

http://stackoverflow.com/questions/22044766/adding-row-to-pandas-dataframe-changes-dtype/22045011#22045011

A bit non-trival (maybe coerce back after) if possible?

maybe just change this to an actual append?

In [1]: df = DataFrame({'a' : range(10)}, dtype='i4')

In [2]: df
Out[2]: 
   a
0  0
1  1
2  2
3  3
4  4
5  5
6  6
7  7
8  8
9  9

[10 rows x 1 columns]

In [3]: df.dtypes
Out[3]: 
a    int32
dtype: object

In [4]: df.loc[10] = 99

In [5]: df
Out[5]: 
     a
0    0
1    1
2    2
3    3
4    4
5    5
6    6
7    7
8    8
9    9
10  99

[11 rows x 1 columns]

In [6]: df.dtypes
Out[6]: 
a    float64
dtype: object

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugDtype ConversionsUnexpected or buggy dtype conversionsIndexingRelated to indexing on series/frames, not to indexes themselvessetitem-with-expansion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions