Search
 
SCRIPT & CODE EXAMPLE
 

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)

Comment

PREVIOUS NEXT
Code Example
Python :: Python Program to Shuffle Deck of Cards 
Python :: is plaindrome python 
Python :: how to open youtube from google chrome browser instead of internet explorerwhen coding in python 
Python :: upload file django 
Python :: django group permissions method 
Python :: swapping 
Python :: dataframe rolling window 
Python :: how to average only positive number in array numpy 
Python :: python create sqlite db file 
Python :: how to convert a matrix string back to a matrix python 
Python :: cv2.imshow not working in vscode 
Python :: how delete an entry tkinter 
Python :: or en python 
Python :: to get the number of unique values for each column 
Python :: Get text without inner tags text in selenium 
Python :: aiohttp 
Python :: jupyter read excel 
Python :: Maximize Difference 
Python :: python loops 
Python :: Python script from c++ 
Python :: pandas rearrange rows based on datetime index 
Python :: best way to access nested key in python 
Python :: dimension of an indez pandas 
Python :: Proj 4.9.0 must be installed. 
Python :: dict comprehensions 
Python :: python list function 
Python :: nltk python how to tokenize text 
Python :: application automation python library 
Python :: create and activate virtual environment with python 3 
Python :: Reverse an string Using Loop in Python 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =