首页 > 解决方案 > 如何查看 geopandas 数据框中的所有列?

问题描述

这是我尝试过的:

# load shape file
shpfile = r"...\PycharmProject\maps\CA_Counties\CA_Counties_TIGER2016.shp"
map_df = gpd.read_file(shpfile);
map_df.set_option('display.max_columns',None)
print(map_df.head())

但它只显示一些列,类似于数据框。

标签: pythondataframegeopandas

解决方案


尽管 Geopandas 扩展了 Pandas,但您仍然需要导入 Pandas 才能使用set_option. 然后,您的所有选项都将转移到您的 Geopandas 数据框中。

对原始代码的这种修改应该有效:

import geopandas as gpd
import pandas as pd

# change the global options that Geopandas inherits from
pd.set_option('display.max_columns',None)

# load shape file
shpfile = r"...\PycharmProject\maps\CA_Counties\CA_Counties_TIGER2016.shp"
map_df = gpd.read_file(shpfile);
print(map_df.head())

推荐阅读