15.2 Cats again
We again employ the data about cats from the City of Greater Dandenong that I introduced in section 14.2. As before, we clean the data and create gender dummy columns.
import pandas as pd
df = pd.read_csv("src/examples/registered-cats.csv")
del df["Animal_Type"]
del df["Postcode"]
new_column_names = {
"Breed_Description": "Breed",
"Colour_Description": "Colour",
"GENDER": "Gender"
}
df.rename(columns=new_column_names, inplace=True)
df.loc[611, ["Gender"]] = 'F'
df = df[df["Gender"].str.contains("F|M")]
df.reset_index(drop=True, inplace=True)
df.dropna(inplace=True)
df.reset_index(drop=True, inplace=True)
df = pd.get_dummies(df, columns=["Gender"], prefix="", prefix_sep="")
df = df.astype({"F": "int8", "M": "int8"})
df.info()
...