Imagine the following dataframe:
import pandas as pd
df = pd.DataFrame(columns = ['A','B','C'], index = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday'])
df.loc[['Monday', 'Friday'], ['A', 'C']] = 19
I want to print all columns and rows, that are not NaN. The output should be as follows:
| A | C | |
|---|---|---|
| Monday | 19 | 19 |
| Friday | 19 | 19 |
I have tried different methods, but none of them gives me the required result. I am doing something wrong here. Please help.
df = df[df.isna()]
df[(df.iloc[::]) & (df.isnull() == False)]
Your code:
Output:
Add this to your code:
Output: