python里except什么意思_python – Pandas中SQL中EXCEPT子句的类比是什么?

我认为你首先需要

set_index的所有字符串列:

df2 = df.set_index('col1').subtract(df1.set_index('col1'),axis='columns')

print (df2)

col2 col3 col4

col1

a 0.0 0.0 0.0

b NaN NaN NaN

c NaN NaN NaN

d NaN NaN NaN

e 0.0 0.0 0.0

f 0.0 0.0 0.0

g 0.0 0.0 0.0

要么:

df2 = df.set_index('col1').subtract(df1.set_index('col1'),axis='columns',fill_value=0)

print (df2)

col2 col3 col4

col1

a 0.0 0.0 0.0

b NaN NaN 6.0

c NaN 8.0 9.0

d NaN 11.0 12.0

e 0.0 0.0 0.0

f 0.0 0.0 0.0

g 0.0 0.0 0.0

编辑问题编辑:

print (df.isin(df1))

col1 col2 col3 col4

0 True True True True

1 False False False False

2 False False False False

3 False False False False

4 True True True True

5 True True True True

6 True True True True

print (df.isin(df1).all(axis=1))

0 True

1 False

2 False

3 False

4 True

5 True

6 True

dtype: bool

print (~df.isin(df1).all(axis=1))

0 False

1 True

2 True

3 True

4 False

5 False

6 False

dtype: bool

print (df[~(df.isin(df1).all(axis=1))])

col1 col2 col3 col4

1 b NaN NaN 6

2 c NaN 8.0 9

3 d NaN 11.0 12

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值