How to convert datatype of all the columns of a pandas dataframe to string

pandas pyspark

79 观看


65 作者的声誉

I have tried multiple ways to achieve this for ex: inputpd = pd.DataFrame(inputpd.columns,dtype=str)

But it does not work. sorry for asking this question as i am beginner to spark.

作者: LKA 的来源 发布者: 2017 年 12 月 27 日

回应 (2)


136041 作者的声誉

If it's a Pandas DataFrame:

df = df.astype(str)
作者: MaxU 发布者: 27.12.2017 04:35


92 作者的声誉

The easiest way I think it is:

df = df.applymap(str)

df is your dataframe.

作者: Sorginah 发布者: 28.12.2017 09:09