import os
os.makedirs(os.path.join(‘…’, ‘data’), exist_ok=True)
data_file = os.path.join(‘…’, ‘data’, ‘house_tiny.csv’)
with open(data_file, ‘w’) as f:
f.write(‘NumRooms,Alley,Price\n’)
f.write(‘NA,Pave,127500\n’)
f.write(‘2,NA,106000\n’)
f.write(‘4,NA,178100\n’)
f.write(‘NA,NA,140000\n’)
import pandas as pd
data = pd.read_csv(data_file)
print(data)
data = data.drop(columns=data.columns[[i for i,x in enumerate(list(data.isnull().sum())) if x==max(list(data.isnull().sum()))]])
data.iloc[:,0] = data.iloc[:,0].fillna(data.iloc[:,0].mean())
import numpy as np
import tensorflow as tf
tf.constant(np.array(data))
如下是我的作业,请指正,谢谢。在jupyter py3.8下运行