<p dir="auto">xref <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="32078028" data-permission-text="Title is private" data-url="https://github.com/pandas-dev/pandas/issues/6942" data-hovercard-type="issue" data-hovercard-url="/pandas-dev/pandas/issues/6942/hovercard" href="https://github.com/pandas-dev/pandas/issues/6942">#6942</a><br>
xref <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="137459758" data-permission-text="Title is private" data-url="https://github.com/pandas-dev/pandas/issues/12499" data-hovercard-type="issue" data-hovercard-url="/pandas-dev/pandas/issues/12499/hovercard" href="https://github.com/pandas-dev/pandas/issues/12499">#12499</a><br>
xref <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="175624003" data-permission-text="Title is private" data-url="https://github.com/pandas-dev/pandas/issues/14179" data-hovercard-type="issue" data-hovercard-url="/pandas-dev/pandas/issues/14179/hovercard" href="https://github.com/pandas-dev/pandas/issues/14179">#14179</a></p>
<p dir="auto">Simple repro, casting to <code class="notranslate">object</code>, but a datetimelike is cast to its underlying repr</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="In [1]: s = pd.Series([1])

In [2]: s
Out[2]: 
0    1
dtype: int64

In [3]: s[1] = pd.Timestamp('20130101')

In [4]: s
Out[4]: 
0                      1
1    1356998400000000000
dtype: object"><pre class="notranslate"><code class="notranslate">In [1]: s = pd.Series([1])

In [2]: s
Out[2]: 
0    1
dtype: int64

In [3]: s[1] = pd.Timestamp('20130101')

