Skip to content

Matplotlib cursor position wrong after using asfreq method to change freq of DateTimeIndex from None to something #5453

Closed
@willfurnass

Description

@willfurnass

After using the asfreq method to change the frequency of a time-series DataFrame from None to something e.g. 15Min the cursor position in matplotlib graphs of that DataFrame is no longer correct (usually shows a datetime just after the unix epoch). The following demonstrates this (NB dt in df1 is not a constant):

df1 = pandas.read_csv('tseries1.csv', names=['tstamp', 'Q'], parse_dates=True, 
    index_col='tstamp').clip_lower(0).fillna(0)
df1['T'] = pandas.read_csv('tseries2.csv', names=['tstamp', 'T'], parse_dates=True, 
    index_col='tstamp', squeeze=True).clip_lower(0).fillna(0)

df2 = df1.asfreq(freq='15Min', method='ffill')
# NB df1.index.freq is None
# NB df2.index.freq is <15 * Minutes>
df1.plot()
df2.plot()
plt.show()

I find the Matplotlib cursor position to be invaluable when looking for features in very long time-series.

Versions:

  • pandas master (commit ID 764b444)
  • numpy 1.8
  • matplotlib 1.3.0

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions