cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

How can I create from scratch a brand new Dataframe with Null values using spark.createDataFrame()?

User15787040559
New Contributor III
from pyspark.sql.types import *
schema = StructType([
  StructField("c1", IntegerType(), True),
  StructField("c2", StringType(), True),
  StructField("c3", StringType(), True)])
df = spark.createDataFrame([(1, "2", None), (3, "4", None)], schema)

1 REPLY 1

Mooune_DBU
Valued Contributor
df = spark.createDataFrame(sc.emptyRDD(), schema)

Can you try this?

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you wonโ€™t want to miss the chance to attend and share knowledge.

If there isnโ€™t a group near you, start one and help create a community that brings people together.

Request a New Group