• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python pyvttbl.DataFrame类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pyvttbl.DataFrame的典型用法代码示例。如果您正苦于以下问题:Python DataFrame类的具体用法?Python DataFrame怎么用?Python DataFrame使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: test01

 def test01(self):
     """repr test"""
     R = Descriptives([('count', 100.0),
                       ('mean', 11.61),
                       ('mode', 11.0),
                       ('var', 26.947373737373752),
                       ('stdev', 5.191085988246944),
                       ('sem', 0.5191085988246944),
                       ('rms', 12.707084638106414),
                       ('min', 3.0),
                       ('Q1', 7.0),
                       ('median', 11.0),
                       ('Q3', 15.5),
                       ('max', 23.0),
                       ('range', 20.0),
                       ('95ci_lower', 10.592547146303598),
                       ('95ci_upper', 12.6274528536964)],
                      cname='WORDS')
     
     df = DataFrame()
     df.read_tbl('data/words~ageXcondition.csv')
     D = eval(repr(df.descriptives('WORDS')))
     
     for k in D.keys():
         self.failUnlessAlmostEqual(D[k],R[k])
开发者ID:marsja,项目名称:pyvttbl,代码行数:25,代码来源:test_stats_descriptives.py


示例2: test11

    def test11(self):
        df = DataFrame()
        df.read_tbl('data/error~subjectXtimeofdayXcourseXmodel_MISSING.csv')

        D = str(df.descriptives('ERROR'))
        R = """\
Descriptive Statistics
  ERROR
==========================
 count        48.000 
 mean          3.896 
 mode          3.000 
 var           5.797 
 stdev         2.408 
 sem           0.348 
 rms           4.567 
 min           0.000 
 Q1            2.000 
 median        3.000 
 Q3            5.000 
 max          10.000 
 range        10.000 
 95ci_lower    3.215 
 95ci_upper    4.577 """
        self.assertEqual(D, R)
开发者ID:marsja,项目名称:pyvttbl,代码行数:25,代码来源:test_stats_descriptives.py


示例3: test6

 def test6(self):
     R = DataFrame([('SUBJECT', [1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3]), ('TIMEOFDAY', [u'T1', u'T1', u'T1', u'T2', u'T2', u'T2', u'T2', u'T2', u'T2', u'T1', u'T1', u'T1', u'T2', u'T2', u'T2']), ('COURSE', [u'C1', u'C1', u'C1', u'C1', u'C1', u'C1', u'C1', u'C1', u'C1', u'C1', u'C1', u'C1', u'C1', u'C1', u'C1']), ('MODEL', [u'M1', u'M2', u'M3', u'M1', u'M2', u'M3', u'M1', u'M2', u'M3', u'M1', u'M2', u'M3', u'M1', u'M2', u'M3']), ('ERROR', [10, 8, 6, 5, 4, 3, 4, 3, 3, 8, 7, 4, 4, 1, 2])])
     
     df=DataFrame()
     df.read_tbl('data/error~subjectXtimeofdayXcourseXmodel_MISSING.csv')
     df2 = df.where([('COURSE','=',['C1']),('TIMEOFDAY','in',["T1", "T2"])])
     self.assertEqual(repr(df2),repr(R))
开发者ID:marsja,项目名称:pyvttbl,代码行数:7,代码来源:test_df_where.py


示例4: export_csv_pivot

def export_csv_pivot(request, entidad=1, ano=str(date.today().year)):

    consumos = Consumo.objects.filter(entidad__pk=entidad, ano=ano)
    
    from collections import namedtuple
    LineaDetalle = namedtuple('LineaDetalle',[u'Año', "Mes", 'Local_o_Vehiculo', "Consumo", "Valor"])

    df = DataFrame()    
    
    for c in consumos:

        if c.content_type.id == 16:
            denominacion = Local.objects.get(pk=c.object_id).denominacion
        else:
            denominacion = Vehiculo.objects.get(pk=c.object_id).denominacion

        df.insert(LineaDetalle(c.ano, c.mes, denominacion.encode("utf-8"), c.medida.denominacion.encode("utf-8"), c.valor)._asdict())

    pt = df.pivot("Valor", ['Local_o_Vehiculo','Consumo'], ['Mes'])

    # get the response object, this can be used as a stream.
    response = HttpResponse(mimetype='text/csv')
    # force download.
    response['Content-Disposition'] = 'attachment;filename=export.csv'

    response.write(pt)

    return response
开发者ID:alabarga,项目名称:calculadoraCO2,代码行数:28,代码来源:views.py


