Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Timestamp when plotting hourly time series with base != 0 #2571

Closed
bmu opened this issue Dec 20, 2012 · 2 comments
Closed

Timestamp when plotting hourly time series with base != 0 #2571

bmu opened this issue Dec 20, 2012 · 2 comments
Labels
Milestone

Comments

@bmu
Copy link

bmu commented Dec 20, 2012

If I plot an hourly time series with a different base (don't know if this is correct englisch I mean if it is not 12:00, 13:00, ... but something like 12:30, 13:30, ...) the values are plotted as full hours at the xaxis. If I convert to a resolution of '60min' it works.

In [250]: idx = pd.date_range('2012-12-20', periods=24, freq='H') + datetime.timedelta(minutes=30)

In [251]: idx
Out[251]: 
<class 'pandas.tseries.index.DatetimeIndex'>
[2012-12-20 00:30:00, ..., 2012-12-20 23:30:00]
Length: 24, Freq: H, Timezone: None

In [252]: df = pd.DataFrame(np.arange(24), index=idx)

In [253]: df.plot(style='r.')
Out[253]: <matplotlib.axes.AxesSubplot at 0xd34920d0>

In [254]: df2 = df.resample('60min', base=30, closed='right')

In [255]: df2.index
Out[255]: 
<class 'pandas.tseries.index.DatetimeIndex'>
[2012-12-20 00:30:00, ..., 2012-12-20 23:30:00]
Length: 24, Freq: 60T, Timezone: None

In [256]: df2.plot(style='r.')
Out[256]: <matplotlib.axes.AxesSubplot at 0xd43fde90>
@changhiskhan
Copy link
Contributor

This is happening because of the internal conversion to PeriodIndex for better tick labels. We'll put in a fix for 0.10.1. Thanks.

@changhiskhan
Copy link
Contributor

I'm putting in a hack for this now so for 'H' it'll keep it as DatetimeIndex and not perform the PeriodIndex conversion. DatetimeIndex has much more functionality not in the PeriodIndex so more and more restrictions are coming up in plotting in order to retain the tick labeling. Probably the answer is to redo the tick labelling so it doesn't rely on Periods at all.

yarikoptic added a commit to neurodebian/pandas that referenced this issue Jan 23, 2013
Version 0.10.1

* tag 'v0.10.1': (195 commits)
  RLS: set released to true
  RLS: Version 0.10.1
  TST: skip problematic xlrd test
  Merging in MySQL support pandas-dev#2482
  Revert "Merging in MySQL support pandas-dev#2482"
  BUG: don't let np.prod overflow int64
  RLS: note changed return type in DatetimeIndex.unique
  RLS: more what's new for 0.10.1
  RLS: some what's new for 0.10.1
  API: restore inplace=TRue returns self, add FutureWarnings. re pandas-dev#1893
  Merging in MySQL support pandas-dev#2482
  BUG: fix python 3 dtype issue
  DOC: fix what's new 0.10 doc bug re pandas-dev#2651
  BUG: fix C parser thread safety. verify gil release close pandas-dev#2608
  BUG: usecols bug with implicit first index column. close pandas-dev#2654
  BUG: plotting bug when base is nonzero pandas-dev#2571
  BUG: period resampling bug when all values fall into a single bin. close pandas-dev#2070
  BUG: fix memory error in sortlevel when many multiindex levels. close pandas-dev#2684
  STY: CRLF
  BUG: perf_HEAD reports wrong vbench name when an exception is raised
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants