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


Python ExcelWriter.close方法代码示例

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


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

示例1: __init__

# 需要导入模块: from pandas.io.excel import ExcelWriter [as 别名]
# 或者: from pandas.io.excel.ExcelWriter import close [as 别名]
 def __init__(self, db_filename = "moore_grants_database.xlsx",
              report_prefix = "report", 
              sheet_name = "grants",
              index_column = "url",
              report_only_new = True):
     '''
     Constructor
     '''
     if(not os.path.isfile(db_filename)):
         #generate a blank writable excel sheet from scratch
         field_names = [field_name for field_name in Grant.fields]
         writer = ExcelWriter(db_filename)
         profile_dataframe = pd.DataFrame(columns = field_names)
         profile_dataframe.to_excel(writer,sheet_name)
         writer.save()
         writer.close()
     
     self.report_filename = (report_prefix + "_" 
                             + str(datetime.today())[:19]
                             .replace(":","_").replace(" ","[") + "].xlsx")
     # kept for posterity, in case only the date component is needed and 
     # we don't care about overwrites
     # self.report_filename = report_prefix + "_" + str(date.today())
     self.db_filename = db_filename
     self.sheet_name = sheet_name
     self.dataframe = pd.read_excel(db_filename,sheet_name, index_col = index_column)
     self.usaved_sol_counter = 0
     self.added_counter = 0
     self.added_items = set()
     self.index_column = index_column
开发者ID:Algomorph,项目名称:moore_scraper,代码行数:32,代码来源:pdexcel.py

示例2: __init__

# 需要导入模块: from pandas.io.excel import ExcelWriter [as 别名]
# 或者: from pandas.io.excel.ExcelWriter import close [as 别名]
 def __init__(self, db_filename = "fbo_solicitations.xlsx",
              report_prefix = "report", 
              sol_sheet_name = "solicitations",
              filtered_sheet_name = "filtered_solicitations",
              index_column = "sponsor_number",
              report_only_new = True):
     '''
     Constructor
     '''
     if(not os.path.isfile(db_filename)):
         #generate a blank writable excel sheet from scratch
         field_names = [field_name for field_name in Opportunity.fields]
         field_names.remove("filtered")
         writer = ExcelWriter(db_filename)
         sol_df = pd.DataFrame(columns = field_names)
         filtered_df = pd.DataFrame(columns = field_names)
         sol_df.to_excel(writer,sol_sheet_name)
         filtered_df.to_excel(writer,filtered_sheet_name)
         writer.save()
         writer.close()
     
     self.report_filename = (report_prefix + "_" 
                             + str(datetime.today())[:19]
                             .replace(":","_").replace(" ","[") + "].xlsx")
     #kept for posterity, in case only the date component is needed and we don't care about overwrites
     #self.report_filename = report_prefix + "_" + str(date.today())
     self.db_filename = db_filename
     self.sol_sheet_name = sol_sheet_name
     self.filtered_sheet_name = filtered_sheet_name
     self.sol_df = pd.read_excel(db_filename,sol_sheet_name, index_col = index_column)
     self.filtered_df = pd.read_excel(db_filename,filtered_sheet_name, index_col = index_column)
     self.usaved_sol_counter = 0
     self.sol_counter = 0
     self.added_items = set()
开发者ID:Algomorph,项目名称:fbo_scraper,代码行数:36,代码来源:pdexcel.py

示例3: save_all

# 需要导入模块: from pandas.io.excel import ExcelWriter [as 别名]
# 或者: from pandas.io.excel.ExcelWriter import close [as 别名]
 def save_all(self):
     '''
     Dumps all solicitations in both databases to an excel file
     '''
     print "\n\n========  Saving {:s}  ========".format(self.sheet_name)
     writer = ExcelWriter(self.db_filename)
     self.dataframe.to_excel(writer,self.sheet_name,merge_cells=False)
     writer.save()
     writer.close()
     print "========  Done saving.  ========\n"
开发者ID:Algomorph,项目名称:moore_scraper,代码行数:12,代码来源:pdexcel.py

示例4: save_all

# 需要导入模块: from pandas.io.excel import ExcelWriter [as 别名]
# 或者: from pandas.io.excel.ExcelWriter import close [as 别名]
 def save_all(self):
     '''
     Dumps all solicitations in both databases to an excel file,
     into two separate spreadsheets: one for filtered items, the other
     for the remaining (relevant) items
     '''
     print "\n\n========  Saving solicitations...  ========"
     writer = ExcelWriter(self.db_filename)
     self.sol_df.to_excel(writer,self.sol_sheet_name,merge_cells=False)
     self.filtered_df.to_excel(writer,self.filtered_sheet_name,merge_cells=False)
     writer.save()
     writer.close()
     print "========  Done saving.  ========\n"
