当有两个索引,pandas,python时,绘制日期时间

问题描述 投票:1回答:1

我有如下所示的数据框,

                USD 
state    date
  AL     01/01    10
         01/08    15
           .
           .
           .
         12/30    8

  AK     01/01    10
         01/08    15
           .
           .
           .
         12/30    8

对于每个州。我想在一个图中为每个州绘制日期与美元的关系。我怎样才能做到这一点?

python-2.7 pandas dataframe seaborn
1个回答
2
投票

使用unstackplot

df.unstack(0).plot()

数据输入

df
Out[92]: 
             USD
state date      
AL    01/01   10
      01/08   15
      12/30    8
AK    01/01    3
      01/08    5
      12/30    2

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.