示例5: test1

    def test1(self):
        R = Descriptives([('count', 48.0),
                          ('mean', 3.8958333333333335),
                          ('mode', 3.0),
                          ('var', 5.797429078014184),
                          ('stdev', 2.4077850979716158),
                          ('sem', 0.34753384361617046),
                          ('rms', 4.566636252940086),
                          ('min', 0.0),
                          ('Q1', 2.0),
                          ('median', 3.0),
                          ('Q3', 5.0),
                          ('max', 10.0),
                          ('range', 10.0),
                          ('95ci_lower', 3.2146669998456394),
                          ('95ci_upper', 4.5769996668210275)],
                         cname='ERROR')
        
        df=DataFrame()
        df.read_tbl('data/error~subjectXtimeofdayXcourseXmodel_MISSING.csv')

        D=df.descriptives('ERROR')
        
        for k in D.keys():
            self.failUnlessAlmostEqual(D[k],R[k])
开发者ID:marsja,项目名称:pyvttbl,代码行数:25,代码来源:test_stats_descriptives.py


示例6: test1

    def test1(self):
        R="""\
t-Test: One Sample for means

                          SUPPRESSION 
=====================================
Sample Mean                    19.541 
Hypothesized Pop. Mean             17 
Variance                      228.326 
Observations                      384 
df                                383 
t Stat                          3.295 
alpha                           0.050 
P(T<=t) one-tail            5.384e-04 
t Critical one-tail             1.966 
P(T<=t) two-tail                0.001 
t Critical two-tail             1.649 
P(T<=t) two-tail                0.001 
Effect size d                   0.168 
delta                           3.295 
Observed power one-tail         0.950 
Observed power two-tail         0.908 """
        
        df = DataFrame()
        df.read_tbl('data/suppression~subjectXgroupXageXcycleXphase.csv')
        D=df.ttest('SUPPRESSION', pop_mean=17.)
        self.assertEqual(str(D),R)
开发者ID:marsja,项目名称:pyvttbl,代码行数:27,代码来源:test_stats_ttest_1sample.py


示例7: test1

    def test1(self):
        R = {'d': [np.array([ 9,  8,  6,  8, 10,  4,  6,  5,  7,  7,
                              7,  9,  6,  6,  6, 11,  6,  3,  8,  7,
                              11, 13,  8,  6, 14, 11, 13, 13, 10, 11,
                              12, 11, 16, 11,  9, 23, 12, 10, 19, 11,
                              10, 19, 14,  5, 10, 11, 14, 15, 11, 11]),
                   np.array([ 8,  6,  4,  6,  7,  6,  5,  7,  9,  7,
                              10,  7,  8, 10,  4,  7, 10, 6,  7,  7,
                              14, 11, 18, 14, 13, 22, 17, 16, 12, 11,
                              20, 16, 16, 15, 18, 16, 20, 22, 14, 19,
                              21, 19, 17, 15, 22, 16, 22, 22, 18, 21])],
             'fname': 'output\\box(WORDS~AGE).png',
             'maintitle': 'WORDS by AGE',
             'xlabels': [u'AGE = old', u'AGE = young']}
        
        df=DataFrame()
        df.TESTMODE=True
        df.read_tbl('data/words~ageXcondition.csv')
        D=df.box_plot('WORDS',['AGE'], output_dir='output')

        self.assertEqual(D['fname'],R['fname'])
        self.assertEqual(D['maintitle'],R['maintitle'])
        self.assertEqual(D['xlabels'],R['xlabels'])
        
        for d,r in zip(np.array(D['d']).flat,
                       np.array(R['d']).flat):
            self.assertAlmostEqual(d,r)
开发者ID:marsja,项目名称:pyvttbl,代码行数:27,代码来源:test_plotting_box_plot.py


示例8: test0

 def test0(self):
     R = {'d': [9.0, 8.0, 6.0, 8.0, 10.0, 4.0, 6.0, 5.0, 7.0, 7.0,
                7.0, 9.0, 6.0, 6.0, 6.0, 11.0, 6.0, 3.0, 8.0, 7.0,
                11.0, 13.0, 8.0, 6.0, 14.0, 11.0, 13.0, 13.0, 10.0,
                11.0, 12.0, 11.0, 16.0, 11.0, 9.0, 23.0, 12.0, 10.0,
                19.0, 11.0, 10.0, 19.0, 14.0, 5.0, 10.0, 11.0, 14.0,
                15.0, 11.0, 11.0, 8.0, 6.0, 4.0, 6.0, 7.0, 6.0, 5.0,
                7.0, 9.0, 7.0, 10.0, 7.0, 8.0, 10.0, 4.0, 7.0, 10.0,
                6.0, 7.0, 7.0, 14.0, 11.0, 18.0, 14.0, 13.0, 22.0, 17.0,
                16.0, 12.0, 11.0, 20.0, 16.0, 16.0, 15.0, 18.0, 16.0,
                20.0, 22.0, 14.0, 19.0, 21.0, 19.0, 17.0, 15.0, 22.0,
                16.0, 22.0, 22.0, 18.0, 21.0],
          'fname': 'output\\box(WORDS).png',
          'maintitle': 'WORDS',
          'val': 'WORDS'}
     
     df=DataFrame()
     df.TESTMODE=True
     df.read_tbl('data/words~ageXcondition.csv')
     D=df.box_plot('WORDS', output_dir='output')
     
     self.assertEqual(D['fname'],R['fname'])
     self.assertEqual(D['maintitle'],R['maintitle'])
     self.assertEqual(D['val'],R['val'])
     
     for d,r in zip(np.array(D['d']).flat,
                    np.array(R['d']).flat):
         self.assertAlmostEqual(d,r)        
开发者ID:marsja,项目名称:pyvttbl,代码行数:28,代码来源:test_plotting_box_plot.py


示例9: test2

    def test2(self):
        R="""\
Chi-Square: Single Factor

SUMMARY
             1        2        3        4        5    
=====================================================
Observed        7       20       23        9        0 
Expected   11.800   11.800   11.800   11.800   11.800 

CHI-SQUARE TESTS
                     Value    df       P     
============================================
Pearson Chi-Square   30.746    4   3.450e-06 
Likelihood Ratio         --   --          -- 
Observations             59                  

POST-HOC POWER
       Measure                 
==============================
Effect size w            0.722 
Non-centrality lambda   30.746 
Critical Chi-Square      9.488 
Power                    0.998 """

        df = DataFrame()
        df.read_tbl('data/chi_test.csv')
        X=df.chisquare1way('RESULT',{1:11.8 ,2:11.8 ,3:11.8 ,4:11.8 ,5:11.8})
        
        self.assertEqual(str(X),R)
开发者ID:marsja,项目名称:pyvttbl,代码行数:30,代码来源:test_stats_chisquare1way.py


示例10: test2

 def test2(self):
     R = DataFrame([('SUBJECT', [1, 2]), ('TIMEOFDAY', [u'T1', u'T1']), ('COURSE', [u'C1', u'C2']), ('MODEL', [u'M1', u'M1']), ('ERROR', [10, 10])])
     
     df=DataFrame()
     df.read_tbl('data/error~subjectXtimeofdayXcourseXmodel_MISSING.csv')
     df2 = df.where([('ERROR', '=', 10)])
     self.assertEqual(repr(df2),repr(df2))
开发者ID:marsja,项目名称:pyvttbl,代码行数:7,代码来源:test_df_where.py


示例11: test02

    def test02(self):
        df=DataFrame()
        df.read_tbl('data/words~ageXcondition.csv')
        D = repr(df.histogram('WORDS'))
        R = "Histogram([('values', [4.0, 14.0, 17.0, 12.0, 15.0, 10.0, 9.0, 5.0, 6.0, 8.0]), \
('bin_edges', [3, 5.0, 7.0, 9.0, 11.0, 13.0, 15.0, 17.0, 19.0, 21.0, 23])], cname='WORDS')"
        self.assertEqual(D, R)
开发者ID:marsja,项目名称:pyvttbl,代码行数:7,代码来源:test_stats_histogram.py


示例12: test1

    def test1(self):
        R="""\
Chi-Square: Single Factor

SUMMARY
             1        2        3        4    
============================================
Observed        7       20       23        9 
Expected   14.750   14.750   14.750   14.750 

CHI-SQUARE TESTS
                     Value    df     P   
========================================
Pearson Chi-Square   12.797    3   0.005 
Likelihood Ratio     13.288    3   0.004 
Observations             59              

POST-HOC POWER
       Measure                 
==============================
Effect size w            0.466 
Non-centrality lambda   12.797 
Critical Chi-Square      7.815 
Power                    0.865 """

        df = DataFrame()
        df.read_tbl('data/chi_test.csv')
        X=df.chisquare1way('RESULT')
        self.assertEqual(str(X),R)
开发者ID:marsja,项目名称:pyvttbl,代码行数:29,代码来源:test_stats_chisquare1way.py


示例13: test2

    def test2(self):
        
        df=DataFrame()
        df.read_tbl('data/error~subjectXtimeofdayXcourseXmodel_MISSING.csv')
        pt = df.pivot('ERROR', ['MODEL','TIMEOFDAY'],['COURSE'],where=['SUBJECT != 1'])

        self.assertEqual(repr(eval(repr(pt))), repr(pt))
开发者ID:marsja,项目名称:pyvttbl,代码行数:7,代码来源:test_pt__repr__.py