开发者ID:Algomorph,项目名称:fbo_scraper,代码行数:15,代码来源:pdexcel.py

示例5: generate_report

# 需要导入模块: from pandas.io.excel import ExcelWriter [as 别名]
# 或者: from pandas.io.excel.ExcelWriter import close [as 别名]
 def generate_report(self):
     '''
     Generates a separate excel report, consisting of non-award-type notices
     that are not yet overdue
     '''
     print "\n\n========  Generating report...  ========"
     df = self.dataframe.copy()
     ix = pd.Series([(True if ix in self.added_items else False ) 
                                   for ix in df.index ],
                                   index=df.index)
     report_df = df[ix == True]
     
     writer = ExcelWriter(self.report_filename)
     report_df.to_excel(writer,self.sheet_name,merge_cells=False)
     writer.save()
     writer.close()
     
     print "========  Report Generated as " + self.report_filename + " ========\n"
开发者ID:Algomorph,项目名称:moore_scraper,代码行数:20,代码来源:pdexcel.py

示例6: generate_report

# 需要导入模块: from pandas.io.excel import ExcelWriter [as 别名]
# 或者: from pandas.io.excel.ExcelWriter import close [as 别名]
 def generate_report(self):
     '''
     Generates a separate excel report, consisting of non-award-type notices
     that are not yet overdue
     '''
     print "\n\n========  Generating report...  ========"
     today = datetime.today()
     df = self.sol_df.copy()
     df["new"] = pd.Series([(True if ix in self.added_items else False ) 
                                   for ix in df.index ],
                                   index=df.index)
     
     report_df = df[(df["proposal_due_date"] >= today) | (df["proposal_due_date"] == None)]
     
     writer = ExcelWriter(self.report_filename)
     report_df.to_excel(writer,self.sol_sheet_name,merge_cells=False)
     writer.save()
     writer.close()
     
     print "========  Report Generated as " + self.report_filename + " ========\n"
开发者ID:Algomorph,项目名称:nsf_scraper,代码行数:22,代码来源:pdexcel.py

示例7: generate_report

# 需要导入模块: from pandas.io.excel import ExcelWriter [as 别名]
# 或者: from pandas.io.excel.ExcelWriter import close [as 别名]
 def generate_report(self):
     '''
     Generates a separate excel report, consisting of non-award-type notices
     that are not yet overdue
     '''
     print "\n\n========  Generating report...  ========"
     today = datetime.today()
     df = self.sol_df.copy()
     df["new"] = pd.Series([(1 if ix in self.added_items else 0 ) 
                                   for ix in df.index ],
                                   index=df.index)
     df["dd"] = [datetime.strptime(dt, "%m/%d/%Y") for dt in df["deadline_date"].values]
     report_df = df[(df["dd"] >= today) 
                             & (df["announcement_type"] != "Award")]
     
     writer = ExcelWriter(self.report_filename)
     report_df.to_excel(writer,self.sol_sheet_name,merge_cells=False)
     writer.save()
     writer.close()
     
     print "========  Report Generated as " + self.report_filename + " ========\n"
开发者ID:Algomorph,项目名称:fbo_scraper,代码行数:23,代码来源:pdexcel.py

示例8: test_excel_date_datetime_format

# 需要导入模块: from pandas.io.excel import ExcelWriter [as 别名]
# 或者: from pandas.io.excel.ExcelWriter import close [as 别名]
    def test_excel_date_datetime_format(self, engine, ext):
        # see gh-4133
        #
        # Excel output format strings
        df = DataFrame([[date(2014, 1, 31),
                         date(1999, 9, 24)],
                        [datetime(1998, 5, 26, 23, 33, 4),
                         datetime(2014, 2, 28, 13, 5, 13)]],
                       index=["DATE", "DATETIME"], columns=["X", "Y"])
        df_expected = DataFrame([[datetime(2014, 1, 31),
                                  datetime(1999, 9, 24)],
                                 [datetime(1998, 5, 26, 23, 33, 4),
                                  datetime(2014, 2, 28, 13, 5, 13)]],
                                index=["DATE", "DATETIME"], columns=["X", "Y"])

        with ensure_clean(ext) as filename2:
            writer1 = ExcelWriter(self.path)
            writer2 = ExcelWriter(filename2,
                                  date_format="DD.MM.YYYY",
                                  datetime_format="DD.MM.YYYY HH-MM-SS")

            df.to_excel(writer1, "test1")
            df.to_excel(writer2, "test1")

            writer1.close()
            writer2.close()

            reader1 = ExcelFile(self.path)
            reader2 = ExcelFile(filename2)

            rs1 = pd.read_excel(reader1, "test1", index_col=0)
            rs2 = pd.read_excel(reader2, "test1", index_col=0)

            tm.assert_frame_equal(rs1, rs2)

            # Since the reader returns a datetime object for dates,
            # we need to use df_expected to check the result.
            tm.assert_frame_equal(rs2, df_expected)
