Pandas version checks
-
[X] I have checked that this issue has not already been reported.
-
[X] I have confirmed this bug exists on the latest version of pandas.
-
[X] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
import pandas as pd
elec_map = pd.DataFrame({
'Channel-ID': {
0: 1,
1: 2,
2: 3,
3: 4,
4: 5,
5: 6,
6: 7,
7: 8,
8: 9,
9: 10,
10: 11,
11: 12,
12: 13,
13: 14,
14: 15,
15: 16,
16: 17,
17: 18,
18: 19,
19: 20,
20: 21,
21: 22,
22: 23,
23: 24,
24: 25,
25: 26,
26: 27,
27: 28,
28: 29,
29: 30,
30: 31,
31: 32,
32: 33,
33: 34
},
'Electrode-ID': {
0: 'CPz',
1: 'O1',
2: 'CP3',
3: 'FC3',
4: 'F3',
5: 'POz',
6: 'C3',
7: 'Pz',
8: 'T7',
9: 'Fp1',
10: 'FT7',
11: 'P9',
12: 'F7',
13: 'P3',
14: 'TP7',
15: 'P7',
16: 'CP4',
17: 'P4',
18: 'Cz',
19: 'O2',
20: 'FCz',
21: 'C4',
22: 'Fp2',
23: 'Fz',
24: 'F8',
25: 'TP8',
26: 'P8',
27: 'P10',
28: 'FT8',
29: 'F4',
30: 'T8',
31: 'FC4',
32: 'LPA',
33: 'RPA'
}
})
currents_df = pd.DataFrame({
'channel': {
11: 'F3',
19: 'FT9',
20: 'FT7',
21: 'FC5',
30: 'T9',
31: 'T7',
40: 'T10',
41: 'TP9',
42: 'TP7',
43: 'CP5',
44: 'CP3',
53: 'P7'
},
'current': {
11: 0.0008434357056398325,
19: -0.0004334751646561182,
20: 0.0,
21: 0.001,
30: -0.0009347905292310828,
31: 0.0004599508945342969,
40: -0.0008397712315939873,
41: 0.0,
42: 0.001,
43: -0.0007919630745188124,
44: -0.001,
53: 0.0006966133998258704
}
})
merged_df = elec_map.merge(currents_df,
left_on='Electrode-ID',
right_on='channel')
Issue Description
Hi,
as mention in the title, it seems there is some rounding happening in the merge; so after few non-0 currents are 0
any idea?
thanks
Expected Behavior
no rounding (non-0 values)
Installed Versions
Comment From: phofl
Hi, thanks for your report. Please reduce your example so that only the rows that are strictly necessary are in it.
Comment From: ggrrll
just realised that this is not related to merging... also subsetting creates the same issue (similar operation)
currents_df[currents_df.channel.isin(elec_map['Electrode-ID']) ]
Comment From: phofl
Please reduce the size of your DataFrame. It should not have more than 2 or three rows if possible
Comment From: ggrrll
never mind -- was a trivial (different) reason
(you can delete the issue)