1. 主页
  2. 文档
  3. GeoPandas 0.12.2中文文档
  4. User Guide
  5. Aggregation with dissolve(聚合操作)
  6. Dissolve Arguments

Dissolve Arguments

The aggfunc = argument defaults to ‘first’ which means that the first row of attributes values found in the dissolve routine will be assigned to the resultant dissolved geodataframe. However it also accepts other summary statistic options as allowed by pandas.groupby including:

aggfunc = 参数默认为“first”,这意味着在聚合程序中找到的第一行属性值将分配给生成的geodataframe。然而,它也接受 pandas.groupby 允许的其他汇总统计选项,包括:

  • ‘first’
  • ‘last’
  • ‘min’
  • ‘max’
    • ‘sum’
    • ‘mean’
    • ‘median’
    • function
    • string function name
    • list of functions and/or function names, e.g. [np.sum, ‘mean’].函数和/或函数名称的列表,例如:[np.sum, ‘mean’]
    • dict of axis labels -> functions, function names or list of such.

    For example, to get the number of countries on each continent, as well as the populations of the largest and smallest country of each, we can aggregate the 'name' column using 'count', and the 'pop_est' column using 'min' and 'max':

    例如,为了得到各大洲的国家数量,以及各大洲最大和最小的国家的人口,我们可以用’count’聚合’name’列,用’min’和’max’聚合’pop_est’列。

    In [11]: world = geopandas.read_file(geopandas.datasets.get_path("naturalearth_lowres"))
    
    In [12]: continents = world.dissolve(
    ...      by="continent",
    ...      aggfunc={
    ...          "name": "count",
    ...          "pop_est": ["min", "max"],
    ...      },
    ... )
    
    标签 , ,
    这篇文章对您有用吗?

    我们要如何帮助您?

    欢迎留下您的宝贵建议

    Please enter your comment!
    Please enter your name here