'Pandas dataframe column values end as zero when merged

I have a Pandas dataframe with a column weekday_surcharge, with the following values:

boxes_agg_final_mile_surcharges_buffer.groupby('weekday_surcharge').size()
weekday_surcharge
0.00     202404
6.07        375
16.00         3
dtype: int64

As you can see, the column contains three different values.

I merge this dataframe with another one, this way: boxes_agg_final_mile_all_rates = boxes_agg_final_mile_base_rates.merge(boxes_agg_final_mile_surcharges_buffer, how='left') and, in the resulting dataframe, column weekday_surcharge contains only zeros:

boxes_agg_final_mile_all_rates.groupby('weekday_surcharge').size()
weekday_surcharge
0.0    24830
dtype: int64

As you can see, all values in that column ended up as zero.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source