Reputation: 7343
I'm completely baffled by the below snippets. I expected both to give me the same output, but that doesn't seem to be the case.
Upvotes: 0
Views: 42
Reputation: 1055
I think the top snippet is returning the length of the entire dataframe.
Consider :
import pandas as pd
df = pd.DataFrame.from_dict({"A":[1, 1, 0, 0, 1]})
print(len(df["A"]==1))
Output : 5
Upvotes: 1