Search code examples
pythonpandasdataframewhere-clause

How to use where method in python when getting error everytime?


I am trying to apply a .where function to this data frame so that it filters by pitch type, but am getting the error "Array conditional must be same shape as self" every-time. Never had this issue with any past data frames,

included an image of the error

as well as

an image of the column in the dataframe


Solution

  • I'm not sure what are.equal_to is, but this should work for you:

    fastball = march[march["TaggedPitchType"] == "Fastball"]