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|
+-----------+---------+------+----+---------+
|buck trends|      ceo|200000|0.25|      100|
|cindy banks|      cfo|170000|0.22|      120|
|  joe coder|developer|130000| 0.2|      120|
+-----------+---------+------+----+---------+


df.describe()
DataFrame[summary: string, name: string, title: string, salary: string, rate: string, insurance: string]

I want the salary, rate, insurance to be Double type, not a String type.

Thank you.
Frakass

---------------------------------------------------------------------
To unsubscribe e-mail: user-unsubscr...@spark.apache.org

Reply via email to