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 <capitnfrak...@free.fr> wrote:

> 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