-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
30 lines (21 loc) · 844 Bytes
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# -*- coding: utf-8 -*-
"""
author SparkByExamples.com
"""
import pandas as pd
from pyspark.sql import SparkSession
from pyspark.sql.types import StructType,StructField, StringType, IntegerType
from etherscan import *
def show():
data = [['Scott', 50], ['Jeff', 45], ['Thomas', 54],['Ann',34]]
# pandasDF = pd.DataFrame(data, columns = ['Name', 'Age'])
spark = SparkSession.builder \
.master("local[1]") \
.appName("SparkByExamples.com") \
.getOrCreate()
spark.sparkContext.setLogLevel("OFF")
sparkDF=spark.createDataFrame(pandasDF)
mySchema = StructType([ StructField("First Name", StringType(), True)\
,StructField("Age", IntegerType(), True)])
sparkDF2 = spark.createDataFrame(pandasDF,schema=mySchema)
return sparkDF2.toPandas()