示例14: test1

    def test1(self):
        R="""Bivariate Correlations

                         A           B           C
======================================================
A   spearman                 1       0.958      -0.924
    Sig (2-tailed)           .   9.699e-12   2.259e-09
    N                       21          21          21
------------------------------------------------------
B   spearman             0.958           1      -0.890
    Sig (2-tailed)   9.699e-12           .       0.000
    N                       21          21          21
------------------------------------------------------
C   spearman            -0.924      -0.890           1
    Sig (2-tailed)   2.259e-09       0.000           .
    N                       21          21          21

Larzelere and Mulaik Significance Testing

 Pair     i   Correlation       P       alpha/(k-i+1)   Sig.
============================================================
A vs. B   1         0.958   9.699e-12           0.017   **
A vs. C   2         0.924   2.259e-09           0.025   **
B vs. C   3         0.890   6.850e-08           0.050   **   """
        df=DataFrame()
        df['A']=[24,61,59,46,43,44,52,43,58,67,62,57,71,49,54,43,53,57,49,56,33]
        df['B']=[42.93472681237495, 78.87307334936268, 75.37292628918023, 65.49076317291956, 55.55965179772366, 56.777730638998236, 62.19451880792437, 54.73710611356715, 72.10021832823149, 85.94377749485642, 78.2087578930983, 72.01681829338037, 84.27889316830063, 60.20516982367225, 65.6276497088971, 62.36549856901088, 69.18772114281175, 67.00548667483324, 59.042687027269466, 71.99214593063917, 45.00831155783992]
        df['C']=[-53.05540625388731, -96.33996451998567, -92.32465861908086, -70.90536432779966, -55.953777697739255, -74.12814626217357, -75.89188834814621, -64.24093256012688, -89.62208010083313, -87.41075066046812, -80.40932820298143, -77.99906284144805, -95.31607277596169, -61.672429800914486, -85.26088499198657, -63.4402296673869, -74.84950736563589, -85.00433219746624, -71.5901436929124, -76.43243666219388, -48.01082320924727]

        cor=df.correlation(['A','B','C'],coefficient='spearman')
        self.assertEqual(str(cor),R)
开发者ID:flavour,项目名称:cert,代码行数:31,代码来源:test_stats.py


示例15: test2

 def test2(self):
     ## Between-Subjects test
     df=DataFrame()
     fname='words~ageXcondition.csv'
     df.read_tbl(fname)
     aov=Anova()
     aov.run(df,'WORDS',bfactors=['AGE','CONDITION'])
开发者ID:flavour,项目名称:cert,代码行数:7,代码来源:test_stats.py


示例16: test0

 def test0(self):
     
     df=DataFrame()
     df.read_tbl('data/error~subjectXtimeofdayXcourseXmodel_MISSING.csv')
     pt = df.pivot('ERROR', ['TIMEOFDAY'],['COURSE'])
 
     self.assertAlmostEqual(3.22222222222,pt[1,0],5)
开发者ID:marsja,项目名称:pyvttbl,代码行数:7,代码来源:test_pt__getitem__.py


示例17: test_kn

 def test_kn(self):
     df = DataFrame()
     df.read_tbl('data/example.csv')
     y = [23]*len(df['X'])
     df['X'] = y
     
     self.assertEqual(df.keys(), ['CASE', 'TIME', 'CONDITION', 'X'])
开发者ID:marsja,项目名称:pyvttbl,代码行数:7,代码来源:test_df__setitem__.py


示例18: test01

    def test01(self):
        df=DataFrame()
        df.TESTMODE = True
        df.read_tbl('data/iqbrainsize.txt', delimiter='\t')
        D = df.scatter_plot('TOTVOL','FIQ',
                        output_dir='output')

        self.assertEqual(None, D['trend'])
开发者ID:marsja,项目名称:pyvttbl,代码行数:8,代码来源:test_plotting_scatter_plot.py


示例19: test3

 def test3(self):
     ## Mixed Between/Within test
     df=DataFrame()
     fname='suppression~subjectXgroupXcycleXphase.csv'
     df.read_tbl(fname)
     df['SUPPRESSION']=[.01*x for x in df['SUPPRESSION']]
     aov=Anova()
     aov.run(df,'SUPPRESSION',wfactors=['CYCLE','PHASE'],bfactors=['GROUP'])#,transform='win
开发者ID:flavour,项目名称:cert,代码行数:8,代码来源:test_stats.py


示例20: test3

    def test3(self):
        df=DataFrame()
  
        with self.assertRaises(Exception) as cm:
            df.box_plot('a', output_dir='output')

        self.assertEqual(str(cm.exception),
                         'Table must have data to print data')
开发者ID:marsja,项目名称:pyvttbl,代码行数:8,代码来源:test_plotting_box_plot.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python pywapi.get_weather_from_google函数代码示例发布时间:2022-05-27
下一篇:
Python query.votableparse函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap