Skip to content

BUG: setitem with at not inferring dtype correctly #6942

Closed
@jreback

Description

@jreback

xref #14179
xref #12499
xref #18027

http://stackoverflow.com/questions/23250333/in-pandas-dataframe-after-i-set-an-entire-column-i-cant-update-another-column

but .loc works

In [50]: df = pd.DataFrame(index=pd.date_range(start,periods=1), columns=['timenow','Live'])

In [51]: df.at[start,'timenow'] = datetime.today() # initial value

In [52]: df
Out[52]: 
                              timenow Live
2014-04-01 2014-04-23 12:42:38.883082  NaN

[1 rows x 2 columns]

In [53]: df._data
Out[53]: 
BlockManager
Items: Index([u'timenow', u'Live'], dtype='object')
Axis 1: <class 'pandas.tseries.index.DatetimeIndex'>
[2014-04-01]
Length: 1, Freq: D, Timezone: None
ObjectBlock: [timenow, Live], 2 x 1, dtype: object

In [54]: df = pd.DataFrame(index=pd.date_range(start,periods=1), columns=['timenow','Live'])

In [55]: df.loc[start,'timenow'] = datetime.today() # initial value

In [56]: df
Out[56]: 
                              timenow Live
2014-04-01 2014-04-23 12:43:00.554915  NaT

[1 rows x 2 columns]

In [57]: df._data
Out[57]: 
BlockManager
Items: Index([u'timenow', u'Live'], dtype='object')
Axis 1: <class 'pandas.tseries.index.DatetimeIndex'>
[2014-04-01]
Length: 1, Freq: D, Timezone: None
DatetimeBlock: [timenow, Live], 2 x 1, dtype: datetime64[ns]

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIndexingRelated to indexing on series/frames, not to indexes themselves

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions