Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

geopandas rename column

# 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)

Comment

PREVIOUS NEXT
Code Example
Python :: PySimple list of elements 
Python :: pandas include nan in value_counts 
Python :: how to use return python 
Python :: open python not write file 
Python :: python get time executed by function 
Python :: seaborn documentation x axis range 
Python :: pyfiglet not coming up 
Python :: treesitter python 
Python :: read csv limit rows python 
Python :: column of lists pandas 
Python :: how to convert a matrix string back to a matrix python 
Python :: np.random.randint to generate -1 +1 
Python :: python check if string is in a list 
Python :: iterating a list in python 
Python :: size of int in python 
Python :: python type hints list of class 
Python :: python cursor placement 
Python :: |= operator python 
Python :: sqlite3 python parameterized query insert into 
Python :: create list of dictionaries from list of list python 
Python :: remove occurence of character from string python 
Python :: ssl socket python 
Python :: how to change an integer to a string in python permanently 
Python :: django admin.py date format 
Python :: repl.it secret 
Python :: is str in pzthon 
Python :: how should i learn python 
Python :: .lstrip() 
Python :: change increment in for loop python 
Python :: can list hold different data types in python 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =