elixir
elixir

Reputation: 989

pandas InvalidIndexError when using aggfunc

I get an error (InvalidIndexError: Reindexing only valid with uniquely valued Index objects) when trying to run this code, that creates a pivot_table out of a dataFrame:

pivData = dfData.pivot_table(values=["ppp", "vvv"],
                             index=["ccc", "iii", "ttt", "www"],
                             aggfunc=[np.sum, np.sum])

I don't get what is wrong. And when I remove the last argument, it works fine (just not doing a sum, but an average)

pivData = dfData.pivot_table(values=["ppp", "vvv"],
                             index=["ccc", "iii", "ttt", "www"])

If anyone has a solution or a workaround... Thank you.

Upvotes: 1

Views: 390

Answers (1)

OwQing
OwQing

Reputation: 11

pivData = dfData.pivot_table(values=["ppp", "vvv"],
                             index=["ccc", "iii", "ttt", "www"],
                             aggfunc=np.sum)

Upvotes: 1

Related Questions