spark
.products_df = spark.table("products")
table
method returns a DataFrame representing the data in the products table.sql
: Executes a SQL query and returns the result as a DataFrame.table
: Returns a DataFrame representing the data in the specified table.read
: Returns a DataFrameReader object that can be used to read data from various sources (e.g., CSV, Parquet, JSON).createDataFrame
: Creates a DataFrame from a local collection of data.range
: Creates a DataFrame with a range of numbers.createOrReplaceTempView
: Creates or replaces a temporary view with the specified name.df.show()
displays the first 20 rows of the DataFrame in a tabular format.
df.schema()
returns the schema of the DataFrame, which describes the structure of the data, including the column names and data types.
df.printSchema()
prints the schema of the DataFrame in a tree format.
show
, collect
, count
, first
, head
, describe
, summary
and take
.
createOrReplaceTempView
method creates a temporary view of the DataFrame that can be queried using SQL.