In Python function calls are indeed not assignable, which creates the necessity to adapt a little the R code.
Try:
df[df.names.index('a')] = df.rx2('a').ro / 10
Question
I read data from a CSV file using rpy2's read_csv() which creates a DataFrame. Now I want to directly manipulate an entire column. What I tried so far:
from rpy2.robjects.packages import importr
utils = importr('utils')
df = utils.read_csv(logn, header=args.head, skip=args.skip)
df.rx2('a').ro / 10
which I expected to write back to the DataFrame which it apparently doesn't: df
is not affected by this operation. So, another idea was
df.rx2('a') = df.rx2('a').ro / 10
but that produces an error that function calls are not assignable - which is not obvious to me since the LHS should return a Vector(?)
So what did I miss?
Solution
In Python function calls are indeed not assignable, which creates the necessity to adapt a little the R code.
Try:
df[df.names.index('a')] = df.rx2('a').ro / 10