import pandas as pd
df_csv = pd.read_csv('example.csv')
import pandas as pd
df_xlsx = pd.read_excel('example.xlsx')
import pandas as pd
df_no_header = pd.read_csv('no_header.csv', header=None)
import pandas as pd
df_with_header = pd.read_csv('with_header.csv')
import pandas as pd
df = pd.read_excel('example.xlsx')
first_column = df.iloc[:, 0] # 获取第一列数据
import pandas as pd
data = {
'Column1': [1, 2, 3],
'Column2': ['A', 'B', 'C']
}
df = pd.DataFrame(data)
df.to_excel('output.xlsx', index=False)
以上就是我最近用到的一些pandas小代码,后续还有更新!!