开发者ID:forking-repos,项目名称:pandas,代码行数:40,代码来源:test_writers.py

示例9: test_excel_date_datetime_format

# 需要导入模块: from pandas.io.excel import ExcelWriter [as 别名]
# 或者: from pandas.io.excel.ExcelWriter import close [as 别名]
    def test_excel_date_datetime_format(self):
        _skip_if_no_xlrd()
        df = DataFrame([[date(2014, 1, 31),
                         date(1999, 9, 24)],
                        [datetime(1998, 5, 26, 23, 33, 4),
                         datetime(2014, 2, 28, 13, 5, 13)]],
                       index=['DATE', 'DATETIME'], columns=['X', 'Y'])
        df_expected = DataFrame([[datetime(2014, 1, 31),
                                  datetime(1999, 9, 24)],
                                 [datetime(1998, 5, 26, 23, 33, 4),
                                  datetime(2014, 2, 28, 13, 5, 13)]],
                                index=['DATE', 'DATETIME'], columns=['X', 'Y'])

        with ensure_clean(self.ext) as filename1:
            with ensure_clean(self.ext) as filename2:
                writer1 = ExcelWriter(filename1)
                writer2 = ExcelWriter(filename2,
                  date_format='DD.MM.YYYY',
                  datetime_format='DD.MM.YYYY HH-MM-SS')

                df.to_excel(writer1, 'test1')
                df.to_excel(writer2, 'test1')

                writer1.close()
                writer2.close()

                reader1 = ExcelFile(filename1)
                reader2 = ExcelFile(filename2)

                rs1 = reader1.parse('test1', index_col=None)
                rs2 = reader2.parse('test1', index_col=None)

                tm.assert_frame_equal(rs1, rs2)

                # since the reader returns a datetime object for dates, we need
                # to use df_expected to check the result
                tm.assert_frame_equal(rs2, df_expected)
开发者ID:5i7788,项目名称:pandas,代码行数:39,代码来源:test_excel.py

示例10: __init__

# 需要导入模块: from pandas.io.excel import ExcelWriter [as 别名]
# 或者: from pandas.io.excel.ExcelWriter import close [as 别名]
    def __init__(self, db_filename = "nsf_solicitations.xlsx",
                 report_prefix = "report", 
                 sol_sheet_name = "solicitations",
                 filtered_sheet_name = "filtered_solicitations",
                 index_column = "pims_id"):
        '''
        Constructor
        '''
        if(not os.path.isfile(db_filename)):
            #generate a blank writable excel sheet from scratch
            field_names = [field_name for field_name in NsfSolicitation.fields]
            field_names.remove("filtered")
            writer = ExcelWriter(db_filename)
            sol_df = pd.DataFrame(columns = field_names)
            filtered_df = pd.DataFrame(columns = field_names)
            sol_df.to_excel(writer,sol_sheet_name)
            filtered_df.to_excel(writer,filtered_sheet_name)
            writer.save()
            writer.close()
        
        self.report_filename = (report_prefix + "_" 
                                + str(datetime.today())[:19]
                                .replace(":","_").replace(" ","[") + "].xlsx")

        self.db_filename = db_filename
        self.sol_sheet_name = sol_sheet_name
        self.filtered_sheet_name = filtered_sheet_name
        self.sol_df = pd.read_excel(db_filename,sol_sheet_name, index_col = index_column)
        self.filtered_df = pd.read_excel(db_filename,filtered_sheet_name, index_col = index_column)
        self.usaved_sol_counter = 0
        self.sol_counter = 0
        self.added_items = set()
        self.solicitation_numbers = set()
        for sn in self.sol_df["solicitation_number"].values:
            self.solicitation_numbers.add(sn)
        self.index_column = index_column
开发者ID:Algomorph,项目名称:nsf_scraper,代码行数:38,代码来源:pdexcel.py


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