Difference between 2 datetimes in a data frame lose ns precision
<p>I have a data frame with 2 columns Event_A / Event_B that looks like this :</p>

<pre class="lang-none prettyprint-override"><code>In [8]: print (df)
                        Event_A                       Event_B
0 2016-10-03 02:00:09.123456789 2016-10-03 02:00:09.123456547
</code></pre>

<p>Both columns contain datetimes and have ns precision.
My issue is that when I do following I lose the ns precision in my new time_diff column :</p>

<pre class="lang-none prettyprint-override"><code>In [9]: df['time_diff'] = df['Event_A'] - df['Event_B']

In [10]: print (df)
                        Event_A                       Event_B       time_diff
0 2016-10-03 02:00:09.123456789 2016-10-03 02:00:09.123456547 00:00:00.000000
</code></pre>

<p>Is there a way to force to output the difference in ns between 2 date times?
Do I have to somehow convert to ns epoch timestamp (not sure how to convert) to perform this operation?</p>

<p>This looks like a display issue, if you access <code>dt.nanoseconds</code> then it will show the difference in nanosecond resolution:</p>

<pre><code>In [85]:
(df['Event_A']- df['Event_B']).dt.nanoseconds

Out[85]:
0    242
dtype: int64
</code></pre>

python pandas dataframe