【问题标题】:How do i update powerpoint with my dataframe?如何使用我的数据框更新 powerpoint?
【发布时间】:2022-01-19 06:18:54
【问题描述】:

真的很想在这里得到一些帮助

我有以下数据

Country Industry Data X Data Y Data Z
Singapore Car 2 5 8
Singapore Bike 3 6 9
Malaysia Pastries 5 7 10

我希望用“此幻灯片包含 [行业] 中 [国家] 的数据”来更新我的幻灯片 幻灯片的另一部分包括一个图表,其中包含数据 X、Y 和 Z 的值

而不是循环如下: df[["country_name", "industry_group_name","X" , "Y", "Z"]].values.tolist() 中的国家、行业、X、Y、Z:

有没有一种方法可以捕获列表中的所有单个行数据以进行更新,而不必提及每个列的名称,例如 X、Y、Z......

希望这不会太混乱!

【问题讨论】:

    标签: python pandas dataframe loops powerpoint


    【解决方案1】:

    而不是嵌套循环(循环遍历 Country、Industry 的所有可能组合,包括不存在的对),只需遍历行并打印每行中的值:

    for index, row in df.iterrows():
      print(row['Country'], row['Industry'])
      # if you want to update a value, just set it for the row:
      row['Country'] = 'new country' # this updates the row in the df
    

    【讨论】:

      猜你喜欢
      • 2020-12-14
      • 2018-09-18
      • 2019-02-10
      • 2021-09-04
      • 1970-01-01
      • 2015-12-25
      • 1970-01-01
      • 1970-01-01
      • 2013-05-13
      相关资源
      最近更新 更多