if mixed_dtypes := {c: dtype for c in df.columns if (dtype := pd.api.types.infer_dtype(df[c])).startswith("mixed")}:     raise TypeError(f"Dataframe has one more mixed dtypes: {mixed_dtypes}") 

Read more of this post