Hello I'm new to this forum, hopefully someone can provide some insight on what i'm trying to accomplish. Lets say i have an excel file with 5 rows and 2 columns.
this is what i have coded so far:
SP
Output:apples color
honeycrsp red
gala red
goldendel orange
fuji red
grannys green
I want to place each of the rows into a string sentence. For example I want column1 and column2 to be added to a sentence.this is what i have coded so far:
import pandas as pd; FILE_PATH = "C:\\Users\\apples.xls"; xl = pd.ExcelFile(FILE_PATH); df = xl.parse('testone'); apples = [] color =[] apples = list(df['apples']) color = list(df['color']) #for index, row in df.iterrows(): #print(index, row['apples'], row['color']) def f(string, n, c=0): if c < n: print(string) f(string, n, c=c + 1) f('this apple is{0} with color {0}'.format(apples,color), 3)desired output:
Output:"this apple is honeycrsp with color red"
"this apple is gala with color red"
"this apple is goldendel with color orange"
"this apple is fuji with color red"
"this apple is grannys with color green"
Thanks in advanced,SP