Hi have a multiindex dataframe:
tuples = [('YTA_Q3', 1), ('YTA_Q3', 2), ('YTA_Q3', 3), ('YTA_Q3', 4), ('YTA_Q3', 99), ('YTA_Q3', 96)]
# Index
index = pd.MultiIndex.from_tuples(tuples, names=['Questions', 'Values'])
# Columns
columns = pd.MultiIndex.from_tuples([('YTA_Q3', '@')], names=['Questions', 'Values'])
# Data
data = [29.014949,5.0260590000000001,
6.6269119999999999,
1.3565260000000001,
41.632221999999999,
21.279499999999999]
df1 = pd.DataFrame(data=data, index=index, columns=columns)
How do I convert the inner values of the df's index to str?
My attempt:
df1.index.astype(str)
returns a TypeError
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…