from sklearn.linear_model import LinearRegression
from sklearn.model_selection import train_test_split
freq_port = df.Sex.dropna().mode()[0] # mode返回出现最多的数据,col_name为列名
df['Sex'] = df['Sex'].fillna(freq_port) #采用出现最频繁的值插补
输出是---------------------------------------------------------------------------NameError Traceback (most recent call last)/tmp/ipykernel_98/2308284494.py in
1 from sklearn.linear_model import LinearRegression
2 from sklearn.model_selection import train_test_split
----> 3 freq_port = df.Sex.dropna().mode()[0] # mode返回出现最多的数据,col_name为列名
4 df['Sex'] = df['Sex'].fillna(freq_port) #采用出现最频繁的值插补
NameError: name 'df' is not defined