简体   繁体   中英

How to export dataframe as excel on Databricks

I want to write multiple dataframes, either pandas, or koalas, or pyspark in one excel sheet and do something fancy like xlwx does(changing size or color of cells, etc), and save in an S3 bucket. I've tried pandas.to_csv(s3.....test.xlsx) but that is not what I want.

To merge dataframes, try something like this.

cond = [df.name == df2.name, df.age == df2.age]
df.join(df2, cond, 'inner')

Or, try converting the two objects to pandas dataframes and then do the merge.

Step #1:

df1= df1.select("*").toPandas()
df2= df2.select("*").toPandas()

Step #2:

result = pd.concat([df1, df2], axis=1)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM