Ref
There is no
Will need someone that understands pandas to help how to iterate and change data in place.
I found dataframe.at(), it works for
desired_number = row[1]['Number_Header']
There is no
Number_Header
column in the csv filehttps://pandas.pydata.org/pandas-docs/st...e.iterrows Wrote:Depending on the data types, the iterator returns a copy and not a view, and writing to it will have no effect.
Will need someone that understands pandas to help how to iterate and change data in place.
I found dataframe.at(), it works for
'Result_Header'
but complains about 'Result_Notes'
as its expecting a number not a string, so that column needs changing somehow.import pandas as pd data = pd.read_csv("some_data.csv") for index, series in data.iterrows(): #desired_number = row[1][5] # desired_number = series['Number_Header'] data.at[index, 'Result_Header'] = 10 # data.at[index, 'Result_Notes'] = 'This is your desired number' # ValueError: could not convert string to float: 'This is your desired number' print(data) # data.to_csv("some_data_output.csv")
Output: Account_Number Invoice_Date Invoice_Number Payor Ground_Tracking_ID_Prefix Express_or_Ground_Tracking_ID ... Standard Transit By Time Status Reason Exception Result_Header Result_Notes
0 X1231Z1123 4/13/2019 0000A031 P/P NaN 1Z112091091208143 ... 23:30:00 XX-XXX NaN NaN 10.0 NaN
1 X1231Z1123 4/13/2019 0000A031 P/P NaN 1Z112091091208144 ... 23:30:00 XX-XXX NaN NaN 10.0 NaN
2 X1231Z1123 4/13/2019 0000A031 P/P NaN 1Z112091091208145 ... 23:30:00 XX-XXX NaN NaN 10.0 NaN
3 X1231Z1123 4/13/2019 0000A031 P/P NaN 1Z112091091208146 ... 23:30:00 XX-XXX NaN NaN 10.0 NaN