0% found this document useful (0 votes)
3 views2 pages

Create DataFrame in PySpark

The document demonstrates how to create a Spark session using PySpark and create a DataFrame from sample data containing names and ages. It includes commands to display the DataFrame content and properly stop the Spark session. The code is repeated multiple times without any changes.

Uploaded by

bkumareddy36
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

Create DataFrame in PySpark

The document demonstrates how to create a Spark session using PySpark and create a DataFrame from sample data containing names and ages. It includes commands to display the DataFrame content and properly stop the Spark session. The code is repeated multiple times without any changes.

Uploaded by

bkumareddy36
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

from pyspark.

sql import SparkSession

# Create a Spark session


spark = [Link] \
.appName("SimpleApp") \
.getOrCreate()

# Sample data
data = [("Alice", 25), ("Bob", 30), ("Charlie", 35)]

# Create a DataFrame from the data


df = [Link](data, ["Name", "Age"])

# Show the DataFrame content


[Link]()

# Stop the Spark session


[Link]()

from [Link] import SparkSession

# Create a Spark session


spark = [Link] \
.appName("SimpleApp") \
.getOrCreate()

# Sample data
data = [("Alice", 25), ("Bob", 30), ("Charlie", 35)]

# Create a DataFrame from the data


df = [Link](data, ["Name", "Age"])

# Show the DataFrame content


[Link]()

# Stop the Spark session


[Link]()
from [Link] import SparkSession

# Create a Spark session


spark = [Link] \
.appName("SimpleApp") \
.getOrCreate()

# Sample data
data = [("Alice", 25), ("Bob", 30), ("Charlie", 35)]

# Create a DataFrame from the data


df = [Link](data, ["Name", "Age"])

# Show the DataFrame content


[Link]()

# Stop the Spark session


[Link]()

You might also like