Python Forum
Pandas Tutor for geopandas
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pandas Tutor for geopandas
#1
Question 
Pandas Tutor can't import the geopandas library. I'm trying to understand a short function.
def dauphin_precs(row):
    nm = row['MCD_NAME']
    if row['WARD']:
        nm = nm + ' ' + row['WARD']
    if row['PRECINCT']:
        nm = nm + ' ' + row['PRECINCT']
    return nm
dauphin_gdf = geopandas.read_file('/Users/admin/Desktop/PA/2018/map/Voting_Districts-shp')
dauphin_gdf['original_precinct_name'] = dauphin_gdf.apply(lambda row: dauphin_precs(row), axis=1)
To avoid line 8 causing an error (without importing geopandas), can it be replaced with the inputted table (attached)? If yes, how? Thanks.
Reply
#2
Did you try importing with pandas rather than geopandas? In your code so far does not look like you are using anything special from geopandas.
Reply
#3
I've figured out the question in my original post (line 8 used geopandas.read_file). Pandas Tutor can't import geopandas, but it can import io.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020