Feb-28-2018, 07:56 PM
(This post was last modified: Feb-28-2018, 07:56 PM by williamlombard.)
Hi Guys
Can you help me process the data in a spreadsheet, in particular to read values in one column apply some functions and then write the results back to another column.
I will simplify my problem as much as I can. The example I am going to give can be easily done in Excel without any 3rd party help, I just want to make the code as easy to read as possible, so that I can apply it back to my own case - which is a bit more complicated, with additional functions inside the main 'for' loop. All the code there is working fine though.
Thanks for helping me out.
WL
Can you help me process the data in a spreadsheet, in particular to read values in one column apply some functions and then write the results back to another column.
I will simplify my problem as much as I can. The example I am going to give can be easily done in Excel without any 3rd party help, I just want to make the code as easy to read as possible, so that I can apply it back to my own case - which is a bit more complicated, with additional functions inside the main 'for' loop. All the code there is working fine though.
import import pandas as pd df = pd.read_excel('serials.xlsx', sheet_name='Sheet1') listSerialsLower = df['Serial_Lower'] listSerialsUpper = df['Serial_Upper'] writer = pd.ExcelWriter('serials.xlsx', engine='xlsxwriter') for i in listSerialsLower: inputSerial = i upperSerial = str(inputSerial).upper() #please let me know how I can insert the corresponding values #for the lowercase serials into the list (or series?) for the uppercase serials #so that they would appear in the same row in the excel document. #i have tried without success... listSerialsUpper[i] = upperSerial df.to_excel(writer) writer.save()
Thanks for helping me out.
WL