Answers for "pyspark create table from dataframe"

0

create dataframe pyspark

from datetime import datetime, date
import pandas as pd
from pyspark.sql import Row

df = spark.createDataFrame([
    Row(a=1, b=2., c='string1', d=date(2000, 1, 1), e=datetime(2000, 1, 1, 12, 0)),
    Row(a=2, b=3., c='string2', d=date(2000, 2, 1), e=datetime(2000, 1, 2, 12, 0)),
    Row(a=4, b=5., c='string3', d=date(2000, 3, 1), e=datetime(2000, 1, 3, 12, 0))
])
df
Posted by: Guest on September-20-2021
0

create table pyspark sql

df.createOrReplaceTempView("tableA")
spark.sql("SELECT count(*) from tableA").show()
Posted by: Guest on September-20-2021

Code answers related to "pyspark create table from dataframe"

Python Answers by Framework

Browse Popular Code Answers by Language