Exercise

Adding the donor segment

Besides age, you also want to add the segment of a donor to the basetable. A selected group of donors that has made many donations in the past is assigned a segment: bronze, silver or gold. Given is an early stage basetable and a pandas dataframe segments that contains the segments for a selected group of the donors in the basetable. In this exercise you will add the segment to the basetable.

You can left join two pandas dataframes using the following code:

merged_df = pd.merge(df1, df2, on=["merge_id"],how="left")

Instructions

100 XP
  • The donor id column is "donor_id" both in segments and basetable. Add the segment to the basetable.
  • Count the number of donors in each segment.
  • Count the number of donors with no segment assigned.