خرید بک لینک

Vote count: 0

how to remove a pandas dataframe from another dataframe, just like the set subtraction:

a=[1,2,3,4,5]
b=[1,5]
a-b=[2,3,4]

and now we have two pandas dataframe, how to remove df2 from df1

In [5]: df1=pd.DataFrame([[1,2],[3,4],[5,6]],columns=['a','b'])
In [6]: df1
Out[6]:
   a  b
0  1  2
1  3  4
2  5  6


In [9]: df2=pd.DataFrame([[1,2],[5,6]],columns=['a','b'])
In [10]: df2
Out[10]:
   a  b
0  1  2
1  5  6

then we expect df1-df2 result will be

In [14]: df
Out[14]:
   a  b
0  3  4

how to do it? thank you.

asked 35 secs ago

برچسب: نویسنده: استخدام کار تاريخ: پنجشنبه 30 ارديبهشت 1395 ساعت: 11:07

صفحه بندی