标签:install import == name port rate sheet for __init__
先安装2个库
pip install pandas
pip install openpyxl
import pandas as pd
class Excel():
def __init__(self):
pass
def get_index(self):
datas = pd.read_excel(‘satisfaction.xlsx‘,sheetname=‘Sheet1‘)
all_rigion = list(datas.ix[:,1])
series_list = []
rigion = [‘Northeast Europe‘,‘Western Europe‘,‘Middle East‘]
NE_index,WE_index,ME_index, = [],[],[]
row_index = [NE_index,WE_index,WE_index]
for index, item in enumerate(all_rigion):
for i in range(len(row_index)):
if item == rigion[i]:
row_index[i].append(index)
for j in range(len(row_index)):
for k in row_index[j]:
series_list.append(datas.ix[k,:])
result = pd.DataFrame(series_list)
result.to_excel(rigion[j]+‘.xlsx‘,index=False)
t = Excel()
t.get_index()
标签:install import == name port rate sheet for __init__
原文地址:http://www.cnblogs.com/vickey-wu/p/6720801.html