-2

I don't know python at all but the project I'm currently working on must be done using it, I have this r code

y_train <- subset(train_df_cleaned_2, Id==IdExec)$Y

and I need to do the exact same thing in python. How do I do it? Thank you

JareBear
  • 37
  • 1
  • 5

2 Answers2

1

The standard way of doing this in Python is comprehension, e.g.:

y_train = [x for x in train_df_cleaned_2 if x.Id == IdExec]
Samwise
  • 68,105
  • 3
  • 30
  • 44
0

I found this answer using this :subsetting a Python DataFrame

y = train[(train.NflId == train.NflIdRusher)][['Yards']]

thanks for the help everyone

JareBear
  • 37
  • 1
  • 5