当前位置: 首页>>代码示例>>Python>>正文


Python ExcelWriter.close方法代码示例

本文整理汇总了Python中pandas.ExcelWriter.close方法的典型用法代码示例。如果您正苦于以下问题:Python ExcelWriter.close方法的具体用法?Python ExcelWriter.close怎么用?Python ExcelWriter.close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pandas.ExcelWriter的用法示例。


在下文中一共展示了ExcelWriter.close方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: build_and_send_email

# 需要导入模块: from pandas import ExcelWriter [as 别名]
# 或者: from pandas.ExcelWriter import close [as 别名]
    def build_and_send_email(self, data, options):
        date = timezone.now().date().strftime('%Y_%m_%d')

        if 'recipients' in options:
            print 'yes'
            recipients = options['recipients']
        else:
            print 'no'
            recipients = settings.DEFAULT_WEEKLY_RECIPIENTS

        print 'recipients:', recipients

        message = EmailMessage(subject='Kikar Hamedina, Weekly Report: %s' % date,
                               body='Kikar Hamedina, Weekly Report: %s.' % date,
                               to=recipients)
        w = ExcelWriter('Weekly_report_%s.xlsx' % date)

        for datum in data:
            # csvfile = StringIO.StringIO()
            pd.DataFrame.from_dict(datum['content']).to_excel(w, sheet_name=datum['name'])

        w.save()
        w.close()
        # f = open(w.path, 'r', encoding='utf-8')
        message.attach_file(w.path)
        message.send()
开发者ID:RobotnickIsrael,项目名称:kikar-hamedina,代码行数:28,代码来源:kikar_weekly_report.py

示例2: save_peaks_excel

# 需要导入模块: from pandas import ExcelWriter [as 别名]
# 或者: from pandas.ExcelWriter import close [as 别名]
def save_peaks_excel(peakOnlyHdf5,xlsxFile):
    dsets = h5py.File(peakOnlyHdf5,'r')
    writer = ExcelWriter(xlsxFile)
    for _key in dsets.keys():
        dset = dsets[_key]
        _df = pd.DataFrame(list(dset))
        _df.to_excel(writer,_key,header=False, index=False)
        print(_key+'sheet is created')
    writer.save()
    writer.close()
开发者ID:byeungchun,项目名称:minlab,代码行数:12,代码来源:utils.py

示例3: GetPrices

# 需要导入模块: from pandas import ExcelWriter [as 别名]
# 或者: from pandas.ExcelWriter import close [as 别名]
def GetPrices():
    """ Goes to the URL, Reads the CSV download link, and creates the CSV DataFrame"""
    url = "http://fundresearch.fidelity.com/mutual-funds/fidelity-funds-daily-pricing-yields/download"
    CSV_Import = urllib.request.urlopen(url).read() 
    CSV = pd.read_csv(url, skiprows=3) 
    
    """ Creates CSV File to be opened in Excel. 
    This can be removed if you don't need Excel and you can just use CSV as the DataFrame """ 
    File = 'DailyPrices'
    writer = ExcelWriter(str(File) + '.xlsx')
    CSV.to_excel(writer, 'DailyReport', index = False)
    writer.close() 
    os.startfile(File + '.xlsx') 
开发者ID:evy555,项目名称:Fidelity-Daily-Prices,代码行数:15,代码来源:FidelityPrices.py

示例4: save_data

# 需要导入模块: from pandas import ExcelWriter [as 别名]
# 或者: from pandas.ExcelWriter import close [as 别名]
def save_data(Working_Directory, Result_Directory, name_file, Duration_ON, Duration_OFF, Num_pixels_ON, Num_pixels_OFF):
    ## Excel data
    #Save duration 
    Duration = list()
    Stimulus_Type = list()
    Matched_Pixels = list()
    Stimulus_Index = list()
    count=0
    for ii in xrange(size(Duration_ON,0)):
        Duration.append(mean(Duration_ON[ii,:]))
        Matched_Pixels.append(Num_pixels_ON[ii,:])
        Stimulus_Type.append(str(count+1)+'ON')
        Stimulus_Index.append(count)
        count=count+1
    for ii in xrange(size(Duration_OFF,0)):
        Duration.append(mean(Duration_OFF[ii,:]))
        Matched_Pixels.append(Num_pixels_OFF[ii,:])
        Stimulus_Type.append(str(count+1)+'OFF')   
        Stimulus_Index.append(count)
        count=count+1
    
    ## For fish 23, change OFF to ON and save
#    Stimulus_Type[2] = '3ON'
        
    #Save matched_pixels 
    Name_stimulus = get_list_of_stimulus_name(Working_Directory)
    Label_plane, Label_stimulus = label_stimulus(Name_stimulus,Stimulus_Type)
    Stim_type_all = repeat(Stimulus_Type, size(Matched_Pixels,1))
    Matched_Pixels_all = reshape(Matched_Pixels, (size(Matched_Pixels)))
    Name_stimulus_all = tile(Name_stimulus, size(Matched_Pixels,0))
    # Some data frames
    df1 = DataFrame({'Stimulus_Type':Stimulus_Type,'TDuration':Duration}) #Only duration
    df2 = DataFrame(index=Stimulus_Index, columns=Name_stimulus) # pixels to concatenate with duration
    df3 = DataFrame(index=Stimulus_Type, columns=Name_stimulus) #pixels tandalone
    df4 = DataFrame({'Stimulus_Type':Stim_type_all, 'Pixels':Matched_Pixels_all,\
    'Label_plane':Label_plane, 'Label_stimulus':Label_stimulus, 'Original_Stim':Name_stimulus_all}) #label pixels with stimulus and z plane
    df4["Stimulus"] = df4.Label_stimulus.map(Label_Odor_reverse)
    
    for ii in xrange(0,size(Stimulus_Index)):
        df2.ix[ii] = Matched_Pixels[ii]
        df3.ix[ii] = Matched_Pixels[ii]
    df = concat([df1,df2], join='inner', axis=1)
    #Save to excel
    writer = ExcelWriter(Result_Directory+ filesep+'Classified_Results'+filesep+name_file+ '.xlsx', engine='xlsxwriter')
    df.to_excel(writer, sheet_name='sheet1')
    writer.close()
    
    return df, df1, df3, df4
