How do i update powerpoint with my dataframe?

Viewed 71

Would really love to get some help here

I have the below data

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

I wish to update my slides with 'This slide contains data for [Country] in [Industry] and another part of the slide includes a chart to include the values for Data X,Y and Z

instead of looping as follows: for country, industry, X, Y, Z in df[["country_name", "industry_group_name","X" , "Y", "Z"]].values.tolist():

is there a way to capture all the individual row data in a list to update without having to mention each column names for eg X, Y, Z......

hope this isnt too confusing!

1 Answers

Instead of a nested loop (which loops through every possible combination of Country, Industry including pairs that don't exist), just loop through the rows and print the values in each row:

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
Related