Forked from christinebuckler/pyspark_dataframe_deep_copy.py
Created
February 20, 2023 07:21
-
-
Save kadaliao/18fe923529a3b329b197259e83f92a44 to your computer and use it in GitHub Desktop.
PySpark deep copy dataframe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import copy | |
X = spark.createDataFrame([[1,2], [3,4]], ['a', 'b']) | |
_schema = copy.deepcopy(X.schema) | |
_X = X.rdd.zipWithIndex().toDF(_schema) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment