简体   繁体   English

如何将 geopandas dataframe 导出到 excel

[英]How to export a geopandas dataframe to excel

Iam writing a simple code and would like to export the content of the GEODATAFRAME to excel.我正在编写一个简单的代码,并希望将 GEODATAFRAME 的内容导出到 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.这是我要导出到 excel 的 GEODATAFRAME(表)。

在此处输入图像描述

It works the same as a pandas dataframe - you can just Google how to do that.它的工作原理与 pandas dataframe 相同 - 你可以谷歌如何做到这一点。

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...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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