pandas数据操作与sql对比

https://blog.csdn.net/u010161379/article/details/79187614

补充 sql中的in 和not in 在dataframe是如下表示

import pandas as pd
data = pd.DataFrame(
    {"name": ["Tom", "Mary", "Jerry", "Mark"], 
    "age":[18, 22, 19, 31], 
    "gender":["M", "F", "M", "M"]})
#in
data.age.isin((18, 22, 19))
#not in
~data.age.isin([18, 22, 19])

#获取筛选的数据
data[data.age.isin([18, 22])]

你可能感兴趣的:(pandas数据操作与sql对比)