I have a dictionary:
matches = {282: 285,
266: 277,
276: 293,
263: 264,
286: 280,
356: 1371,
373: 262,
314: 327,
294: 290,
285: 282,
277: 266,
293: 276,
264: 263,
280: 286,
1371: 356,
262: 373,
327: 314,
290: 294}
And a df, like so:
team_id
0 327
1 293
2 373
3 282
4 314
5 263
6 280
7 354
8 264
9 294
10 1371
11 262
12 266
13 356
14 290
15 285
16 286
17 275
18 277
19 276
Now I'm trying to create an 'adversary_id' column, mapped from the dict, like so:
df['adversary_id'] = df['team_id'].map(matches)
But this new column adversary_id is being converted to type float, and two rows are ending up with NaN:
Why, if all data is type int?
How do I fix this?