Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

geopandas change column name

# Geopandas use the same rename function as Pandas.

import geopandas as gpd

gdf = gpd.GeoDataFrame({'x':['John', 'Doe', 'Paul'], 
        'y':[22, 31, 15],
        'z':[[-45.23332,34.23556], [-45.32565,34.49347], [-45.27648,34.45284]]
        })
columns_Name = {'x': 'name', 'y': 'age', 'z': 'location'}
gdf = gdf.rename(columns = columns_Name)
gdf
   name  age               location
0  John   22  [-45.23332, 34.23556]
1   Doe   31  [-45.32565, 34.49347]
2  Paul   15  [-45.27648, 34.45284]

# When you want the change to be implicitly saved
columns_Name = {'x': 'name', 'y': 'age', 'z': 'location'}
gdf.rename(columns = columns_Name, inplace=True)

 
PREVIOUS NEXT
Tagged: #geopandas #change #column
ADD COMMENT
Topic
Name
9+9 =