Skip to content

melting of time-series #6434

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

Closed
michaelaye opened this issue Feb 21, 2014 · 1 comment
Closed

melting of time-series #6434

michaelaye opened this issue Feb 21, 2014 · 1 comment
Labels
Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff Datetime Datetime data dtype Dtype Conversions Unexpected or buggy dtype conversions Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Milestone

Comments

@michaelaye
Copy link
Contributor

I have a standard DataFrame indexed by

<class 'pandas.tseries.index.DatetimeIndex'>
[2009-07-08 07:00:00.134000, ..., 2009-07-08 10:00:01.297000]
Length: 84384, Freq: None, Timezone: None

and 189 columns named like this:

Index([u'a3_01', u'a3_02', u'a3_03', u'a3_04', u'a3_05', u'a3_06', u'a3_07', u'a3_08', u'a3_09', u'a3_10', u'a3_11', u'a3_12', u'a3_13', u'a3_14', u'a3_15', u'a3_16', u'a3_17', u'a3_18', u'a3_19', u'a3_20', u'a3_21', u'a4_01', u'a4_02',...], dtype='object')

Why is it that the following melt operation creates a KeyError:

pd.melt(rad, id_vars=[rad.index])
KeyError: "['2009-07-08T00:00:00.134000000-0700' '2009-07-08T00:00:00.262000000-0700'\n '2009-07-08T00:00:00.390000000-0700' ...,\n '2009-07-08T03:00:01.041000000-0700' '2009-07-08T03:00:01.169000000-0700'\n '2009-07-08T03:00:01.297000000-0700'] not in index"

but if I reset_index() first it works:

pd.melt(rad.reset_index(), id_vars=['index'])

I am aware that the time-index will become non-unique after melting, but shouldn't this actually work? Or maybe it is a feature request that the id_vars accepts a DatetimeIndex as input?

@jreback
Copy link
Contributor

jreback commented Mar 22, 2014

this is the same reason as #6582, so will link to that one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Algos Non-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diff Datetime Datetime data dtype Dtype Conversions Unexpected or buggy dtype conversions Reshaping Concat, Merge/Join, Stack/Unstack, Explode
Projects
None yet
Development

No branches or pull requests

2 participants