Apr-22-2019, 01:43 PM
Hi all,
Thank you in advance for all suggestions. I am attempting to read data from a csv file and populate a field ('Result_Header') with a value. The example below is just to help me understand the concept -- the final code will actually be populating a value from an api call (that part I figured out). I am just getting tripped up on the to_csv function.
print(data) shows me that the column is being populated correctly, it is just the to_csv where I get the error below.
Thank you in advance for all suggestions. I am attempting to read data from a csv file and populate a field ('Result_Header') with a value. The example below is just to help me understand the concept -- the final code will actually be populating a value from an api call (that part I figured out). I am just getting tripped up on the to_csv function.
print(data) shows me that the column is being populated correctly, it is just the to_csv where I get the error below.
import pandas as pd data = pd.read_csv("C:\\Users\\X\\Documents\\X\\some_data.csv") for data in data.iterrows(): #desired_number = data[1][5] desired_number = data[1]['Number_Header'] data[1]['Result_Header'] = desired_number data[1]['Result_Notes'] = 'This is your desired number' print(data) data.to_csv("C:\\Users\\X\\Documents\\X\\some_data_output.csv")
Error:AttributeError: 'tuple' object has no attribute 'to_csv'