I'm using Pandas to drive a Python function. From inputs.csv, I use each row in "Column A" as an input for the function.
In the csv, there is also a "Column B" that contains values that I want to read into a variable x within the function. It should not apply from "Column B" – this should still be done from "Column A". Is this possible?
This is the current code that applies the function from "Column A":
import pandas as pd
df = pd.read_csv(inputs.csv, delimiter=",")
def function(a):
#variables c, d, e are created here
###I would like to create x from Column B if possible
return pd.Series([c, d, e])
df[["Column C", "Column D", "Column E"]] = df["Column A"].apply(function)
Post-edit: This question has been identified as a possible duplicate of another question. Although the answer may be the same, the question is not the same. For future readers it is probably not apparent that apply on two columns is interchangeable with apply on one column and "reading" another column at the same time. The question should therefore remain open.