Reputation: 1993
I'm trying to add a fixed value n times to an empty (geo)dataframe, I thought the below was the way to do it, but I can't seem to get it to work, where am I going wrong?
features = gpd.GeoDataFrame()
n=100
value = 'a'
gdf['new_column-name'] = value * n
Upvotes: 1
Views: 913
Reputation: 2615
Use this format:
gdf = pd.DataFrame(value, index=range(n),columns=['new_col_name'])
your way of creating dataframe:
gdf = pd.DataFrame()
gdf['new_column-name'] = [value] * n
gdf
Upvotes: 1
Reputation: 35205
This is the easiest way. Thanks for giving me a chance to answer.
gdf['new_column-name'] = [value] * n
Upvotes: 1