1. 程式人生 > 其它 >Task1:論文資料統計(待續...)

Task1:論文資料統計(待續...)

技術標籤:taskpython

Task1:論文資料統計(待續...)

一、 小白的吐槽

  1. 沒有任何計算機專業基礎,程式碼看不懂;(選擇先不理解)
  2. 沒有Python專業,分不清楚Anaconda和pandas;(隊友解釋很給力)
    隊友解釋很給力
    安裝連線:https://blog.csdn.net/weixin_37766087/article/details/100742198
    視訊教程:
  3. 英語基礎差,太坑自己了;
  4. 資料下載,官網的下載速度很慢。(清華大學開源軟體映象站給力)
    https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/?C=N&O=D

二、 實際操作

1.匯入所需包

import seaborn as sns           #用於畫圖
from bs4 import BeautifulSoup   #用於爬取arxiv的資料
import re                       #用於正則表示式,匹配字串的模式
import requests                 #用於網路連線,傳送網路請求,使用域名獲取對應資訊
import json                     #讀取資料,我們的資料為json格式的
import pandas as pd             #資料處理,資料分析
import matplotlib.
pyplot as plt #畫圖工具 data = [] #初始化 #使用with語句優勢:1.自動關閉檔案控制代碼;2.自動顯示(處理)檔案讀取資料異常 with open(r'E:\04\arxiv-metadata-oai-snapshot.json', 'r') as f: for idx, line in enumerate(f): # 讀取前50000行,如果讀取所有資料需要8G記憶體 if idx >= 50000: break
data.append(json.loads(line)) data = pd.DataFrame(data) #將list變為dataframe格式,方便使用pandas進行分析 data.shape #顯示資料大小
(50000, 14)

2.讀入資料並檢視資料大小

     

3.顯示資料的前五行

     

4.進行資料預處理

      

5.檢視所有論文的種類

   # 所有的種類(獨立的)
unique_categories = set([i for l in [x.split(' ') for x in data["categories"]] for i in l])
print(len(unique_categories))
unique_categories   
     146
{'astro-ph',
 'astro-ph.CO',
 'astro-ph.EP',
 'astro-ph.GA',
 'astro-ph.HE',
 'astro-ph.IM',
 'astro-ph.SR',
 'cond-mat.dis-nn',
 'cond-mat.mes-hall',
 'cond-mat.mtrl-sci',
 'cond-mat.other',
 'cond-mat.quant-gas',
 'cond-mat.soft',
 'cond-mat.stat-mech',
 'cond-mat.str-el',
 'cond-mat.supr-con',
 'cs.AI',
 'cs.AR',
 'cs.CC',
 'cs.CE',
 'cs.CG',
 'cs.CL',
 'cs.CR',
 'cs.CV',
 'cs.CY',
 'cs.DB',
 'cs.DC',
 'cs.DL',
 'cs.DM',
 'cs.DS',
 'cs.ET',
 'cs.FL',
 'cs.GL',
 'cs.GR',
 'cs.GT',
 'cs.HC',
 'cs.IR',
 'cs.IT',
 'cs.LG',
 'cs.LO',
 'cs.MA',
 'cs.MM',
 'cs.MS',
 'cs.NA',
 'cs.NE',
 'cs.NI',
 'cs.OH',
 'cs.OS',
 'cs.PF',
 'cs.PL',
 'cs.RO',
 'cs.SC',
 'cs.SD',
 'cs.SE',
 'cs.SI',
 'cs.SY',
 'econ.EM',
 'gr-qc',
 'hep-ex',
 'hep-lat',
 'hep-ph',
 'hep-th',
 'math-ph',
 'math.AC',
 'math.AG',
 'math.AP',
 'math.AT',
 'math.CA',
 'math.CO',
 'math.CT',
 'math.CV',
 'math.DG',
 'math.DS',
 'math.FA',
 'math.GM',
 'math.GN',
 'math.GR',
 'math.GT',
 'math.HO',
 'math.IT',
 'math.KT',
 'math.LO',
 'math.MG',
 'math.MP',
 'math.NA',
 'math.NT',
 'math.OA',
 'math.OC',
 'math.PR',
 'math.QA',
 'math.RA',
 'math.RT',
 'math.SG',
 'math.SP',
 'math.ST',
 'nlin.AO',
 'nlin.CD',
 'nlin.CG',
 'nlin.PS',
 'nlin.SI',
 'nucl-ex',
 'nucl-th',
 'physics.acc-ph',
 'physics.ao-ph',
 'physics.atm-clus',
 'physics.atom-ph',
 'physics.bio-ph',
 'physics.chem-ph',
 'physics.class-ph',
 'physics.comp-ph',
 'physics.data-an',
 'physics.ed-ph',
 'physics.flu-dyn',
 'physics.gen-ph',
 'physics.geo-ph',
 'physics.hist-ph',
 'physics.ins-det',
 'physics.med-ph',
 'physics.optics',
 'physics.plasm-ph',
 'physics.pop-ph',
 'physics.soc-ph',
 'physics.space-ph',
 'q-bio.BM',
 'q-bio.CB',
 'q-bio.GN',
 'q-bio.MN',
 'q-bio.NC',
 'q-bio.OT',
 'q-bio.PE',
 'q-bio.QM',
 'q-bio.SC',
 'q-bio.TO',
 'q-fin.CP',
 'q-fin.GN',
 'q-fin.PM',
 'q-fin.PR',
 'q-fin.RM',
 'q-fin.ST',
 'q-fin.TR',
 'quant-ph',
 'stat.AP',
 'stat.CO',
 'stat.ME',
 'stat.ML',
 'stat.TH'} 

三、 總結

經過三天緊張學習過程,瞭解pandas的簡單操作,依葫蘆畫瓢操作完了,其中奧妙還沒有理解。