I have my algorithm and code. It works but writes the dataframe to an entire column in my output CSV file. I want to write the dataframe to only rows where the column is equal to a certain value. This is on Line 6. Rest of logic, syntax seems fine. I researched a fair few options including sort_values(), apply(), map(), lambda, writing if statements. It seems like an easy solution but I cannot get to write the dataframe to specific rows and column combination. If this question has been asked for before, please refer me to the solution.
Thank you.
Output file - Line 1
df_Working_File = pd.read_csv('Working\WF.csv')
Input File - Line 2
df_GSTRemoved = pd.read_csv('Working\GSTRemoved.csv')
Concat for vlookup essentially in output file - Line 3
df_OriginalKey = df_GSTRemoved.apply(lambda x:x['Origin'] + x['Destination'],1)
Concat for vlookup in input file - Line 4
df_Key = df_Working_File.apply(lambda x:x['Origin'] + x['Destination'],1)
Value of column dataset to write - Line 5
df_Charge_Per_Item = df_GSTRemoved['500g']
Line 6 - I want to write the dataframe to column 9 for all rows where Origin is GL in the input file
df_Working_File.apply(df_Charge_Per_Item, df_Working_File['Origin'] == 'GL')
Line 7 - Writing to csv with no index column
df_Working_File.to_csv("Working/writetoCSV.csv", index=False)