You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@spark.apache.org by ca...@free.fr on 2022/04/02 01:42:57 UTC

how to change data type for columns of dataframe

Hi

I got a dataframe object from other application, it means this obj is 
not generated by me.
How can I change the data types for some columns in this dataframe?

For example, change the column type from Int to Float.

Thanks.

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


Re: how to change data type for columns of dataframe

Posted by Bjørn Jørgensen <bj...@gmail.com>.
https://sparkbyexamples.com/pyspark/pyspark-cast-column-type/


lør. 2. apr. 2022 kl. 04:10 skrev ayan guha <gu...@gmail.com>:

> Please use cast. Also I would strongly recommend to go through spark doco,
> its pretty good.
>
> On Sat, 2 Apr 2022 at 12:43 pm, <ca...@free.fr> wrote:
>
>> Hi
>>
>> I got a dataframe object from other application, it means this obj is
>> not generated by me.
>> How can I change the data types for some columns in this dataframe?
>>
>> For example, change the column type from Int to Float.
>>
>> Thanks.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe e-mail: user-unsubscribe@spark.apache.org
>>
>> --
> Best Regards,
> Ayan Guha
>


-- 
Bjørn Jørgensen
Vestre Aspehaug 4, 6010 Ålesund
Norge

+47 480 94 297

Re: how to change data type for columns of dataframe

Posted by ayan guha <gu...@gmail.com>.
Please use cast. Also I would strongly recommend to go through spark doco,
its pretty good.

On Sat, 2 Apr 2022 at 12:43 pm, <ca...@free.fr> wrote:

> Hi
>
> I got a dataframe object from other application, it means this obj is
> not generated by me.
> How can I change the data types for some columns in this dataframe?
>
> For example, change the column type from Int to Float.
>
> Thanks.
>
> ---------------------------------------------------------------------
> To unsubscribe e-mail: user-unsubscribe@spark.apache.org
>
> --
Best Regards,
Ayan Guha