开发者ID:seethakris,项目名称:Olfactory-Chip-Scripts,代码行数:50,代码来源:classify_active_pixels.py

示例5: build_and_send_email

# 需要导入模块: from pandas import ExcelWriter [as 别名]
# 或者: from pandas.ExcelWriter import close [as 别名]
    def build_and_send_email(self, data, options):
        date = timezone.now().date().strftime('%Y_%m_%d')

        if options['beta_recipients_from_db']:
            print 'beta recipients requested from db.'
            recipients = [a.email for a in WeeklyReportRecipients.objects.filter(is_active=True, is_beta=True)]
        elif options['recipients_from_db']:
            print 'recipients requested from db.'
            recipients = [a.email for a in WeeklyReportRecipients.objects.filter(is_active=True)]

        elif options['recipients']:
            print 'manual recipients requested.'
            recipients = options['recipients']
        else:
            print 'no recipients requested.'
            recipients = settings.DEFAULT_WEEKLY_RECIPIENTS

        if not recipients:
            print 'no recipients in db.'
            recipients = settings.DEFAULT_WEEKLY_RECIPIENTS

        print 'recipients:', recipients

        message = EmailMessage(subject='Kikar Hamedina, Weekly Report: %s' % date,
                               body='Kikar Hamedina, Weekly Report: %s.' % date,
                               to=recipients)
        w = ExcelWriter('Weekly_report_%s.xlsx' % date)

        for datum in data:
            # csvfile = StringIO.StringIO()
            pd.DataFrame.from_dict(datum['content']).to_excel(w, sheet_name=datum['name'])

        w.save()
        w.close()
        # f = open(w.path, 'r', encoding='utf-8')
        message.attach_file(w.path)
        message.send()
开发者ID:50stuck,项目名称:kikar-hamedina,代码行数:39,代码来源:kikar_weekly_report.py

示例6: gdx_to_df

# 需要导入模块: from pandas import ExcelWriter [as 别名]
# 或者: from pandas.ExcelWriter import close [as 别名]
print 'get balance'
print 'retrieving marg'
marg = gdx_to_df(gdx_file, 'marg')
old_index = marg.index.names
marg['C'] = [zone_dict[z] for z in marg.index.get_level_values('Z')]
marg.set_index('C', append=True, inplace=True)
marg = marg.reorder_levels(['C'] + old_index)
marg.reset_index(inplace=True)
marg = pivot_table(marg, 'marg', index=['Y', 'P', 'T'], columns=['C'], aggfunc=np.sum)

print 'Writing balances.m to Excel'
marg.to_excel(writer, na_rep=0.0, sheet_name='balance', merge_cells=False)


writer.close()

# wb = load_workbook(writefile)
# ws1 = wb.active
# gen_techn = list()
# gen_energ = list()
# gen_margc = list()
# final = list()
# for r in range (2,len(ws1.rows)+1,1):
# #smaller loop for testing
# #for r in range (2,100,1):
#     currentg = ws1.cell(row = r, column = 4).value
#     currente = ws1.cell(row = r, column = 5).value
#     currentc = ws1.cell(row = r, column = 6).value
#     if currentg not in gen_techn:
#         gen_techn.append(currentg)
开发者ID:WoutjeParys,项目名称:thesis_Wout_Final,代码行数:32,代码来源:get_output_Wout.py

示例7: print

# 需要导入模块: from pandas import ExcelWriter [as 别名]
# 或者: from pandas.ExcelWriter import close [as 别名]
    elif df.loc[l[i], 'Signal'] == "Hold":
        df.loc[l[i], 'Investment'] = df.loc[l[i-1], 'Investment'] * (1 + df.loc[l[i], "Returns"])

print(df.head())
        



#Excess Return over S&P500 Column 
#for i in range(1,len(l)):
#    df.loc[l[i], 'Excess Return'] = df.loc[l[i], 'Investment'] - df.loc[l[i], 'S&P500 Investment']

    
file = ExcelWriter('Time1.xlsx')
df.to_excel(file, 'Data')
file.close()
os.startfile('Time1.xlsx')

df.plot(y = ['Investment', 'S&P500 Investment'])
plt.show() 




print("Average Monday return: %s" % (Monday/MonCount))      
print("Average Tuesday return: %s" % (Tuesday/TueCount))
print("Average Wednesday return: %s" % (Wednesday/WedCount))
print("Average Thursday return: %s" % (Thursday/ThuCount))
print("Average Friday return: %s" % (Friday/FriCount))

print("1 sample t-tests for each day to test significance of daily returns against 0 are as follows:")
开发者ID:evy555,项目名称:Stock-day-of-week-return-analysis,代码行数:33,代码来源:S&PTimeTest.py


注:本文中的pandas.ExcelWriter.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。