Pandas DataFrame ne() Method
Example
Find which values are not equal to 7:
import pandas as pd
df = pd.DataFrame([[10, 12, 2], [3, 4, 7]])
print(df.ne(7))
Try it Yourself »
Definition and Usage
The ne()
method compares each value in a DataFrame
to check if it is NOT equal to a specified value, or a value from a specified DataFrame
objects, and returns a DataFrame with boolean True/False for each comparison.
Syntax
dataframe.ne(other, axis, level)
Parameters
Parameter | Description |
---|---|
other | Required. A number, list of numbers, or another object with a data structure that fits with the original DataFrame. |
axis | Optional, A definition that decides whether to compare by index or
columns. 0 or 'index' means compare by index. 1 or 'columns' means compare by columns |
level | Optional. A number or label that indicates where to compare. |
Return Value
A DataFrame object.