I have the following two dataframes (samples). I’d like to know which companies had their sales changed between the two dataframes. For example, AAPL is different in the second dataframe.
JavaScript
x
25
25
1
Sales 52W High 52W Low
2
Root
3
A 4.81B -0.1072 0.1082
4
AA 12.81B -0.3124 0.0709
5
AABA 266.05M -0.2038 0.0437
6
AAL 43.52B -0.3285 0.1131
7
AAN 3.61B -0.0208 0.4716
8
AAOI 321.80M -0.5196 0.5195
9
AAP 9.42B -0.0153 1.1190
10
AAPL 255.27B -0.0101 0.5210
11
AAXN 385.40M -0.1005 2.3432
12
ABB 35.52B -0.1870 0.0987
13
Sales 52W High 52W Low
14
Root
15
A 4.81B -0.1019 0.1149
16
AA 12.81B -0.3527 0.0082
17
AABA 266.05M -0.2212 0.0208
18
AAL 43.52B -0.3487 0.0797
19
AAN 3.61B -0.0196 0.4733
20
AAOI 321.80M -0.5478 0.4303
21
AAP 9.42B -0.0216 1.1218
22
AAPL 243.89B -0.0286 0.4957
23
AAXN 385.40M -0.0806 2.4171
24
ABB 35.52B -0.1838 0.1030
25
Advertisement
Answer
This you can using ne
(not equal)
JavaScript
1
15
15
1
df1.Sales.ne(df2.Sales)# the one mask as True is the different
2
Out[482]:
3
Root
4
A False
5
AA False
6
AABA False
7
AAL False
8
AAN False
9
AAOI False
10
AAP False
11
AAPL True
12
AAXN False
13
ABB False
14
Name: Sales, dtype: bool
15