In [4]: s
Out[4]: 
0                      1
1    1356998400000000000
dtype: object
</code></pre></div>
<h4 dir="auto">Code Sample, a copy-pastable example if possible</h4>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; import pandas as pd
&gt;&gt;&gt; s = pd.Series()
&gt;&gt;&gt; s.loc['date'] = pd.Timestamp.now()
&gt;&gt;&gt; s
date   2017-02-27 15:04:32.357
dtype: datetime64[ns]
&gt;&gt;&gt; s.loc['date2'] = pd.Timestamp.now()
&gt;&gt;&gt; s
date    2017-02-27 15:04:32.357
date2   2017-02-27 15:04:41.724
dtype: datetime64[ns]
&gt;&gt;&gt; s.loc['date3'] = 3
&gt;&gt;&gt; s
date     2017-02-27 15:04:32.357000
date2    2017-02-27 15:04:41.724000
date3                             3
dtype: object
&gt;&gt;&gt; s.loc['date4'] = pd.Timestamp.now()
&gt;&gt;&gt; s
date     2017-02-27 15:04:32.357000
date2    2017-02-27 15:04:41.724000
date3                             3
date4           1488207907032000000
dtype: object"><pre class="notranslate"><span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-k">import</span> <span class="pl-s1">pandas</span> <span class="pl-k">as</span> <span class="pl-s1">pd</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">s</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">Series</span>()
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">s</span>.<span class="pl-s1">loc</span>[<span class="pl-s">'date'</span>] <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">Timestamp</span>.<span class="pl-en">now</span>()
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">s</span>
<span class="pl-s1">date</span>   <span class="pl-c1">2017</span><span class="pl-c1">-</span><span class="pl-c1">02</span><span class="pl-c1">-</span><span class="pl-c1">27</span> <span class="pl-c1">15</span>:<span class="pl-c1">04</span>:<span class="pl-c1">32.357</span>
<span class="pl-s1">dtype</span>: <span class="pl-s1">datetime64</span>[<span class="pl-s1">ns</span>]
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">s</span>.<span class="pl-s1">loc</span>[<span class="pl-s">'date2'</span>] <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">Timestamp</span>.<span class="pl-en">now</span>()
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">s</span>
<span class="pl-s1">date</span>    <span class="pl-c1">2017</span><span class="pl-c1">-</span><span class="pl-c1">02</span><span class="pl-c1">-</span><span class="pl-c1">27</span> <span class="pl-c1">15</span>:<span class="pl-c1">04</span>:<span class="pl-c1">32.357</span>
<span class="pl-s1">date2</span>   <span class="pl-c1">2017</span><span class="pl-c1">-</span><span class="pl-c1">02</span><span class="pl-c1">-</span><span class="pl-c1">27</span> <span class="pl-c1">15</span>:<span class="pl-c1">04</span>:<span class="pl-c1">41.724</span>
<span class="pl-s1">dtype</span>: <span class="pl-s1">datetime64</span>[<span class="pl-s1">ns</span>]
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">s</span>.<span class="pl-s1">loc</span>[<span class="pl-s">'date3'</span>] <span class="pl-c1">=</span> <span class="pl-c1">3</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">s</span>
<span class="pl-s1">date</span>     <span class="pl-c1">2017</span><span class="pl-c1">-</span><span class="pl-c1">02</span><span class="pl-c1">-</span><span class="pl-c1">27</span> <span class="pl-c1">15</span>:<span class="pl-c1">04</span>:<span class="pl-c1">32.357000</span>
<span class="pl-s1">date2</span>    <span class="pl-c1">2017</span><span class="pl-c1">-</span><span class="pl-c1">02</span><span class="pl-c1">-</span><span class="pl-c1">27</span> <span class="pl-c1">15</span>:<span class="pl-c1">04</span>:<span class="pl-c1">41.724000</span>
<span class="pl-s1">date3</span>                             <span class="pl-c1">3</span>
<span class="pl-s1">dtype</span>: <span class="pl-s1">object</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">s</span>.<span class="pl-s1">loc</span>[<span class="pl-s">'date4'</span>] <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">Timestamp</span>.<span class="pl-en">now</span>()
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">s</span>
<span class="pl-s1">date</span>     <span class="pl-c1">2017</span><span class="pl-c1">-</span><span class="pl-c1">02</span><span class="pl-c1">-</span><span class="pl-c1">27</span> <span class="pl-c1">15</span>:<span class="pl-c1">04</span>:<span class="pl-c1">32.357000</span>
<span class="pl-s1">date2</span>    <span class="pl-c1">2017</span><span class="pl-c1">-</span><span class="pl-c1">02</span><span class="pl-c1">-</span><span class="pl-c1">27</span> <span class="pl-c1">15</span>:<span class="pl-c1">04</span>:<span class="pl-c1">41.724000</span>
<span class="pl-s1">date3</span>                             <span class="pl-c1">3</span>
<span class="pl-s1">date4</span>           <span class="pl-c1">1488207907032000000</span>
<span class="pl-s1">dtype</span>: <span class="pl-s1">object</span></pre></div>
<h4 dir="auto">Problem description</h4>
<p dir="auto">When a series' dtype is object, .loc assignment of pd.Timestamp values results in being cast to a long, rather than remaining a datetime. Since the dtype is object, I would expect objects to be uncasted.</p>
<h4 dir="auto">Expected Output</h4>
<p dir="auto">The expected behavior is to not be casted, i.e. to remain a datetime.</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; s = s.append(pd.Series(data = [pd.Timestamp.now()], index = ['date_x']))
&gt;&gt;&gt; s
date      2017-02-27 15:04:32.357000
date2     2017-02-27 15:04:41.724000
date3                              3
date4            1488207907032000000
date_x    2017-02-27 15:11:03.995000
dtype: object"><pre class="notranslate"><span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">s</span> <span class="pl-c1">=</span> <span class="pl-s1">s</span>.<span class="pl-en">append</span>(<span class="pl-s1">pd</span>.<span class="pl-v">Series</span>(<span class="pl-s1">data</span> <span class="pl-c1">=</span> [<span class="pl-s1">pd</span>.<span class="pl-v">Timestamp</span>.<span class="pl-en">now</span>()], <span class="pl-s1">index</span> <span class="pl-c1">=</span> [<span class="pl-s">'date_x'</span>]))
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">s</span>
<span class="pl-s1">date</span>      <span class="pl-c1">2017</span><span class="pl-c1">-</span><span class="pl-c1">02</span><span class="pl-c1">-</span><span class="pl-c1">27</span> <span class="pl-c1">15</span>:<span class="pl-c1">04</span>:<span class="pl-c1">32.357000</span>
<span class="pl-s1">date2</span>     <span class="pl-c1">2017</span><span class="pl-c1">-</span><span class="pl-c1">02</span><span class="pl-c1">-</span><span class="pl-c1">27</span> <span class="pl-c1">15</span>:<span class="pl-c1">04</span>:<span class="pl-c1">41.724000</span>
<span class="pl-s1">date3</span>                              <span class="pl-c1">3</span>
<span class="pl-s1">date4</span>            <span class="pl-c1">1488207907032000000</span>
<span class="pl-s1">date_x</span>    <span class="pl-c1">2017</span><span class="pl-c1">-</span><span class="pl-c1">02</span><span class="pl-c1">-</span><span class="pl-c1">27</span> <span class="pl-c1">15</span>:<span class="pl-c1">11</span>:<span class="pl-c1">03.995000</span>
<span class="pl-s1">dtype</span>: <span class="pl-s1">object</span></pre></div>
<h4 dir="auto">Output of <code class="notranslate">pd.show_versions()</code></h4>
<details>
# Paste the output here pd.show_versions() here
27-Feb-17 15:08:27 DEBUG     lzma module is not available
27-Feb-17 15:08:27 DEBUG     Registered VCS backend: git
27-Feb-17 15:08:28 DEBUG     Registered VCS backend: hg
27-Feb-17 15:08:28 DEBUG     Config variable 'Py_DEBUG' is unset, Python ABI tag may be incorrect
27-Feb-17 15:08:28 DEBUG     Config variable 'WITH_PYMALLOC' is unset, Python ABI tag may be incorrect
27-Feb-17 15:08:28 DEBUG     Config variable 'Py_UNICODE_SIZE' is unset, Python ABI tag may be incorrect
27-Feb-17 15:08:28 DEBUG     Config variable 'Py_DEBUG' is unset, Python ABI tag may be incorrect
27-Feb-17 15:08:28 DEBUG     Config variable 'WITH_PYMALLOC' is unset, Python ABI tag may be incorrect
27-Feb-17 15:08:28 DEBUG     Config variable 'Py_UNICODE_SIZE' is unset, Python ABI tag may be incorrect
27-Feb-17 15:08:28 DEBUG     Registered VCS backend: svn
27-Feb-17 15:08:28 DEBUG     Registered VCS backend: bzr
<h2 dir="auto">INSTALLED VERSIONS</h2>
<p dir="auto">commit: None<br>
python: 2.7.12.final.0<br>
python-bits: 64<br>
OS: Windows<br>
OS-release: 10<br>
machine: AMD64<br>
processor: Intel64 Family 6 Model 60 Stepping 3, GenuineIntel<br>
byteorder: little<br>
LC_ALL: None<br>
LANG: None<br>
LOCALE: None.None</p>
<p dir="auto">pandas: 0.19.2<br>
nose: 1.3.7<br>
pip: 9.0.1<br>
setuptools: 33.1.0.post20170122<br>
Cython: 0.25.2<br>
numpy: 1.10.4<br>
scipy: 0.17.1<br>
statsmodels: 0.8.0<br>
xarray: 0.9.1<br>
IPython: 5.2.2<br>
sphinx: 1.5.2<br>
patsy: 0.4.1<br>
dateutil: 2.6.0<br>
pytz: 2016.10<br>
blosc: None<br>
bottleneck: 1.2.0<br>
tables: 3.3.0<br>
numexpr: 2.6.1<br>
matplotlib: 2.0.0<br>
openpyxl: 2.4.1<br>
xlrd: 1.0.0<br>
xlwt: 1.2.0<br>
xlsxwriter: 0.9.6<br>
lxml: 3.7.2<br>
bs4: 4.5.3<br>
html5lib: 0.999<br>
httplib2: None<br>
apiclient: None<br>
sqlalchemy: 1.1.5<br>
pymysql: None<br>
psycopg2: None<br>
jinja2: 2.8<br>
boto: 2.45.0<br>
pandas_datareader: 0.2.1</p>
</details>
<p dir="auto">xref <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="175624003" data-permission-text="Title is private" data-url="https://github.com/pandas-dev/pandas/issues/14179" data-hovercard-type="issue" data-hovercard-url="/pandas-dev/pandas/issues/14179/hovercard" href="https://github.com/pandas-dev/pandas/issues/14179">#14179</a><br>
xref <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="137459758" data-permission-text="Title is private" data-url="https://github.com/pandas-dev/pandas/issues/12499" data-hovercard-type="issue" data-hovercard-url="/pandas-dev/pandas/issues/12499/hovercard" href="https://github.com/pandas-dev/pandas/issues/12499">#12499</a><br>
xref <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="269507526" data-permission-text="Title is private" data-url="https://github.com/pandas-dev/pandas/issues/18027" data-hovercard-type="issue" data-hovercard-url="/pandas-dev/pandas/issues/18027/hovercard" href="https://github.com/pandas-dev/pandas/issues/18027">#18027</a></p>
<p dir="auto"><a href="http://stackoverflow.com/questions/23250333/in-pandas-dataframe-after-i-set-an-entire-column-i-cant-update-another-column" rel="nofollow">http://stackoverflow.com/questions/23250333/in-pandas-dataframe-after-i-set-an-entire-column-i-cant-update-another-column</a></p>
<p dir="auto">but <code class="notranslate">.loc</code> works</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="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: &lt;class 'pandas.tseries.index.DatetimeIndex'&gt;
[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: &lt;class 'pandas.tseries.index.DatetimeIndex'&gt;
[2014-04-01]
Length: 1, Freq: D, Timezone: None
DatetimeBlock: [timenow, Live], 2 x 1, dtype: datetime64[ns]
"><pre class="notranslate"><code class="notranslate">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: &lt;class 'pandas.tseries.index.DatetimeIndex'&gt;
[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: &lt;class 'pandas.tseries.index.DatetimeIndex'&gt;
[2014-04-01]
Length: 1, Freq: D, Timezone: None
DatetimeBlock: [timenow, Live], 2 x 1, dtype: datetime64[ns]

</code></pre></div>