<p dir="auto">Hello,</p>
<p dir="auto">I did</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import numpy as np
import pandas as pd
from matplotlib.pyplot as plt

idx = pd.date_range('20140101', '20140201')
df = pd.DataFrame(index=idx)
df['col0'] = np.random.randn(len(idx))
s_idx = pd.Series(idx, index=idx) # need to do this because we can't shift index
diff_idx = (s_idx-s_idx.shift(1)).fillna(pd.Timedelta(0))
df['diff_dt'] = diff_idx
df['diff_dt'].plot()"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</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-k">from</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>

<span class="pl-s1">idx</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-s1">date_range</span>(<span class="pl-s">'20140101'</span>, <span class="pl-s">'20140201'</span>)
<span class="pl-s1">df</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>(<span class="pl-s1">index</span><span class="pl-c1">=</span><span class="pl-s1">idx</span>)
<span class="pl-s1">df</span>[<span class="pl-s">'col0'</span>] <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">randn</span>(<span class="pl-en">len</span>(<span class="pl-s1">idx</span>))
<span class="pl-s1">s_idx</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">Series</span>(<span class="pl-s1">idx</span>, <span class="pl-s1">index</span><span class="pl-c1">=</span><span class="pl-s1">idx</span>) <span class="pl-c"># need to do this because we can't shift index</span>
<span class="pl-s1">diff_idx</span> <span class="pl-c1">=</span> (<span class="pl-s1">s_idx</span><span class="pl-c1">-</span><span class="pl-s1">s_idx</span>.<span class="pl-en">shift</span>(<span class="pl-c1">1</span>)).<span class="pl-en">fillna</span>(<span class="pl-s1">pd</span>.<span class="pl-v">Timedelta</span>(<span class="pl-c1">0</span>))
<span class="pl-s1">df</span>[<span class="pl-s">'diff_dt'</span>] <span class="pl-c1">=</span> <span class="pl-s1">diff_idx</span>
<span class="pl-s1">df</span>[<span class="pl-s">'diff_dt'</span>].<span class="pl-en">plot</span>()</pre></div>
<p dir="auto">but it raises <code class="notranslate">Empty 'Series': no numeric data to plot</code></p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="In [78]: df.dtypes
Out[78]:
col0               float64
diff_dt    timedelta64[ns]
dtype: object


In [79]: type(df['diff_dt'][1])
Out[79]: pandas.tslib.Timedelta"><pre class="notranslate"><span class="pl-v">In</span> [<span class="pl-c1">78</span>]: <span class="pl-s1">df</span>.<span class="pl-s1">dtypes</span>
<span class="pl-v">Out</span>[<span class="pl-c1">78</span>]:
<span class="pl-s1">col0</span>               <span class="pl-s1">float64</span>
<span class="pl-s1">diff_dt</span>    <span class="pl-s1">timedelta64</span>[<span class="pl-s1">ns</span>]
<span class="pl-s1">dtype</span>: <span class="pl-s1">object</span>


