【问题标题】:How to sum over sheets that have same index in pandas?如何总结熊猫中具有相同索引的工作表?
【发布时间】:2021-02-13 12:07:49
【问题描述】:

我有一个包含多张工作表的 excel 数据。 数据为每小时降雨数据值,空间索引为行中的经度和列中的纬度。 This is the excel file

我需要汇总所有这些表格以获取每日降雨量数据。 我如何在 python 中处理 pandas?

【问题讨论】:

  • 将工作表加载到数据框列表中,将它们连接起来,然后使用 groupby 和 sum。

标签: python excel pandas dataframe


【解决方案1】:

您可以使用dict = pd.read_excel('myfile.xlsx', sheetname=None)。此函数为您提供了一个由 for sheet in dict.items() 迭代的工作表字典。其余与@cs95 提供的解决方案相同。在 for 循环中连接它们,然后按纬度/经度分组。

【讨论】:

    猜你喜欢
    • 2018-12-25
    • 1970-01-01
    • 2017-01-31
    • 2016-10-02
    • 1970-01-01
    • 2021-08-23
    • 2023-03-24
    • 2019-09-26
    • 1970-01-01
    相关资源
    最近更新 更多