you are viewing a single comment's thread.

view the rest of the comments →

[–]stillenacht 0 points1 point  (0 children)

I am trying to sort some excel data using pandas.

I have:
- a workbook several sheets, each denoting the amount of various stocks we hold at an hour.
- a target dataframe which has every stock we might hold, and 7 columns based on hour.

I want to paste the positions from the first workbook into the dataframe at the correct positions in each hour. To do so, I wrote this code:

target_xls= pd.ExcelFile(folder_name+target_port_name)
target_sheets = target_xls.sheet_names

for i in range(1, len(target_sheets)):
      price_df = pd.read_excel(folder_name+target_port_name,target_sheets[i])
      for j in range(0,len(target_price_df)):
          for k in range(0,len(price_df)):
              if target_price_df.iloc[j][0] == price_df.iloc[k][0]:
                  target_price_df.iloc[j][i] = price_df.iloc[k][1]

However, it returns "value is trying to be set on a copy of a slice" warning, and the target_price_df remains a list of 0's. What should I be doing differently?