<span class="pl-v">In</span> [<span class="pl-c1">79</span>]: <span class="pl-en">type</span>(<span class="pl-s1">df</span>[<span class="pl-s">'diff_dt'</span>][<span class="pl-c1">1</span>])
<span class="pl-v">Out</span>[<span class="pl-c1">79</span>]: <span class="pl-s1">pandas</span>.<span class="pl-s1">tslib</span>.<span class="pl-v">Timedelta</span></pre></div>
<p dir="auto">I don't understand if data inside <code class="notranslate">diff_dt</code> columns are <code class="notranslate">numpy.timedelta64</code> or <code class="notranslate">pd.Timedelta</code></p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="df['diff_dt'].map(lambda x: x.value)"><pre class="notranslate"><span class="pl-s1">df</span>[<span class="pl-s">'diff_dt'</span>].<span class="pl-en">map</span>(<span class="pl-k">lambda</span> <span class="pl-s1">x</span>: <span class="pl-s1">x</span>.<span class="pl-s1">value</span>)</pre></div>
<p dir="auto">raises <code class="notranslate">AttributeError: 'numpy.timedelta64' object has no attribute 'value'</code></p>
<p dir="auto">but it seems that I can get <code class="notranslate">value</code>for a given data (let's say row 10)</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="In [97]: df['diff_dt'][10].value
Out[97]: 86400000000000"><pre class="notranslate"><span class="pl-v">In</span> [<span class="pl-c1">97</span>]: <span class="pl-s1">df</span>[<span class="pl-s">'diff_dt'</span>][<span class="pl-c1">10</span>].<span class="pl-s1">value</span>
<span class="pl-v">Out</span>[<span class="pl-c1">97</span>]: <span class="pl-c1">86400000000000</span></pre></div>
<p dir="auto">I don't understand why...</p>
<p dir="auto">But I also don't understand how I could plot diff_dt column without doing an uggly:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="df['diff_dt'].map(lambda x: x/np.timedelta64(1, 'ns')).plot()"><pre class="notranslate"><code class="notranslate">df['diff_dt'].map(lambda x: x/np.timedelta64(1, 'ns')).plot()
</code></pre></div>
<p dir="auto">But I don't know how I could automatically get this <code class="notranslate">np.timedelta64(1, 'ns')</code></p>
<p dir="auto">Maybe Pandas could plot Timedelta (or <code class="notranslate">np.timedelta64</code>) out of the box ?<br>
because that's interesting to know for example if sampling period is constant.</p>
<p dir="auto">Kind regards</p>
<h4 dir="auto">Code Sample</h4>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import pandas as pd
from pandas.compat import StringIO
import matplotlib.pyplot as plt


dat = &quot;&quot;&quot;c1,c2,c3
1000,2000,1500
9000,8000,1600&quot;&quot;&quot;

df = pd.read_csv(StringIO(dat))

print(df)

df.plot.bar()
plt.show()

df = df.apply(lambda x: pd.to_timedelta(x, unit='ms'))

print(df)

df.plot.bar()
plt.show()
"><pre class="notranslate"><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-k">from</span> <span class="pl-s1">pandas</span>.<span class="pl-s1">compat</span> <span class="pl-k">import</span> <span class="pl-v">StringIO</span>
<span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>


<span class="pl-s1">dat</span> <span class="pl-c1">=</span> <span class="pl-s">"""c1,c2,c3</span>
<span class="pl-s">1000,2000,1500</span>
<span class="pl-s">9000,8000,1600"""</span>

<span class="pl-s1">df</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-en">read_csv</span>(<span class="pl-v">StringIO</span>(<span class="pl-s1">dat</span>))

<span class="pl-en">print</span>(<span class="pl-s1">df</span>)

<span class="pl-s1">df</span>.<span class="pl-s1">plot</span>.<span class="pl-en">bar</span>()
<span class="pl-s1">plt</span>.<span class="pl-en">show</span>()

<span class="pl-s1">df</span> <span class="pl-c1">=</span> <span class="pl-s1">df</span>.<span class="pl-en">apply</span>(<span class="pl-k">lambda</span> <span class="pl-s1">x</span>: <span class="pl-s1">pd</span>.<span class="pl-en">to_timedelta</span>(<span class="pl-s1">x</span>, <span class="pl-s1">unit</span><span class="pl-c1">=</span><span class="pl-s">'ms'</span>))

<span class="pl-en">print</span>(<span class="pl-s1">df</span>)

<span class="pl-s1">df</span>.<span class="pl-s1">plot</span>.<span class="pl-en">bar</span>()
<span class="pl-s1">plt</span>.<span class="pl-en">show</span>()</pre></div>
<h4 dir="auto">Problem description</h4>
<p dir="auto"><code class="notranslate">plot.bar()</code> works with numerical values (<code class="notranslate">int</code>, <code class="notranslate">float</code>).</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="     c1    c2    c3
0  1000  2000  1500
1  9000  8000  1600"><pre class="notranslate"><code class="notranslate">     c1    c2    c3
0  1000  2000  1500
1  9000  8000  1600
</code></pre></div>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/109167/28241986-6b0fb8e8-69a0-11e7-88d0-2c32de28af90.png"><img src="https://user-images.githubusercontent.com/109167/28241986-6b0fb8e8-69a0-11e7-88d0-2c32de28af90.png" alt="capture d ecran 2017-07-15 a 20 20 30" style="max-width: 100%;"></a></p>
<p dir="auto">not with <code class="notranslate">Timedelta</code></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="        c1       c2              c3
0 00:00:01 00:00:02 00:00:01.500000
1 00:00:09 00:00:08 00:00:01.600000"><pre class="notranslate"><code class="notranslate">        c1       c2              c3
0 00:00:01 00:00:02 00:00:01.500000
1 00:00:09 00:00:08 00:00:01.600000
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    df.plot.bar()
  File &quot;/Users/scls/anaconda/lib/python3.6/site-packages/pandas/plotting/_core.py&quot;, line 2659, in bar
    return self(kind='bar', x=x, y=y, **kwds)
  File &quot;/Users/scls/anaconda/lib/python3.6/site-packages/pandas/plotting/_core.py&quot;, line 2620, in __call__
    sort_columns=sort_columns, **kwds)
  File &quot;/Users/scls/anaconda/lib/python3.6/site-packages/pandas/plotting/_core.py&quot;, line 1857, in plot_frame
    **kwds)
  File &quot;/Users/scls/anaconda/lib/python3.6/site-packages/pandas/plotting/_core.py&quot;, line 1682, in _plot
    plot_obj.generate()
  File &quot;/Users/scls/anaconda/lib/python3.6/site-packages/pandas/plotting/_core.py&quot;, line 236, in generate
    self._compute_plot_data()
  File &quot;/Users/scls/anaconda/lib/python3.6/site-packages/pandas/plotting/_core.py&quot;, line 345, in _compute_plot_data
    'plot'.format(numeric_data.__class__.__name__))
