Python Pandas performing operation on each row of CSV file -


i have 1million line csv file. want call lookup function on each row's 1'st column, , append result new column in same csv (if possible).

what want this:

for each row in dataframe    string=row[1]    result=lookupfunction(string)    row.append[string] 

i know using python's csv library opening csv, read each row, operation, write results new csv.

this code using python's csv library

with open(rawfile, 'r') f:     open(newfile, 'a') csvfile:         csvwritter = csv.writer(csvfile, delimiter=' ')         line in f:              #do operation 

however want pandas because new me. data looks like

77,#oshkosh #         tannersville pa,,pa,us 82,#osithesakcom         ca,,ca,us 88,#osp open records        or,,or,us 89,#ospbco      tel ord   in,,in,us 98,#ospwmnwithn return    in,,in,us 99,#ospwmnwithn tel ord   in,,in,us 100,#osram sylvania inc      ma,,ma,us 106,#osteria giotto        montclair    nj,,nj,us 

any , guidance appreciated it. thanks

here simple example of adding 2 columns new column csv file

import pandas pd  df = pd.read_csv("yourpath/yourfile.csv")  df['newcol'] = df['col1'] + df['col2'] 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -