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

tsplot cannot use variables in a DataFrame index #77

Closed
laprice opened this issue Jan 10, 2014 · 5 comments
Closed

tsplot cannot use variables in a DataFrame index #77

laprice opened this issue Jan 10, 2014 · 5 comments

Comments

@laprice
Copy link

laprice commented Jan 10, 2014

Here is a notebook that illustrates the issue.

It appears that if one passes a dataframe with a date based index and no condition; one goes down the first branch in tsplot() in timeseries.py

As near as I can tell, constructing an x near line 99 of timeseries.py would make this work. Trying to determine exactly what goes into that line

df.index.values.astype(np.float) 

doesn't work, but something near it should. ( or I just need to convert dates to? )

@mwaskom
Copy link
Owner

mwaskom commented Jan 10, 2014

Try calling df.reset_index(), even just in the line where you pass it to tsplot?

@mwaskom
Copy link
Owner

mwaskom commented Jan 10, 2014

OK the solution will have to be doing something like this

(Or not calling pivot and doing something else when unit is None)

@laprice
Copy link
Author

laprice commented Jan 10, 2014

So, I got it to work following your instructions.

See the notebook for the gory details.

Essentially the issues were.

  1. needed to pass parse_dates=True when importing the csv as apparently the time index needs to be datetime objects, not opaque strings that sort in date order.
  2. all the pivot jazz to get things lined up correctly.

It seems counterintuitive to me that you have to reorder the table if you have a temporal index, but I'm sure you have your reasons.

In this instance I think I'm not understanding what was optional and what was required.

Closing as not a bug. I'll be poking at the documentation and doing more with the library so I'm sure I'll have more questions. Thanks for your help.

@laprice laprice closed this as completed Jan 10, 2014
@mwaskom
Copy link
Owner

mwaskom commented Jan 10, 2014

The main advantage of tsplot is the handling of uncertainty by bootstrapping across sampling units at each timepoint (and then plotting it in various ways the emphasize different aspects of the uncertainty). It probably should behave better in situations where the caller isn't asking for all that jazz, but in your usecase it's not clear that tsplot is ever going to give you more than doing df.plot().

I'll downgrade the tag to "annoyance" and think about this more :)

@shobhitverma
Copy link

Well this happened to me today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants