當前位置: 首頁>>代碼示例>>Python>>正文


Python SimpleTable.as_text方法代碼示例

本文整理匯總了Python中statsmodels.iolib.table.SimpleTable.as_text方法的典型用法代碼示例。如果您正苦於以下問題:Python SimpleTable.as_text方法的具體用法?Python SimpleTable.as_text怎麽用?Python SimpleTable.as_text使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在statsmodels.iolib.table.SimpleTable的用法示例。


在下文中一共展示了SimpleTable.as_text方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_simple_table_3

# 需要導入模塊: from statsmodels.iolib.table import SimpleTable [as 別名]
# 或者: from statsmodels.iolib.table.SimpleTable import as_text [as 別名]
    def test_simple_table_3(self):
        # Test SimpleTable.extend() as in extend down
        desired = '''
==============================
           header s1 header d1
------------------------------
stub R1 C1  10.30312  10.73999
stub R2 C1  90.30312  90.73999
           header s2 header d2
------------------------------
stub R1 C2  50.95038  50.65765
stub R2 C2  40.95038  40.65765
------------------------------
'''
        data1 = [[10.30312, 10.73999], [90.30312, 90.73999]]
        data2 = [[50.95038, 50.65765], [40.95038, 40.65765]]
        stubs1 = ['stub R1 C1', 'stub R2 C1']
        stubs2 = ['stub R1 C2', 'stub R2 C2']
        header1 = ['header s1', 'header d1']
        header2 = ['header s2', 'header d2']
        actual1 = SimpleTable(data1, header1, stubs1, txt_fmt=default_txt_fmt)
        actual2 = SimpleTable(data2, header2, stubs2, txt_fmt=default_txt_fmt)
        actual1.extend(actual2)
        actual = '\n%s\n' % actual1.as_text()
        assert_equal(desired, str(actual))
開發者ID:statsmodels,項目名稱:statsmodels,代碼行數:27,代碼來源:test_table.py

示例2: test_customlabel

# 需要導入模塊: from statsmodels.iolib.table import SimpleTable [as 別名]
# 或者: from statsmodels.iolib.table.SimpleTable import as_text [as 別名]
    def test_customlabel(self):
        # Limited test of custom custom labeling
        tbl = SimpleTable(table1data, test1header, test1stubs, txt_fmt=txt_fmt1)
        tbl[1][1].data = np.nan
        tbl.label_cells(custom_labeller)
        #print([[c.datatype for c in row] for row in tbl])
        desired = """
*****************************
*       * header1 * header2 *
*****************************
* stub1 *    --   *       1 *
* stub2 *    2.00 *       3 *
*****************************
"""
        actual = '\n%s\n' % tbl.as_text(missing='--')
        assert_equal(actual, desired)
開發者ID:cong1989,項目名稱:statsmodels,代碼行數:18,代碼來源:test_table_econpy.py

示例3: test_simple_table_1

# 需要導入模塊: from statsmodels.iolib.table import SimpleTable [as 別名]
# 或者: from statsmodels.iolib.table.SimpleTable import as_text [as 別名]
    def test_simple_table_1(self):
        # Basic test, test_simple_table_1
        desired = '''
=====================
      header1 header2
---------------------
stub1 1.30312 2.73999
stub2 1.95038 2.65765
---------------------
'''
        test1data = [[1.30312, 2.73999],[1.95038, 2.65765]]
        test1stubs = ('stub1', 'stub2')
        test1header = ('header1', 'header2')
        actual = SimpleTable(test1data, test1header, test1stubs,
                             txt_fmt=default_txt_fmt)
        actual = '\n%s\n' % actual.as_text()
        assert_equal(desired, str(actual))
開發者ID:statsmodels,項目名稱:statsmodels,代碼行數:19,代碼來源:test_table.py


注:本文中的statsmodels.iolib.table.SimpleTable.as_text方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。