4 ms·
The thing I've been looking for in pandas is: df %>% mutate(x = y[2] + z[3]) %>% filter(x > 4) I haven't found anything like this in pandas; I haven't found
by j88439h84 9y ago
The thing I've been looking for in pandas is:
df %>%
mutate(x = y[2] + z[3]) %>%
filter(x > 4)
I haven't found anything like this in pandas; I haven't found any of the pandas dplyr emulators able to do either of these transformations cleanly.
If anybody knows a way, I'd love to hear it. (But afaik dplython etc can't do it.)
- ljw1001 9y agoCould you please explain what that expression is intended to accomplish so I can be sure that I understand the example?
- in9 9y agoThis example seems a little odd, since it takes a data frame and mutates the x column to be equal (all entries of the column) to the sum of the second component of the y column/vector to the 3rd component of the z column/vector. It is odd since they whole column turns into one value.
- in9 9y agoit is quite simple in pandas, but as a said in another comment, your example is a bit weird, since it turns all values of x into the same. But this is how to do it: df.assign(x = lambda x: x.ix[2, 'y']).query('x > 3')