Re: question for definition of column types

2022-01-26 Thread Sean Owen
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 = > >>> >

Re: question for definition of column types

2022-01-26 Thread Peyman Mohajerian
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),

question for definition of column types

2022-01-26 Thread capitnfrakass
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|