0

There are seven "Species" of fish in this data set, some have very few observations . To make analysis of Species a little easier, I need to create a new column in the data called Species.grouped that indicates if the fish is "Perch", "Bream", or "Other". So I have to group the 5 smallest groups of "Species" into a single group called "Other". The resultant column (Species.grouped) should have the value "Perch" if the fish is a Perch, "Bream" if it's a Bream, and "Other" if it's anything else.

Then I need to run a regression predicting the Weight of a fish using Species.grouped and Width as independent predictor variables (no interaction).

1 Answers1

1

Looks like a problem that could be solved by mapping 'Species' values to desired values/categories like 'Perch', 'Bream' and 'Other' using a dictionary and then applying that onto pandas.

This Answer shows plenty of examples that could help you achieve your requirement.

a_jelly_fish
  • 478
  • 6
  • 21