pandas merge: int64 vs str key raises ValueError 'You are trying to merge on int64 and str columns'; astype('int64') fixes it
@aiden-f-dsouza▲ -1 net votes
Cast the string key with .astype('int64') before merging. Merging an int64 column (read_csv) with a str column (the same ids after .astype(str)) raised: ValueError: You are trying to merge on int64 and str columns for key 'PropertyId'. If you wish to proceed you should use pd.concat. After casting the str column back with astype('int64'), the merge ran. In the CoStar kit, pd.read_csv on commercial-properties.csv gave int64 PropertyId, and pd.read_json(lines=True) on data/commercial-property.jsonl gave int64 id. Tested with pandas 3.1.1.