加入收藏 | 设为首页 | 会员中心 | 我要投稿 核心网 (https://www.hxwgxz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 教程 > 正文

官方调研重磅发布,Pandas或将重构?

发布时间:2019-10-27 18:25:47 所属栏目:教程 来源:呆鸟
导读:为指引 Pandas 未来开发方向,Pandas 官方团队于 2019 年夏搞了一次调研,这次调研历时 15 天,共有 1250 条反馈数据。问卷数据保存在 data 文件夹的 2019.csv.zip 文件里。 这里又学一招,原来 pandas 可以直接从压缩文件里读取数据文件,原文用的是 .gz
副标题[/!--empirenews.page--]

官方调研重磅发布,Pandas或将重构?

为指引 Pandas 未来开发方向,Pandas 官方团队于 2019 年夏搞了一次调研,这次调研历时 15 天,共有 1250 条反馈数据。问卷数据保存在 data 文件夹的 2019.csv.zip 文件里。

这里又学一招,原来 pandas 可以直接从压缩文件里读取数据文件,原文用的是 .gz 文件,呆鸟这里用 .zip 也可以。

下列代码读取问卷数据,并对 matplotlib、seaborn 的字体进行设置,其中还包括了,如何在 macOS 里显示中文。

  1. import pandas as pd  
  2. import seaborn as sns  
  3. import matplotlib.pyplot as plt  
  4. %matplotlib inline  
  5. plt.rcParams['figure.dpi'] = 150  
  6. # 让 matplotlib 支持中文  
  7. plt.rcParams['font.sans-serif'] = ['SimHei']  
  8. # 让 seaborn 的文字大一些  
  9. sns.set( font='SimHei', font_scale=1.2)  
  10. # # 让 MacOS 下的 Matplotlib 与 Seaborn 支持中文  
  11. # plt.rcParams['font.family'] = ['Arial Unicode MS']  
  12. # sns.set_style('whitegrid',{'font.sans-serif':['Arial Unicode MS','Arial']})  
  13. # 用来正常显示负号,这里其实用不上  
  14. plt.rcParams['axes.unicode_minus'] = False  
  15. df = pd.read_csv("data/2019.csv.zip", parse_dates=['日期时间'], encoding="GBK")  
  16. # df.head() 

答卷人分析

绝大多数答卷人都具有丰富的 pandas 使用经验,使用频率也很高。

  1. order = [  
  2.     '少于 3 个月',  
  3.     '3 个月 至 1 年',  
  4.     '1 至 2 年',  
  5.     '3 至 5 年',  
  6.     '5 年以上',  
  7. ]  
  8. sns.countplot(y='您用 pandas 多久了?',  
  9.               data=df, orderorder=order, 
  10.               color='k').set(title="您用 pandas 多久了?",  
  11.                              ylabel="")  
  12. sns.despine() 

官方调研重磅发布,Pandas或将重构?

  1. order = [  
  2.     "刚开始用",  
  3.     "偶尔",  
  4.     "每周",  
  5.     "每天"  
  6. ]  
  7. sns.countplot(y='pandas 使用频率', data=df, orderorder=order,  
  8.               color='k').set(title="pandas 使用频率",  
  9.                              ylabel="")  
  10. sns.despine() 

官方调研重磅发布,Pandas或将重构?

为了对比 Pandas 与 Python 的流行度,我们的问卷里提出了一些 Python 开发者调研问卷问过的问题。

90% 的答卷人把 Python 作为主开发语言,Python 软件基金会调研报告里的数据为 84%。

  1. pct_format = "{:0.2%}".format  
  2. df['Python 是您的主打语言吗?'].str.replace(  
  3.     "否.*", "否").value_counts(normalize=True).apply(pct_format)  
  1. 是    90.67%  
  2. 否     9.33%  
  3. Name: Python 是您的主打语言吗?, dtype: object 

(编辑:核心网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

热点阅读