spark在 python 中运用

RDD属性。

只读:不能修改,只能通过转换操作生成新的 RDD。
分布式:可以分布在多台机器上进行并行处理。
弹性:计算过程中内存不够时它会和磁盘进行数据交换。
基于内存:可以全部或部分缓存在内存中,在多次计算间重用

# -*- coding: utf-8 -*-
# uptime  8 月 26
import requests
#  v36 二级违禁专项排查
import time
import json
import MySQLdb,zlib
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir, os.pardir))
import xlrd
env = os.environ
from pyspark import SparkContext
from pyspark.sql import  SparkSession
os.system('mkdir %s' % env['BUILD_NUMBER'])

from weijin_data.utils.validate_data import download
# # 根据表单数据,下载资源并进行验证
weijin_link = env.get('weijin_link')
print(weijin_link)
print('===========')

# 下载文件
save_path = download(weijin_link,file_name='weijin.xlsx')
print(save_path)
book = xlrd.open_workbook(save_path,encoding_override='utf-8')
# book = xlrd.open_workbook('全站违禁词列表 .xlsx',encoding_override='utf-8')
table = book.sheet_by_index(0)
nrow = table.nrows
weijin_list = []
for q in range(1, nrow):
    str1 = table.cell(q, 0).value  # 主词
    str3 = table.cell(q, 4).value  # 等级
    str2 = table.cell(q, 6).value # 正选词
    fa_x = table.cell(q,7).value # 反选词
    if int(str3) ==2 and fa_x == '':
        str_list = 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
Paperback: 146 pages Publisher: Packt Publishing - ebooks Account (February 4, 2016) Language: English ISBN-10: 1784399698 ISBN-13: 978-1784399696 Key Features Set up real-time streaming and batch data intensive infrastructure using Spark and Python Deliver insightful visualizations in a web app using Spark (PySpark) Inject live data using Spark Streaming with real-time events Book Description Looking for a cluster computing system that provides high-level APIs? Apache Spark is your answer―an open source, fast, and general purpose cluster computing system. Spark's multi-stage memory primitives provide performance up to 100 times faster than Hadoop, and it is also well-suited for machine learning algorithms. Are you a Python developer inclined to work with Spark engine? If so, this book will be your companion as you create data-intensive app using Spark as a processing engine, Python visualization libraries, and web frameworks such as Flask. To begin with, you will learn the most effective way to install the Python development environment powered by Spark, Blaze, and Bookeh. You will then find out how to connect with data stores such as MySQL, MongoDB, Cassandra, and Hadoop. You'll expand your skills throughout, getting familiarized with the various data sources (Github, Twitter, Meetup, and Blogs), their data structures, and solutions to effectively tackle complexities. You'll explore datasets using iPython Notebook and will discover how to optimize the data models and pipeline. Finally, you'll get to know how to create training datasets and train the machine learning models. By the end of the book, you will have created a real-time and insightful trend tracker data-intensive app with Spark.

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

瓶瓶罐罐的

如果帮助到你了,请来点实际的

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值