如何使用PyPy作为笔记本解释器?

时间:2015-02-09 06:53:00

标签: pandas pypy

我有一个脚本,用于从某些CSV文件中提取数据,并将数据分成不同的Excel文件。我使用Ipython,我确信它使用CPython作为默认解释器。

但脚本花费了太多时间来完成整个过程。有人可以帮助使用PyPy如何使用该脚本,因为我听说它比CPython快得多。 脚本是这样的:

import pandas as pd
import xlsxwriter as xw
import csv
import pymsgbox as py

file1 = "vDashOpExel_Change_20150109.csv"
file2 = "vDashOpExel_T3Opened_20150109.csv"

path = "C:\Users\Abhishek\Desktop\Pandas Anlaysis"

def uniq(words):
    seen = set()
    for word in words:
        l = word.lower()
        if l in seen:
            continue
        seen.add(l)
        yield word

def files(file_name):
    df = pd.read_csv( path + '\\' + file_name, sep=',', encoding = 'utf-16')

    final_frame = df.dropna(how='all')

    file_list = list(uniq(list(final_frame['DOEClient'])))

    return file_list, final_frame

def fill_data(f_list, frame1=None, frame2=None):
    if f_list is not None:
        for client in f_list:
            writer = pd.ExcelWriter(path + '\\' + 'Accounts'+ '\\' + client + '.xlsx', engine='xlsxwriter')
            if frame1 is not None:
                data1 = frame1[frame1.DOEClient == client]                  # Filter the Data
                data1.to_excel(writer,'Change',index=False, header=True)    # Importing the Data to Excel File

            if frame2 is not None:
                data2 = frame2[frame2.DOEClient == client]                   # Filter the Data
                data2.to_excel(writer,'Opened',index=False, header=True)  # Importing the Data to Excel File

    else:
        py.alert('Please enter the First Parameter !!!', 'Error')
list1, frame1 = files(file1)
list2, frame2 = files(file2)

final_list = set(list1 + list2)

0 个答案:

没有答案
相关问题