Dataframe has 200+columns with repeated dates and empty columns
weight height total weight height total
2019 2019 2019 2020 2020 2020
Species jan1 jan1 '' jan1 jan1 ''
cat 1.0 2.0 3 4.0 3.0 7
dog 3.0 4.0 9 4.0 5.0 9
I tried:
[x for x in df.columns if df.columns.count(x) >1]
#error: 'MultiIndex' object has no attribute 'count'
df.stack(dropna=False)
#error: cannot reindex from a duplicate axis
Objective: To add any string value like 'a.jan1' repeated column and blank columns renamed as a, b.... so on.
Output required in tabular form for further processing and storage ..
class year Month cat dog
weight 2019 jan1 1 3
height 2019 jan1 2 4
weight 2020 jan1 4 4
height 2020 jan1 3 5