TypeError: Empty 'DataFrame': no numeric data to plot"><pre class="notranslate"><code class="notranslate">    df.plot.bar()
  File "/Users/scls/anaconda/lib/python3.6/site-packages/pandas/plotting/_core.py", line 2659, in bar
    return self(kind='bar', x=x, y=y, **kwds)
  File "/Users/scls/anaconda/lib/python3.6/site-packages/pandas/plotting/_core.py", line 2620, in __call__
    sort_columns=sort_columns, **kwds)
  File "/Users/scls/anaconda/lib/python3.6/site-packages/pandas/plotting/_core.py", line 1857, in plot_frame
    **kwds)
  File "/Users/scls/anaconda/lib/python3.6/site-packages/pandas/plotting/_core.py", line 1682, in _plot
    plot_obj.generate()
  File "/Users/scls/anaconda/lib/python3.6/site-packages/pandas/plotting/_core.py", line 236, in generate
    self._compute_plot_data()
  File "/Users/scls/anaconda/lib/python3.6/site-packages/pandas/plotting/_core.py", line 345, in _compute_plot_data
    'plot'.format(numeric_data.__class__.__name__))
TypeError: Empty 'DataFrame': no numeric data to plot
</code></pre></div>
<h4 dir="auto">Expected Output</h4>
<p dir="auto">Timedelta on y axis should be displayed</p>
<h4 dir="auto">Output of <code class="notranslate">pd.show_versions()</code></h4>
<details>
/Users/scls/anaconda/lib/python3.6/site-packages/xarray/core/formatting.py:16: FutureWarning: The pandas.tslib module is deprecated and will be removed in a future version.
  from pandas.tslib import OutOfBoundsDatetime
<h2 dir="auto">INSTALLED VERSIONS</h2>
<p dir="auto">commit: None<br>
python: 3.6.1.final.0<br>
python-bits: 64<br>
OS: Darwin<br>
OS-release: 16.6.0<br>
machine: x86_64<br>
processor: i386<br>
byteorder: little<br>
LC_ALL: None<br>
LANG: fr_FR.UTF-8<br>
LOCALE: fr_FR.UTF-8</p>
<p dir="auto">pandas: 0.20.1<br>
pytest: 3.1.2<br>
pip: 9.0.1<br>
setuptools: 27.2.0<br>
Cython: 0.25.2<br>
numpy: 1.12.1<br>
scipy: 0.19.0<br>
xarray: 0.9.5<br>
IPython: 5.3.0<br>
sphinx: 1.5.6<br>
patsy: 0.4.1<br>
dateutil: 2.6.0<br>
pytz: 2017.2<br>
blosc: None<br>
bottleneck: 1.2.1<br>
tables: 3.3.0<br>
numexpr: 2.6.2<br>
feather: None<br>
matplotlib: 2.0.2<br>
openpyxl: 2.4.7<br>
xlrd: 1.0.0<br>
xlwt: 1.2.0<br>
xlsxwriter: 0.9.6<br>
lxml: 3.7.3<br>
bs4: 4.6.0<br>
html5lib: 0.999<br>
sqlalchemy: 1.1.9<br>
pymysql: None<br>
psycopg2: None<br>
jinja2: 2.9.6<br>
s3fs: None<br>
pandas_gbq: None<br>
pandas_datareader: 0.4.0</p>
</details>