API/BUG: should df.loc[:,'col'] be the same as df['col'] for assignment · Issue #6149 · 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
I believe this changed from 0.12. was the same in 0.12
Boils down to if the row indexer is a null-slice (IOW all rows are selected), should
dtype conversion be done or not (as it current)
In [45]: df = pd.DataFrame({'date':pd.date_range('2000-01-01','2000-01-5'),'val' : np.arange(5)})
In [46]: df
Out[46]:
date val
0 2000-01-01 0
1 2000-01-02 1
2 2000-01-03 2
3 2000-01-04 3
4 2000-01-05 4
[5 rows x 2 columns]
In [47]: df['date'] = 0
In [48]: df
Out[48]:
date val
0 0 0
1 0 1
2 0 2
3 0 3
4 0 4
[5 rows x 2 columns]
In [49]: df = pd.DataFrame({'date':pd.date_range('2000-01-01','2000-01-5'),'val' : np.arange(5)})
In [53]: df.loc[:,'date'] = np.array([0])
In [54]: df
Out[54]:
date val
0 1970-01-01 0
1 1970-01-01 1
2 1970-01-01 2
3 1970-01-01 3
4 1970-01-01 4
[5 rows x 2 columns]