Q:

Write a Pandas program to check inequality over the index axis of a given dataframe and a given series

0

Write a Pandas program to check inequality over the index axis of a given dataframe and a given series

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import pandas as pd
df_data = pd.DataFrame({'W':[68,75,86,80,None],'X':[78,75,None,80,86], 'Y':[84,94,89,86,86],'Z':[86,97,96,72,83]});
sr_data = pd.Series([68, 75, 86, 80, None]) 
print("Original DataFrame:")
print(df_data)
print("\nOriginal Series:")
print(sr_data)
print("\nCheck for inequality of the said series & dataframe:")
print(df_data.ne(sr_data, axis = 0))

Sample Output:

Original DataFrame:
      W     X   Y   Z
0  68.0  78.0  84  86
1  75.0  75.0  94  97
2  86.0   NaN  89  96
3  80.0  80.0  86  72
4   NaN  86.0  86  83

Original Series:
0    68.0
1    75.0
2    86.0
3    80.0
4     NaN
dtype: float64

Check for inequality of the said series & dataframe:
       W      X     Y     Z
0  False   True  True  True
1  False  False  True  True
2  False   True  True  True
3  False  False  True  True
4   True   True  True  True

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now