"Server: Cone\r\n"
输出
import pandas as pd
df = pd.DataFrame({"A": ["a", "b", "c"], "B": ["d", "e", "f"]})
print(df)
print(df["A"])
if "b" in df.A:
print("if b in A")
for i in df.A:
if i == "b":
print("for b in A")
if 1 in df.A:
print("if index in A")
似乎if-in使用数据帧的索引,for-in使用数据帧的值。为什么会有区别,到底有什么区别?