# 定义list del_col
del_col = [0, 38, 39, 46, 51, 56, 57, 64, 69, 74, 75, 82, 87]
# 删除raw_x_train中del_col的列,axis为1代表删除列
raw_x_train = np.delete(raw_x_train, del_col, axis=1) # numpy数组增删查改方法
# 定义列表get_col
get_col = [35, 36, 37, 47, 48, 35+18, 36+18, 37+18, 47+18, 48+18, 35+18*2, 36+18*2, 37+18*2, 47+18*2, 48+18*2, 52, 52+18]
# [:, get_col]取所有行,get_col指定的列
raw_x_train = raw_x_train[:, get_col] # numpy数组取某几行某几列
pandas.read_csv读取数据
# pd.read_csv('./covid_train.csv')读取covid_train.csv的数据,
# .values选中除第一行列名下面的所有行;不读取第一行的属性值
#
train_data, test_data = pd.read_csv('./covid_train.csv').values, pd.read_csv('./covid_test.csv').values
字符串格式化:字符串中允许使用花括号{ },来引入变量或者表达式
name = "Tom"
age = 18
print(f"My name is {name}, and I am {age} years old.")
加上花括号{},就能在字符串里表示变量和表达式了
x_train = np.array([1.0, 2.0])
y_train = np.array([300.0, 500.0])print(f"x_train : {x_train}")
print(f"y_train : {y_train}")
print(f"""train_data size: {train_data.shape}
valid_data size: {valid_data.shape}
test_data size: {test_data.shape}""")
输出格式为:
train_data size: train_data.shape
valid_data size: valid_data.shape
test_data size: test_data.shape