1. 程式人生 > >pandas讀寫excel

pandas讀寫excel

AD clu amp clas xls pri sum color false

import pandas as pd
import numpy as np


df = pd.read_csv("result.csv")              # csv
# df = pd.read_excel("sample.xlsx")         # excel
df.to_excel("sample.xlsx", encoding="gbk", index=False)     # write data to excel
print(df.head(10))
# include row title, read 0-3 row data, sum is 5 row, read 0-1 column data, sum is 2 column
column = df.ix[:3, :2] column.to_excel("sample.xlsx", encoding="gbk", index=False)

pandas讀寫excel