First page Back Continue Last page Overview Graphics

Adding New Columns

We can also include a column name which is not contained in the dictionary. In this case, all the values of this column will be set to NaN:

city_frame = pd.DataFrame(cities,

columns=["country",

"area",

"population"],

index=cities["name"])

print(city_frame)

country area population

name

London England NaN 8615246

Berlin Germany NaN 3562166

Madrid Spain NaN 3165235

Rome Italy NaN 2874038

Paris France NaN 2273305

Vienna Austria NaN 1805681

Bucharest Romania NaN 1803425

Hamburg Germany NaN 1760433