代码之家  ›  专栏  ›  技术社区  ›  Kernel

进入熊猫的定义。系列super().reindex

  •  0
  • Kernel  · 技术社区  · 10 月前

    我有兴趣看看的源代码 pandas.Series.reindex ,所以我使用中的链接跳到源代码 documentation page ,但我找到了返回其他函数的方法 super().reindex ,我还不知道这个功能是在哪里引入的。 我怎样才能理解这个函数的定义 熊猫。系列.索引 ?

    1 回复  |  直到 10 月前
        1
  •  2
  •   wjandrea senderle    10 月前

    super().reindex 从Series的父类调用reindex方法。系列类定义为

    class Series(base.IndexOpsMixin, NDFrame):
    

    所以有两个家长班。在文件顶部的导入中,您可以看到 base 从以下来源进口 pandas.core NDFrame pandas.core.generic

    在base.py中没有reindex函数,但在类中 NDFrame 有。你可以找到 reindex() 功能:

    https://github.com/pandas-dev/pandas/blob/v2.2.3/pandas/core/generic.py#L5347 ( permalink )