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


Python BytesIO.seek方法代码示例

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


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

示例1: packers_write_excel_xlwt

# 需要导入模块: from pandas.compat import BytesIO [as 别名]
# 或者: from pandas.compat.BytesIO import seek [as 别名]
class packers_write_excel_xlwt(object):
    goal_time = 0.2

    def setup(self):
        self.f = '__test__.msg'
        self.N = 100000
        self.C = 5
        self.index = date_range('20000101', periods=self.N, freq='H')
        self.df = DataFrame(dict([('float{0}'.format(i), randn(self.N)) for i in range(self.C)]), index=self.index)
        self.N = 100000
        self.C = 5
        self.index = date_range('20000101', periods=self.N, freq='H')
        self.df2 = DataFrame(dict([('float{0}'.format(i), randn(self.N)) for i in range(self.C)]), index=self.index)
        self.df2['object'] = [('%08x' % randrange((16 ** 8))) for _ in range(self.N)]
        self.remove(self.f)
        self.bio = BytesIO()

    def time_packers_write_excel_xlwt(self):
        self.bio.seek(0)
        self.writer = pd.io.excel.ExcelWriter(self.bio, engine='xlwt')
        self.df[:2000].to_excel(self.writer)
        self.writer.save()

    def remove(self, f):
        try:
            os.remove(self.f)
        except:
            pass
开发者ID:Tux1,项目名称:pandas,代码行数:30,代码来源:packers.py

示例2: Excel

# 需要导入模块: from pandas.compat import BytesIO [as 别名]
# 或者: from pandas.compat.BytesIO import seek [as 别名]
class Excel(object):

    goal_time = 0.2
    params = ['openpyxl', 'xlsxwriter', 'xlwt']
    param_names = ['engine']

    def setup(self, engine):
        N = 2000
        C = 5
        self.df = DataFrame(np.random.randn(N, C),
                            columns=['float{}'.format(i) for i in range(C)],
                            index=date_range('20000101', periods=N, freq='H'))
        self.df['object'] = tm.makeStringIndex(N)
        self.bio_read = BytesIO()
        self.writer_read = ExcelWriter(self.bio_read, engine=engine)
        self.df.to_excel(self.writer_read, sheet_name='Sheet1')
        self.writer_read.save()
        self.bio_read.seek(0)

        self.bio_write = BytesIO()
        self.bio_write.seek(0)
        self.writer_write = ExcelWriter(self.bio_write, engine=engine)

    def time_read_excel(self, engine):
        read_excel(self.bio_read)

    def time_write_excel(self, engine):
        self.df.to_excel(self.writer_write, sheet_name='Sheet1')
        self.writer_write.save()
开发者ID:cpcloud,项目名称:pandas,代码行数:31,代码来源:excel.py

示例3: packers_read_excel

# 需要导入模块: from pandas.compat import BytesIO [as 别名]
# 或者: from pandas.compat.BytesIO import seek [as 别名]
class packers_read_excel(_Packers):

    def setup(self):
        self._setup()
        self.bio = BytesIO()
        self.writer = pd.io.excel.ExcelWriter(self.bio, engine='xlsxwriter')
        self.df[:2000].to_excel(self.writer)
        self.writer.save()

    def time_packers_read_excel(self):
        self.bio.seek(0)
        pd.read_excel(self.bio)
开发者ID:Xbar,项目名称:pandas,代码行数:14,代码来源:packers.py

示例4: test_stringio_writer

# 需要导入模块: from pandas.compat import BytesIO [as 别名]
# 或者: from pandas.compat.BytesIO import seek [as 别名]
 def test_stringio_writer(self):
     _skip_if_no_xlsxwriter()
     _skip_if_no_xlrd()
     
     path = BytesIO()
     with ExcelWriter(path, engine='xlsxwriter', **{'options': {'in-memory': True}}) as ew:
         self.frame.to_excel(ew, 'test1', engine='xlsxwriter')
         ew.save()
         path.seek(0)
         ef = ExcelFile(path)
         found_df = ef.parse('test1')
         tm.assert_frame_equal(self.frame, found_df)
     path.close()
开发者ID:fennnec,项目名称:pandas,代码行数:15,代码来源:test_excel.py

示例5: Excel

# 需要导入模块: from pandas.compat import BytesIO [as 别名]
# 或者: from pandas.compat.BytesIO import seek [as 别名]
class Excel(_Packers):

    def setup(self):
        self._setup()
        self.bio = BytesIO()

    def time_write_excel_openpyxl(self):
        self.bio.seek(0)
        self.writer = pd.io.excel.ExcelWriter(self.bio, engine='openpyxl')
        self.df[:2000].to_excel(self.writer)
        self.writer.save()

    def time_write_excel_xlsxwriter(self):
        self.bio.seek(0)
        self.writer = pd.io.excel.ExcelWriter(self.bio, engine='xlsxwriter')
        self.df[:2000].to_excel(self.writer)
        self.writer.save()

    def time_write_excel_xlwt(self):
        self.bio.seek(0)
        self.writer = pd.io.excel.ExcelWriter(self.bio, engine='xlwt')
        self.df[:2000].to_excel(self.writer)
        self.writer.save()
开发者ID:AlexisMignon,项目名称:pandas,代码行数:25,代码来源:packers.py

示例6: time_write_excel

# 需要导入模块: from pandas.compat import BytesIO [as 别名]
# 或者: from pandas.compat.BytesIO import seek [as 别名]
 def time_write_excel(self, engine):
     bio_write = BytesIO()
     bio_write.seek(0)
     writer_write = ExcelWriter(bio_write, engine=engine)
     self.df.to_excel(writer_write, sheet_name='Sheet1')
     writer_write.save()
开发者ID:bkandel,项目名称:pandas,代码行数:8,代码来源:excel.py


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