Reputation: 85
I have a pyspark dataframe. I was able to convert dynamic dataframe to spark dataframe by persons.toDF()
. I want to convert the spark dataframe again back to dynamic dataframe in pyspark.I wanted to cast my column to timestamp and again convert it to dynamic dataframe to resolveChoices.
Please help me
Upvotes: 3
Views: 10767
Reputation: 61
at least you need pyspark.context, awsglue.context and awsglue.dynamicframe There is example :
from pyspark.context import SparkContext
from awsglue.context import GlueContext
from awsglue.dynamicframe import DynamicFrame
sc = SparkContext()
glueContext = GlueContext(sc)
NewDynamicFrame = DynamicFrame.fromDF(persons, glueContext, "nested")
"persons" is your DataFrame
Please check following links :
Upvotes: 4
Reputation: 2224
You can create a dynamic frame from dataframe using the fromDF function.
Basic Syntax
dyf = fromDF(dataframe, glue_ctx, name)
where,
dataframe – The Apache Spark SQL DataFrame to convert (required).
glue_ctx – The GlueContext Class object that specifies the context for this transform (required).
name – The name of the resulting DynamicFrame (required).
Reference : Dynamic frame from dataframe
Upvotes: 3