如何将 geopandas 数据框导出到 excel

How to export a geopandas dataframe to excel

我正在编写一个简单的代码,想将 GEODATAFRAME 的内容导出到 excel。

请告知实现该目标的最简单方法是什么。

代码如下:

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)

我尝试了以下代码但没有成功:

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

这是我要导出到 excel 的 GEODATAFRAME(table)。

它的工作原理与 pandas 数据框相同 - 您可以 Google 如何做到这一点。

你的情况

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