You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found an issue related to having an Int64Index and using pivot_table.
Here's the code that illustrates the problem:
Start code
import itertools
import datetime
import pandas
d = datetime.date.min
data = list(itertools.product(['foo', 'bar'], ['A', 'B', 'C'],['x1', 'x2'],[d + datetime.timedelta(i) for i in xrange(20)], [1.0]))
I would expect the columns of the pivoted table to be the same regardless of whether the column index of the original table
is ints or strings. I'm finding that this is not the case.
thanks in advance for looking into it.
The text was updated successfully, but these errors were encountered:
I think i sorted out what the problem is here. pivot_table calls unstack on a DataFrame, passing a level argument. When the argument is an int, then unstack assumes (reasonably so) that this is an index, not a level name.
I tried to hack in a fix in dieterv77@8e7b69a
I don't know the internals well enough to know if this fix is appropriate, but if someone thinks it is, i can open a pull request.
I found an issue related to having an Int64Index and using pivot_table.
Here's the code that illustrates the problem:
Start code
import itertools
import datetime
import pandas
d = datetime.date.min
data = list(itertools.product(['foo', 'bar'], ['A', 'B', 'C'],['x1', 'x2'],[d + datetime.timedelta(i) for i in xrange(20)], [1.0]))
print data[0]
df = pandas.DataFrame(data)
df2 = pandas.pivot_table(df, values=4, rows=[0,1,3],cols=[2])
print df2.columns
df = df.rename(columns=lambda x: str(x))
df2 = pandas.pivot_table(df, values='4', rows=['0','1','3'],cols=['2'])
print df2.columns
end code
I would expect the columns of the pivoted table to be the same regardless of whether the column index of the original table
is ints or strings. I'm finding that this is not the case.
thanks in advance for looking into it.
The text was updated successfully, but these errors were encountered: