My code:
<code>xdf = pd.DataFrame(data={'A':[-10,np.nan,-2.2],'B':[np.nan,2,1.5],'C':[3,1,-0.3]},index=['2023-05-13 08:40:00','2023-05-13 08:41:00','2023-05-13 08:42:00'])
xdf =
A B C
2023-05-13 08:40:00 -10.0 NaN 3.0
2023-05-13 08:41:00 NaN 2.0 1.0
2023-05-13 08:42:00 -2.2 1.5 -0.3
</code>
<code>xdf = pd.DataFrame(data={'A':[-10,np.nan,-2.2],'B':[np.nan,2,1.5],'C':[3,1,-0.3]},index=['2023-05-13 08:40:00','2023-05-13 08:41:00','2023-05-13 08:42:00'])
xdf =
A B C
2023-05-13 08:40:00 -10.0 NaN 3.0
2023-05-13 08:41:00 NaN 2.0 1.0
2023-05-13 08:42:00 -2.2 1.5 -0.3
</code>
xdf = pd.DataFrame(data={'A':[-10,np.nan,-2.2],'B':[np.nan,2,1.5],'C':[3,1,-0.3]},index=['2023-05-13 08:40:00','2023-05-13 08:41:00','2023-05-13 08:42:00'])
xdf =
A B C
2023-05-13 08:40:00 -10.0 NaN 3.0
2023-05-13 08:41:00 NaN 2.0 1.0
2023-05-13 08:42:00 -2.2 1.5 -0.3
Consider only values below 4.0 and above -4.0 in each row of the dataframe
<code>print(xdf[((xdf<4.0).all(axis=1))&((xdf>-4.0).all(axis=1))])
</code>
<code>print(xdf[((xdf<4.0).all(axis=1))&((xdf>-4.0).all(axis=1))])
</code>
print(xdf[((xdf<4.0).all(axis=1))&((xdf>-4.0).all(axis=1))])
Present output:
<code> A B C
2023-05-13 08:42:00 -2.2 1.5 -0.3
</code>
<code> A B C
2023-05-13 08:42:00 -2.2 1.5 -0.3
</code>
A B C
2023-05-13 08:42:00 -2.2 1.5 -0.3
Expected output: My above code drops a row if there is a NaN in one column, despite other columns satisfying the filter condition. So, I want to omit NaN columns and consider non-NaN columns in <> operation.
<code> A B C
2023-05-13 08:41:00 NaN 2.0 1.0
2023-05-13 08:42:00 -2.2 1.5 -0.3
</code>
<code> A B C
2023-05-13 08:41:00 NaN 2.0 1.0
2023-05-13 08:42:00 -2.2 1.5 -0.3
</code>
A B C
2023-05-13 08:41:00 NaN 2.0 1.0
2023-05-13 08:42:00 -2.2 1.5 -0.3