python pandas读写excel

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", 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", index=False)

 

def find_need_data(need_list):
    raw_data = pd.read_excel("raw_data.xlsx")
    all_need = []
   need_list = ["vickey", "wu"]
for n in need_list: # find need data need = raw_data[raw_data["filed"].str.contains(n)] all_need.append(need) # write all need data into excel pd.concat(all_need).to_excel("sample.xlsx", index=False)

 

posted @ 2017-04-20 16:40  随便了888  阅读(32187)  评论(0编辑  收藏  举报