• python pylab出图


    from pandas import DataFrame,Series
    import pandas as pd
    import numpy as np
    import sys
    import matplotlib.pyplot as plt
    reload(sys)
    sys.setdefaultencoding('utf8')
    import json
    import time
    path='E:ch02usagov_bitly_data2012-03-16-1331923249.txt'
    a= open(path).readlines()
    # print a
    print type(a)
    arr01=[]
    for x in a:
        #print x
        # print type(x)
        y=json.loads(x)
        #print y
        # time.sleep(100)
        for z in y:
          arr01.append(y[z])
        print '--------------------------------'
    print arr01
    records=[json.loads(line)  for line in open(path)]
    print records
    
    frame=DataFrame(records)
    print frame
    print frame['tz'][:10]
    print frame['tz'].value_counts()[:10]
    clean_tz=frame['tz'].fillna('Missing')
    clean_tz[clean_tz == ''] ='Unknown'
    print '-----------------------------------------'
    print clean_tz.value_counts()[:10]
    print clean_tz.value_counts()[:10].plot(kind='barh',rot=0)
    print plt.show()
  • 相关阅读:
    python module introduce
    python代码基
    20100911部署更新
    汉王ocr
    wsgi
    css布局模板
    Making a simple web server in Python.
    20100910更新部署
    tw.forms usage
    python web shell
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13348736.html
Copyright © 2020-2023  润新知