更新时间:2022-12-11 20:19:05
下面是一个示例,说明了EdChum给出的答案.有很多其他选项可以加载CSV文件,请检查
Here is an example illustrating the answer given by EdChum. There is a lot of additional options to load a CSV file, check the API reference.
raw_data = {'first_name': ['Steve', 'Guido', 'John'],
'last_name': ['Jobs', 'Van Rossum', "von Neumann"]}
df = pd.DataFrame(raw_data)
# Saving data without header
df.to_csv(path_or_buf='test.csv', header=False)
# Telling that there is no header and loading only the first name
df = pd.read_csv(filepath_or_buffer='test.csv', header=None, usecols=[1], names=['first_name'])
df
first_name
0 Steve
1 Guido
2 John