如何修复“索引0超出大小为0的轴0的界限”?

2024-05-14 04:20:08 发布

您现在位置:Python中文网/ 问答频道 /正文

我在练Python。 运行下面的代码将导致错误。 我不知道为什么。你知道吗

    def plot_conv_south_2(sf, title, south, color):
        df = read_shapefile(sf)
        CTP_KOR_ID = []
        for i in south:
            i = conv_south(i).upper()
            CTP_KOR_ID.append(df[df.CTP_KOR_NM == i.upper()]
                             .index.get_values()[0])
        plot_map_fill_multiples_ids(title, CTP_KOR_ID, sf, 
                                           x_lim = None, 
                                           y_lim = None, 
                                           figsize = (11,9), 
                                           color = color);

AA = ['aaa', 'bbb', 'ccc', 'ddd']

plot_conv_south_2(sf, 'South', AA, 'c')


---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-104-c2d1c4f0d535> in <module>
----> 1 plot_conv_south_2(sf, 'South', AA, 'c')

<ipython-input-102-27a5c1d3a5cb> in plot_conv_south_2(sf, title, south, color)
      8         i = conv_south(i).upper()
      9         CTP_KOR_ID.append(df[df.CTP_KOR_NM == i.upper()]
---> 10                          .index.get_values()[0])
     11     i = np.array(i)
     12     plot_map_fill_multiples_ids(title, CTP_KOR_ID, sf, 

索引器错误:索引0超出大小为0的轴0的界限


Tags: iniddfplottitle错误ctpsf