1Import using pandas
train = pd.read_csv('train_data_head_Chinese.csv', encoding="gb18030")
If you are using Chinese, remember to set the encoding parameter to gb18030
2 Get the value
Pandas is a data frame, which also contains headers. We only care about its content, so we use the .values method to get the
specific operation:
data = train.values
3 Convert to floating-point type data
data = data.astype(float)
At this point, there is a small tip. If there are many commas (thousand separators) in the number, you need to enter the csv file and change the format to "normal"
4 Convert to tensor
y = torch.from_numpy(data)
Through the above steps, it can be smoothly transformed into a tensor