Skip to content

Should setting an integer into a DataFrame float column cause a type cast? #669

@wesm

Description

@wesm

Not sure about this

In [4]: df = tm.makeTimeDataFrame()

In [5]: df
Out[5]: 
            A       B        C         D      
2000-01-03  0.5694  1.15202  1.269872 -0.08819
2000-01-04 -0.3278 -0.39915 -0.591330  0.81658
2000-01-05  0.8175  0.15806  0.751025  0.61545
2000-01-06  0.2541  2.25491 -0.536671 -0.43782
2000-01-07 -1.4400 -0.12882  0.077768 -0.40887
2000-01-10 -0.3598  1.74354 -1.388002  0.49269
2000-01-11 -0.1260 -0.86097  1.028045 -0.15667
2000-01-12  1.9286  1.42076  1.780311  1.78580
2000-01-13  0.6148  0.28743  0.660499  0.94072
2000-01-14 -0.7055  0.34959  0.538657  0.90766
2000-01-17 -0.4395  0.19145 -0.413462  1.35715
2000-01-18  0.6851 -1.04204  1.721110  0.67047
2000-01-19  1.2581 -1.36096 -0.854228  0.02768
2000-01-20  0.8928 -0.93538 -0.810424  1.64063
2000-01-21  0.5252 -1.09177 -1.060109  0.44210
2000-01-24  0.2277 -0.06904 -0.029423  0.36855
2000-01-25  0.3063 -0.38531  0.597502 -0.24924
2000-01-26 -1.5342 -0.17552  0.033193  0.88376
2000-01-27  1.3528 -1.28998  0.378057 -1.15563
2000-01-28  0.7619 -0.18432  0.476671 -0.08385
2000-01-31  0.3166  0.17006 -0.470700 -0.22658
2000-02-01 -0.4439  0.94540 -0.090201  0.97781
2000-02-02 -0.1776  2.30224  0.225779 -0.52249
2000-02-03 -1.6860  0.10163  0.009537 -0.44277
2000-02-04 -0.7501  1.19757 -2.191548 -0.96064
2000-02-07 -0.5917  0.81859  0.140187  1.42304
2000-02-08  1.4421  0.15792 -0.085060  0.39537
2000-02-09  0.6675 -0.59396 -1.012737 -1.67261
2000-02-10 -0.2199  0.77754 -0.319754  0.24299
2000-02-11 -0.4806 -0.84326  0.664512  0.91148

In [6]: df.dtypes
Out[6]: 
A    float64
B    float64
C    float64
D    float64

In [7]: df['B'] = 0

In [8]: df.dtypes
Out[8]: 
A    float64
B    int64
C    float64
D    float64

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions