如何将Geopandas数据框导出到Excel [英] How to export a geopandas dataframe to excel
本文介绍了如何将Geopandas数据框导出到Excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在编写一个简单的代码,并希望将GEODATAFRAME的内容导出到excel.
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.
代码如下:
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)
这是我要导出到excel的GEODATAFRAME(表).
This is the GEODATAFRAME(table) that i want to export to excel.
推荐答案
它的工作原理与pandas数据框相同-您可以通过Google来做到这一点.
It works the same as a pandas dataframe - you can just Google how to do that.
以您的情况
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...
这篇关于如何将Geopandas数据框导出到Excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文