Skip to content

Bad x-axis dates when plotting two time-series with different indexes (start, end, and freq) #9524

Closed
@ocefpaf

Description

@ocefpaf

The two DataFrames are from 2014, but from the figure you can see that pandas throws one of them to the year 2050!

bad_pandas

I am using pandas 0.15.2 and the notebook below describes the problem and show a few workarounds that might help debug this:

http://nbviewer.ipython.org/gist/ocefpaf/e7e085c84fd3ea7dbc24

Here is a quick SSCCE to generate the figure above:

import numpy as np                                                                               
import pandas as pd                                                                              

index = pd.date_range(start='2014-06-01 00:00:00', end='2014-09-01 00:00:00', freq='H')          
data = np.random.rand(len(index))                                                                
df0 = pd.DataFrame(data=data, index=index, columns=['DF0'])                                      
index = pd.date_range(start='2014-04-07 10:57:00', end='2014-10-29 09:32:00', freq='D')          
data = np.random.rand(len(index))                                                                
df1 = pd.DataFrame(data=data, index=index, columns=['DF1'])                                      

ax = df0.plot(legend=True, figsize=(12, 4))                                                      
ax = df1.plot(ax=ax)                                                                             

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions