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

arrays of datetime.time() objects don't convert into TimeSeries #1531

Closed
blais opened this issue Jun 26, 2012 · 10 comments
Closed

arrays of datetime.time() objects don't convert into TimeSeries #1531

blais opened this issue Jun 26, 2012 · 10 comments
Labels
Milestone

Comments

@blais
Copy link
Contributor

blais commented Jun 26, 2012

Create an array of datetime.time() objects as an index for a DataFrame, and plotting will be wrong, and the index is not of type TimeSeries. Convert that array (using combine()) into an array of datetime.datetime() objects, and it works.

@changhiskhan
Copy link
Contributor

Thanks for the bug report Martin!
Currently pandas cannot create a DatetimeIndex out of array of datetime.time directly.
Suppose we had a convenience function time_range with a date keyword to do the combine operation, would that be sufficient for your use case? Do you need to manipulate the index as datetime.time objects?

@wesm
Copy link
Member

wesm commented Jun 26, 2012

It looks like the root issue is that matplotlib doesn't have a converter for datetime.time. I'm not sure why creating a Series indexed by datetime.time plots at all...bug?

import datetime
times = [(datetime.datetime(2012, 6, 26) + datetime.timedelta(minutes=i)).time() for i in range(100)]
ts = Series(np.random.randn(100), index=times)
ts.plot()

???

@changhiskhan
Copy link
Contributor

it's plotting using linspace and then setting the xticklabels (this is in
the existing non-ts code).

need to convert to datetimes first

On Tue, Jun 26, 2012 at 6:09 PM, Wes McKinney <
reply@reply.github.com

wrote:

It looks like the root issue is that matplotlib doesn't have a converter
for datetime.time. I'm not sure why creating a Series indexed by
datetime.time plots at all...bug?

import datetime
times = [(datetime.datetime(2012, 6, 26) +
datetime.timedelta(minutes=i)).time() for i in range(100)]
ts = Series(np.random.randn(100), index=times)
ts.plot()

???


Reply to this email directly or view it on GitHub:
#1531 (comment)

Chang She
Lambda Foundry http://www.lambdafoundry.com

@wesm
Copy link
Member

wesm commented Jun 26, 2012

Well, strictly speaking if the index is datetime.time, it's not necessarily proper to assign them to a particular calendar date?

@changhiskhan
Copy link
Contributor

Right, I agree it would be a hack.

I mean, we can try writing our own datetime.time converter for MPL. Can
probably mostly just reuse the existing datetime.datetime converter
perhaps. Maybe use a floating number to represent seconds since midnight as
the x-axis ordinals?

On Tue, Jun 26, 2012 at 6:30 PM, Wes McKinney <
reply@reply.github.com

wrote:

Well, strictly speaking if the index is datetime.time, it's not
necessarily proper to assign them to a particular calendar date?


Reply to this email directly or view it on GitHub:
#1531 (comment)

Chang She
Lambda Foundry http://www.lambdafoundry.com

@timmie
Copy link
Contributor

timmie commented Jun 27, 2012

@changhiskhan

I mean, we can try writing our own datetime.time converter for MPL.
would also be easier to fix #1300 then.

@changhiskhan
Copy link
Contributor

How do you see the datetime.time converter help with that issue? I thought #1300 still pertained only to plotting datetime.datetime.

@wesm
Copy link
Member

wesm commented Jun 28, 2012

Merged #1531 and plotting with datetime.time index looking good now

@wesm wesm closed this as completed Jun 28, 2012
@blais
Copy link
Contributor Author

blais commented Jun 28, 2012

Dude you ruleeee

On Thu, Jun 28, 2012, at 13:04, Wes McKinney wrote:

Merged #1531 and plotting with datetime.time index looking good now


Reply to this email directly or view it on GitHub:
#1531 (comment)

@wesm
Copy link
Member

wesm commented Jun 28, 2012

It's all @changhiskhan on this one :) Glad it's sorted out

yarikoptic added a commit to neurodebian/pandas that referenced this issue Jun 30, 2012
* commit 'v0.8.0rc2-26-g76c6351': (42 commits)
  BUG/TST: typo caused read_csv to lose index name pandas-dev#1536
  BUG: incorrect tick label positions pandas-dev#1531 (zooming is still wrong)
  ENH: register converters with matplotlib for better datetime convesion
  ENH: handle datetime.date in Period constructor
  DOC: small doc for pandas-dev#1450
  BUG: repr of pre-1900 datetime64 values in a DataFrame column close pandas-dev#1518
  BUG: workaround vstack/concat bug in numpy 1.6 pandas-dev#1518
  DOC: lreshape docstring, release note
  ENH: experimental lreshape function
  BUG: plotting DataFrame with freq with offset
  BUG: DataFrame plotting with inferred freq
  BUG: timedelta.total_seconds only in 2.7 and 3.2
  DOC: release notes
  ENH: Add raise on conflict keyword to update
  DOC: release notes re: pandas-dev#921
  overload header keyword instead of extra col_aliases keyword
  ENH: column aliases for to_csv/to_excel pandas-dev#921
  ENH: handle weekly resampling via daily
  BUG: plot mixed frequencies pandas-dev#1517
  BUG/TST: plot irregular and reg freq on same subplot
  ...
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

4 participants