Pandas DataFrame.where() Function Syntax
Syntax: DataFrame.where(cond, other=nan, inplace=False, axis=None, level=None, errors=’raise’, try_cast=False, raise_on_error=None)
Parameters:
- cond: One or more condition to check data frame for.
- other: Replace rows which don’t satisfy the condition with user defined object, Default is NaN
- inplace: Boolean value, Makes changes in data frame itself if True
- axis: axis to check( row or columns)
For the link to the CSV file used, Click here.
Python | Pandas DataFrame.where()
Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric Python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
Pandas where()
method in Python is used to check a data frame for one or more conditions and return the result accordingly. By default, The rows not satisfying the condition are filled with NaN value.