I cannot get this to work for my data, so first I try to use a concrete example that is very similar. Here is the data frame:
In [56]: idx = pd.DatetimeIndex(start='1990-01-01', freq='d', periods=5) data= pd.DataFrame({('A','a'):[1,2,3,4,5], ('A','b'):[6,7,8,9,1], ('B','a'):[2,3,4,5,6], ('B','b'):[7,8,9,1,2]}, idx) Out[56]: AB abab 1990-01-01 1 6 2 7 1990-01-02 2 7 3 8 1990-01-03 3 8 4 9 1990-01-04 4 9 5 1 1990-01-05 5 1 6 2
So I hope that this is a time series graph with a line for the central trend among the variables (each column) for each observation (every day in the index) with a shaded area indicating the indicated error rating (probably only 95% qi) of the observations corresponding to each day.
I tried this:
sns.tsplot(data, time=idx)
But I get the following error:
UnboundLocalError Traceback (most recent call last) <ipython-input-57-fa07e08ead95> in <module>() 5 ('B','b'):[7,8,9,1,2]}, idx) 6
The syntax for tsplot is:
sns.tsplot(data, time=None, unit=None, condition=None, value=None, err_style='ci_band', ci=68, interpolate=True, color=None, estimator=<function mean at 0x00000000044F2C18>, n_boot=5000, err_palette=None, err_kws=None, legend=True, ax=None, **kwargs)
So, I provide my data to the index as an argument to the time, but I'm not sure what I'm doing wrong. I don’t think I need other keyword arguments, but maybe this is a problem.
If I do this with an array with dimensions (unit, time) instead:
sns.tsplot(data.values.T, time=idx)
I get the expected result (except without a timestamp - these are xlabels):

But what is the right way to do this with a dataframe? I know that this should be in “long form”, but I'm not quite sure what this will mean for this particular frame.