I can use for loop to print every row of the data frame.
import pandas as pd
data = {"col1": [1.1, 2.2, 3.3]
, "col2": [4.4, None, 6.6]}
csv = pd.DataFrame(data)
for i in range(len(csv)):
col1 = csv["col1"][i]
col2 = csv["col2"][i]
print(col1, col2)
But when I use pd.notnull to filter data frame, for loop will have an error.
csv = csv[pd.notnull(csv["col2"])]
print("csv:{}".format(csv))
for i in range(len(csv)):
col1 = csv["col1"][i]
col2 = csv["col2"][i]
print(col1, col2)
The error is
KeyError: 1
Anyone know iterate data frames by the name of the columns after pd.notnull.