資料讀入、輸出
import pandas as pd
df_straw_hat_old = pd.read_excel(r'straw_hat_old.xlsx')
df_straw_hat_new = pd.read_csv(r'straw_hat_new.csv')
print(type(df_straw_hat_old))
df_straw_hat_old
df_straw_hat_old.to_excel(r'straw_hat_old_python.xlsx')
df_straw_hat_new.to_csv(r'straw_hat_new_python.csv')
df_straw_hat_old.to_excel(r'straw_hat_old_python.xlsx', index=False)
df_straw_hat_new.to_csv(r'straw_hat_new_python.csv', index=False)
csv檔案的編碼問題
df_straw_hat_new_python = pd.read_csv(r'straw_hat_new_python.csv')
df_straw_hat_new_python = pd.read_csv(r'straw_hat_new_python.csv', encoding='ANSI')
df_straw_hat_new_python
df_straw_hat_new.to_csv(r'straw_hat_new_python.csv', index=False, encoding='utf-8')
df_straw_hat_new_python = pd.read_csv(r'straw_hat_new_python.csv')
df_straw_hat_new_python
使用pandas讀讀看自己的檔案吧