0

Trying to get crosstab data from Tableau API, however, when I pivot the table I get bad column names and can't figure out how to change them:

Col 1 Col 2 Col 3
Col_1.1 Col_2.1 Col_2.2 col 2.3
0 data data data data data
1 more data more data more data more data more Data

However, I want the data to look like this

Col 1 Col 2 Col_2.1 Col_2.2 col 2.3
data data data data data
more data more data more data more data more Data

I have been able to generate table 1 without problems, I just need to try and make it where col3 is not basically a "merge" column when exported to Excel, but instead displays the data as formatted in Table B

Tdakers
  • 43
  • 6

1 Answers1

1

try:

df.columns = df.columns.map(lambda x: x[0] if (x[0]>x[1]) else x[1])

enter image description here

Pygirl
  • 12,969
  • 5
  • 30
  • 43