Mixed type DataFrame.diff converts to object · Issue #1896 · pandas-dev/pandas (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Description
In [68]: df = DataFrame(np.random.randn(5, 3))
In [69]: df
Out[69]:
0 1 2
0 -1.102224 0.395433 -0.112327
1 -0.025758 2.810779 -0.823856
2 1.100939 0.741825 1.016203
3 0.452166 -1.914473 1.439475
4 0.030840 -0.690666 -0.346612
In [70]: df.diff().dtypes
Out[70]:
0 float64
1 float64
2 float64
In [71]: df['A'] = np.array([1, 2, 3, 4, 5], dtype=object)
In [72]: df.dtypes
Out[72]:
0 float64
1 float64
2 float64
A object
In [73]: df.diff().dtypes
Out[73]:
0 object
1 object
2 object
A object