You can cast the cols as well. But are the columns strings to begin with?
they could also actually be doubles.
On Wed, Jan 26, 2022 at 8:49 PM wrote:
> when creating dataframe from a list, how can I specify the col type?
>
> such as:
>
> >>> df =
> >>>
> spark.createDataFrame(list,["name","title
from pyspark.sql.types import *
list =[("buck trends", "ceo", 20.00, 0.25, "100")]
schema = StructType([ StructField("name", StringType(), True),
StructField("title", StringType(), True),
StructField("salary", DoubleType(), True),
when creating dataframe from a list, how can I specify the col type?
such as:
df =
spark.createDataFrame(list,["name","title","salary","rate","insurance"])
df.show()
+---+-+--++-+
| name|title|salary|rate|insurance|
+---+-+--++