<h1 dir="auto">Description</h1>
<p dir="auto">Importing pandas makes plotting with matplotlib and standard datetime objects impossible.</p>
<p dir="auto">A type error is raised in matplotlib because pandas import datetime and "override the global" one.</p>
<p dir="auto">I would not expect pandas to override the default datetime. After importing pandas one cannot use datetimes for plotting for example.</p>
<p dir="auto">PS: just reposting this from matplotlib issue 6796</p>
<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="import datetime
import matplotlib.pyplot as plt
# this works
x = [datetime.date(1677,1,1) + datetime.timedelta(days=i) for i in range(10)]
plt.plot(x,range(10))
import pandas as pd
# do not work anymore
x = [datetime.date(1677,1,1) + datetime.timedelta(days=i) for i in range(10)]
plt.plot(x,range(10))"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">datetime</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-c"># this works</span>
<span class="pl-s1">x</span> <span class="pl-c1">=</span> [<span class="pl-s1">datetime</span>.<span class="pl-en">date</span>(<span class="pl-c1">1677</span>,<span class="pl-c1">1</span>,<span class="pl-c1">1</span>) <span class="pl-c1">+</span> <span class="pl-s1">datetime</span>.<span class="pl-en">timedelta</span>(<span class="pl-s1">days</span><span class="pl-c1">=</span><span class="pl-s1">i</span>) <span class="pl-k">for</span> <span class="pl-s1">i</span> <span class="pl-c1">in</span> <span class="pl-en">range</span>(<span class="pl-c1">10</span>)]
<span class="pl-s1">plt</span>.<span class="pl-en">plot</span>(<span class="pl-s1">x</span>,<span class="pl-en">range</span>(<span class="pl-c1">10</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-c"># do not work anymore</span>
<span class="pl-s1">x</span> <span class="pl-c1">=</span> [<span class="pl-s1">datetime</span>.<span class="pl-en">date</span>(<span class="pl-c1">1677</span>,<span class="pl-c1">1</span>,<span class="pl-c1">1</span>) <span class="pl-c1">+</span> <span class="pl-s1">datetime</span>.<span class="pl-en">timedelta</span>(<span class="pl-s1">days</span><span class="pl-c1">=</span><span class="pl-s1">i</span>) <span class="pl-k">for</span> <span class="pl-s1">i</span> <span class="pl-c1">in</span> <span class="pl-en">range</span>(<span class="pl-c1">10</span>)]
<span class="pl-s1">plt</span>.<span class="pl-en">plot</span>(<span class="pl-s1">x</span>,<span class="pl-en">range</span>(<span class="pl-c1">10</span>))</pre></div>
<h4 dir="auto">Expected Output</h4>
<p dir="auto">datetime would not be "change".</p>
<h4 dir="auto">output of <code class="notranslate">pd.show_versions()</code></h4>
<h2 dir="auto">INSTALLED VERSIONS</h2>
<p dir="auto">commit: None<br>
python: 3.5.1.final.0<br>
python-bits: 64<br>
OS: Darwin<br>
OS-release: 15.5.0<br>
machine: x86_64<br>
processor: i386<br>
byteorder: little<br>
LC_ALL: None<br>
LANG: en_AU.utf-8</p>
<p dir="auto">pandas: 0.18.1<br>
nose: 1.3.7<br>
pip: 8.1.2<br>
setuptools: 21.0.0<br>
Cython: 0.24<br>
numpy: 1.11.0<br>
scipy: 0.17.0<br>
statsmodels: 0.6.1<br>
xarray: 0.7.2<br>
IPython: 4.2.0<br>
sphinx: 1.3.5<br>
patsy: 0.4.1<br>
dateutil: 2.5.3<br>
pytz: 2016.4<br>
blosc: None<br>
bottleneck: None<br>
tables: None<br>
numexpr: None<br>
matplotlib: 1.5.1<br>
openpyxl: 2.3.3<br>
xlrd: 0.9.4<br>
xlwt: None<br>
xlsxwriter: None<br>
lxml: 3.6.0<br>
bs4: 4.4.1<br>
html5lib: None<br>
httplib2: None<br>
apiclient: None<br>
sqlalchemy: 1.0.13<br>
pymysql: None<br>
psycopg2: None<br>
jinja2: 2.8<br>
boto: 2.40.0<br>
pandas_datareader: None</p>
<p dir="auto">register it upon plotting?</p>
<p dir="auto"><a href="http://stackoverflow.com/questions/13988111/importing-pandas-in-python-changes-how-matplotlib-handles-datetime-objects" rel="nofollow">http://stackoverflow.com/questions/13988111/importing-pandas-in-python-changes-how-matplotlib-handles-datetime-objects</a></p>