最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

利用python實(shí)現(xiàn)數(shù)據(jù)分析

 更新時(shí)間:2017年01月11日 08:44:00   作者:米油  
為什么要利用python進(jìn)行數(shù)據(jù)分析?python擁有一個(gè)巨大的活躍的科學(xué)計(jì)算社區(qū),擁有不斷改良的庫(kù),能夠輕松的集成C,C++,Fortran代碼(Cython項(xiàng)目),可以同時(shí)用于研究和原型的構(gòu)建以及生產(chǎn)系統(tǒng)的構(gòu)建。

1:文件內(nèi)容格式為json的數(shù)據(jù)如何解析

import json,os,sys
current_dir=os.path.abspath(".")

filename=[file for file in os.listdir(current_dir) if ".txt" in file]#得到當(dāng)前目錄中,后綴為.txt的數(shù)據(jù)文件
fn=filename[0] if len(filename)==1 else "" #從list中取出第一個(gè)文件名

if fn: # means we got a valid filename
  fd=open(fn)
  content=[json.loads(line) for line in fd]
  
else:
  print("no txt file in current directory")
  sys.exit(1)
for linedict in content:
  for key,value in linedict.items():
    print(key,value)
  print("\n")

2:出現(xiàn)頻率統(tǒng)計(jì)

import random
from collections import Counter
fruits=[random.choice(["apple","cherry","orange","pear","watermelon","banana"]) for i in range(20)]
print(fruits) #查看所有水果出現(xiàn)的次數(shù)

cover_fruits=Counter(fruits)
for fruit,times in cover_fruits.most_common(3):
  print(fruit,times)

########運(yùn)行結(jié)果如下:apple在fruits里出了5次
apple 5  
banana 4
pear 4

3:重新加載module的方法py3

import importlib
import.reload(modulename)

4:pylab中包含了哪些module

   from pylab import *

等效于下面的導(dǎo)入語(yǔ)句:

  from pylab import *
  from numpy import *
  from scipy import *
  import matplotlib

相關(guān)文章

  • Windows 安裝 Anaconda3+PyCharm的方法步驟

    Windows 安裝 Anaconda3+PyCharm的方法步驟

    這篇文章主要介紹了Windows 安裝 Anaconda3+PyCharm的方法步驟,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2019-06-06
  • python?scatter繪制散點(diǎn)圖

    python?scatter繪制散點(diǎn)圖

    這篇文章主要介紹了python?scatter繪制散點(diǎn)圖,文章圍繞主題展開(kāi)詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的小伙伴可以參考一下
    2022-06-06
  • Python同時(shí)迭代多個(gè)序列的方法

    Python同時(shí)迭代多個(gè)序列的方法

    這篇文章主要介紹了Python同時(shí)迭代多個(gè)序列的方法,文中講解非常細(xì)致,代碼幫助大家更好的理解和學(xué)習(xí),感興趣的朋友可以了解下
    2020-07-07
  • Web服務(wù)器框架 Tornado簡(jiǎn)介

    Web服務(wù)器框架 Tornado簡(jiǎn)介

    Tornado Web Server 是使用Python編寫(xiě)出來(lái)的一個(gè)極輕量級(jí)、高可伸縮性和非阻塞IO的Web服務(wù)器軟件,著名的 Friendfeed 網(wǎng)站就是使用它搭建的。
    2014-07-07
  • 最新評(píng)論

    莱西市| 孟州市| 双牌县| 南城县| 偃师市| 通许县| 丹寨县| 瑞丽市| 新晃| 秦安县| 新郑市| 深州市| 辽阳县| 凌源市| 汾西县| 瑞安市| 呼和浩特市| 道孚县| 博乐市| 潍坊市| 宝山区| 靖江市| 望都县| 阿拉善盟| 宜宾市| 九龙县| 于都县| 蓬莱市| 开原市| 天柱县| 乌拉特中旗| 磴口县| 云安县| 睢宁县| 广灵县| 容城县| 博爱县| 通州区| 安义县| 宜川县| 保康县|