You can get its shape with:

print((df.count(), len(df.columns)))
Answer from George Fisher on Stack Overflow
🌐
Spark By {Examples}
sparkbyexamples.com › home › hbase › pyspark get the size or shape of a dataframe
PySpark Get the Size or Shape of a DataFrame - Spark By {Examples}
March 27, 2024 - Similar to Python Pandas you can get the Size and Shape of the PySpark (Spark with Python) DataFrame by running count() action to get the number of rows
🌐
Spark By {Examples}
sparkbyexamples.com › home › pandas › pandas get dataframe shape
Pandas Get DataFrame Shape - Spark By {Examples}
March 27, 2024 - We can get the shape of Pandas DataFrame using the shape attribute. The shape is nothing but a number of rows and columns of the DataFrame. It returns a tuple where the first element is the number of rows and the second is the number of columns.
🌐
Data Science Learner
datasciencelearner.com › find-spark-dataframe-shape-pyspark-code
How do you find spark dataframe shape pyspark ( With Code ) ?
May 22, 2023 - We can get spark dataframe shape pyspark differently for row and column. We can use count() function for rows and len(df.columns()) for columns. Actually, most of us are pandas background where we …
🌐
GitHub
github.com › spark-examples › pyspark-examples › blob › master › pyspark-shape-dataframe.py
pyspark-examples/pyspark-shape-dataframe.py at master · spark-examples/pyspark-examples
Pyspark RDD, DataFrame and Dataset Examples in Python language - pyspark-examples/pyspark-shape-dataframe.py at master · spark-examples/pyspark-examples
Author   spark-examples
🌐
Databricks Community
community.databricks.com › t5 › data-engineering › save-spark-dataframe-to-shape-file-shp-format › td-p › 10562
Save Spark DataFrame to shape file (.shp format) - Databricks Community - 10562
March 9, 2023 - import geopandas as gpd from pyspark.sql import SparkSession from shapely.geometry import Point # create SparkSession spark = SparkSession.builder.appName("SparkGeoPandas").getOrCreate() # create sample Spark DataFrame df = spark.createDataFrame([(1, Point(0, 0)), (2, Point(1, 1))], ["id", "geometry"]) # convert Spark DataFrame to GeoDataFrame using GeoPandas *** = gpd.GeoDataFrame(df.toPandas(), geometry="geometry") # save GeoDataFrame to Shapefile ***.to_file("path/to/shapefile.shp", driver="ESRI Shapefile")
🌐
YouTube
youtube.com › joydeep bhattacharjee
Spark Dataframe Shape - YouTube
Topics covered in this video 1. Get the shape of a spark dataframe 2. Changing the column names of the dataframes Code used in this video is shared in https:...
Published   November 30, 2018
Views   251
Find elsewhere
🌐
Spark Code Hub
sparkcodehub.com › pandas-understanding-data-dimensions-with-shape
Understanding Data Dimensions and Shape in Pandas: A Comprehensive Guide
shape attribute in Pandas, exploring their functionality, applications, and practical examples. Designed for both beginners and experienced users, this blog ensures you can effectively use these tools to navigate and analyze your data. In Pandas, the dimensions of a dataset refer to its structural characteristics, specifically the number of rows and columns (for DataFrames) or elements (for Series).
🌐
Apache JIRA
issues.apache.org › jira › browse › SPARK-27756
[SPARK-27756] Add a shape property to DataFrame in pyspark - ASF JIRA
May 20, 2019 - SPARK-27756 · Log In · Export · XML · Word · Printable · JSON · Type: Wish · Status: Resolved · Priority: Minor · Resolution: Won't Fix · Affects Version/s: 2.4.3 · Fix Version/s: None · Component/s: PySpark · Labels: None · It will be great if PySpark DataFrame can support simple shape attribute which returns the number of rows and columns similar to what [pandas|https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.shape.html] has.
🌐
Linux Hint
linuxhint.com › pyspark-pandas-dataframe-shape-axes-ndim-dtypes
Pandas DataFrame: shape(),axes(),ndim() and dtypes()
Linux Hint LLC, [email protected] 1210 Kelly Park Circle, Morgan Hill, CA 95037 Privacy Policy and Terms of Use
🌐
Iditect
iditect.com › faq › python › how-to-find-the-size-or-shape-of-a-dataframe-in-pyspark.html
How to find the size or shape of a DataFrame in PySpark?
In PySpark, you can find the shape (number of rows and columns) of a DataFrame using the .count() method to get the number of rows and the .columns attribute to get the list of column names. Here's how you can do it: from pyspark.sql import SparkSession # Create a Spark session spark = ...
🌐
GeeksforGeeks
geeksforgeeks.org › get-number-of-rows-and-columns-of-pyspark-dataframe
Get number of rows and columns of PySpark dataframe | GeeksforGeeks
September 13, 2021 - In the example code, after creating the Dataframe, we are converting the PySpark Dataframe to Pandas Dataframe using toPandas() function by writing df.toPandas(). After converting the dataframe we are using Pandas function shape for getting ...
🌐
Towards Data Science
towardsdatascience.com › home › latest › 5 useful pandas functions reimplemented in pyspark
5 Useful Pandas Functions Reimplemented In Pyspark | Towards Data Science
March 5, 2025 - We will be using pd_df and ps_df to represent a Pandas and Pyspark DataFrame respectively. ... Pandas’ .shape attribute allows us to examine the number of rows and columns of a DataFrame.
🌐
Spark By {Examples}
sparkbyexamples.com › home › polars › polars dataframe shape – explained by examples
Polars DataFrame shape - Explained by Examples - Spark By {Examples}
March 20, 2025 - In Polars, the shape attribute is used to get the dimensions of a DataFrame or Series. It returns a tuple representing the number of rows and columns in the DataFrame, or the length of the Series.