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

TOP 3大开源Python数据分析工具!

发布时间:2018-08-16 08:48:37 所属栏目:教程 来源:赵钰莹
导读:技术沙龙 | 邀您于8月25日与国美/AWS/转转三位专家共同探讨小程序电商实战 在大数据库领域,Python是最常被使用的编程语言,因此了解与其相关的数据分析工具是很有必要的。如果你正在使用virtualenv、pyenv或其他变体在自己的环境中运行Python,那么,可以

这会加载pyspark shell:

  1. (python-big-data)[email protected]:~/Development/access-log-data$ pyspark Python 3.6.5 (default, Apr 1 2018, 05:46:30) [GCC 7.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. 2018-08-03 18:13:38 WARN Utils:66 - Your hostname, admintome resolves to a loopback address: 127.0.1.1; using 192.168.1.153 instead (on interface enp0s3) 2018-08-03 18:13:38 WARN Utils:66 - Set SPARK_LOCAL_IP if you need to bind to another address 2018-08-03 18:13:39 WARN NativeCodeLoader:62 - Unable to load native-hadoop library for your platform... using builtin-java classes where applicable Setting default log level to "WARN". To adjust logging level use sc.setLogLevel(newLevel). For SparkR, use setLogLevel(newLevel). Welcome to ____ __ / __/__ ___ _____/ /__ _ / _ / _ `/ __/ '_/ /__ / .__/_,_/_/ /_/_ version 2.3.1 /_/ Using Python version 3.6.5 (default, Apr 1 2018 05:46:30) SparkSession available as 'spark'. >>> 

当你启动shell时,你会得到一个Web GUI查看你的工作状态,只需浏览到http:// localhost:4040即可获得PySpark Web GUI。

TOP 3大开源Python数据分析工具!

让我们使用PySpark Shell加载示例数据:

  1. dataframe = spark.read.format("csv").option("header","false").option("mode","DROPMALFORMED").option("quote","'").load("access_logs.csv")  
  2. dataframe.show() 

PySpark提供了已创建的DataFrame示例:

  1. >>> dataframe2.show()  
  2. +----------------+----+----------+--------------------+  
  3. | _c0| _c1| _c2| _c3|  
  4. +----------------+----+----------+--------------------+  
  5. |2018-08-01 17:10|www2|www_access|172.68.133.49 - -...|  
  6. |2018-08-01 17:10|www2|www_access|162.158.255.185 -...|  
  7. |2018-08-01 17:10|www2|www_access|108.162.238.234 -...|  
  8. |2018-08-01 17:10|www2|www_access|172.68.47.211 - -...|  
  9. |2018-08-01 17:11|www2|www_access|141.101.96.28 - -...|  
  10. |2018-08-01 17:11|www2|www_access|141.101.96.28 - -...|  
  11. |2018-08-01 17:11|www2|www_access|162.158.50.89 - -...|  
  12. |2018-08-01 17:12|www2|www_access|192.168.1.7 - - [...|  
  13. |2018-08-01 17:12|www2|www_access|172.68.47.151 - -...|  
  14. |2018-08-01 17:12|www2|www_access|192.168.1.7 - - [...|  
  15. |2018-08-01 17:12|www2|www_access|141.101.76.83 - -...|  
  16. |2018-08-01 17:14|www2|www_access|172.68.218.41 - -...|  
  17. |2018-08-01 17:14|www2|www_access|172.68.218.47 - -...|  
  18. |2018-08-01 17:14|www2|www_access|172.69.70.72 - - ...|  
  19. |2018-08-01 17:15|www2|www_access|172.68.63.24 - - ...|  
  20. |2018-08-01 17:18|www2|www_access|192.168.1.7 - - [...|  
  21. |2018-08-01 17:18|www2|www_access|141.101.99.138 - ...|  
  22. |2018-08-01 17:19|www2|www_access|192.168.1.7 - - [...|  
  23. |2018-08-01 17:19|www2|www_access|162.158.89.74 - -...|  
  24. |2018-08-01 17:19|www2|www_access|172.68.54.35 - - ...|  
  25. +----------------+----+----------+--------------------+ 
  26. only showing top 20 rows 

我们再次看到DataFrame中有四列与我们的模式匹配,DataFrame此处可以被视为数据库表或Excel电子表格。

3、Python SciKit-Learn

任何关于大数据的讨论都会引发关于机器学习的讨论,幸运的是,Python开发人员有很多选择来使用机器学习算法。

(编辑:核心网)

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

热点阅读