import json
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
if __name__=="__main__":
    path="usagov_bitly_data2012-03-16-1331923249.txt"
    fp=open(path)
    records=[json.loads(line) for line in fp.readlines()]
    print(len(records))
    frame=pd.DataFrame(records)
    print(frame['tz'])
    clean_tz=frame['tz'].fillna('Missing')
    clean_tz[clean_tz=='']='Unknown'
    tz_counts=clean_tz.value_counts()
    print(tz_counts[:20])
    tz_counts[:10].plot(kind='barh',rot=0)
    plt.show()

简单的入门1

相关文章:

  • 2021-12-22
  • 2021-09-28
  • 2021-11-28
  • 2022-12-23
  • 2022-01-22
  • 2022-12-23
猜你喜欢
  • 2021-12-19
  • 2021-04-01
  • 2022-12-23
  • 2022-12-23
  • 2021-07-19
  • 2022-01-27
相关资源
相似解决方案