import pandas as pd
 
df = pd.DataFrame({"month": [1, 4, 7, 10],
                   "year": [2012, 2014, 2013, 2014],
                   "sale": [55, 40, 84, 31]})
new_df = df.set_index(["year", "month"])
print(new_df.index.names)
print(new_df.index.levels)
 
['year', 'month']
[[2012, 2013, 2014], [1, 4, 7, 10]]

 

相关文章:

  • 2021-09-01
  • 2021-04-12
  • 2022-12-23
  • 2021-10-16
  • 2021-12-19
猜你喜欢
  • 2021-05-14
  • 2022-12-23
  • 2021-06-29
  • 2022-12-23
  • 2022-02-07
  • 2021-04-02
  • 2021-08-08
相关资源
相似解决方案