I have two DataFrames
and I want to perform the same list of cleaning ops.
I realized I can merge into one, and to everything in one pass, but I am still curios why this method is not working
test_1 = pd.DataFrame({
"A": [1, 8, 5, 6, 0],
"B": [15, 49, 34, 44, 63]
})
test_2 = pd.DataFrame({
"A": [np.nan, 3, 6, 4, 9, 0],
"B": [-100, 100, 200, 300, 400, 500]
})
Let's assume I want to only take the raws without NaN
s: I tried
for df in [test_1, test_2]:
df = df[pd.notnull(df["A"])]
but test_2
is left untouched. On the other hand if I do:
test_2 = test_2[pd.notnull(test_2["A"])]
Now I the first raw went away.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…