How to export a geopandas dataframe to excel

北城以北 提交于 2021-01-29 07:40:28

问题


Iam writing a simple code and would like to export the content of the GEODATAFRAME to excel.

Please advise what is the simplest way to achieve that.

The code is as follows:

import geopandas as gpd
import pandas as pd
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
world.plot()
import matplotlib.pyplot as plt
plt.show()
print(world)

I have tried the following code without success:

xlpath='C:/'
df=pd.DataFrame(eval(world))
export_excel = df.to_excel(xlpath)

This is the GEODATAFRAME(table) that i want to export to excel.


回答1:


It works the same as a pandas dataframe - you can just Google how to do that.

In your case

import geopandas as gpd
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
xlpath='C:/'
world.to_excel(xlpath)    # do not use here export_excel=df.to_excel...


来源:https://stackoverflow.com/questions/58478193/how-to-export-a-geopandas-dataframe-to-excel

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!