_594.159.447.252 / 1084_159_242.py
antitheft159's picture
Upload 1084_159_242.py
d4fb15e verified
# -*- coding: utf-8 -*-
"""1084.159.242
Automatically generated by Colab.
Original file is located at
https://colab.research.google.com/drive/16y68gc0r9IhP7zQrYaHn726QzpMNc-uz
"""
import pandas as pd
df = pd.read_csv('/content/Cost_of_Living_Index_by_Country_2024.csv')
df.head()
df.describe().T
import geopandas as gpd
import matplotlib.pyplot as plt
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
filtered_world = world[world['name'].isin(df['Country'])]
merged = filtered_world.set_index('name').join(
pd.DataFrame(df).set_index('Country')
)
fig, ax = plt.subplots(1, 1, figsize=(15, 10))
world.boundary.plot(ax=ax)
merged.plot(column='Cost of Living Index', ax=ax, legend=True, legend_kwds={'label': "Cost of Living Index", 'orientation': "horizontal"})
plt.title('Country by Cost of Living Index')
plt.show()
import plotly.express as px
world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres'))
world = world.rename(columns={'name': 'Country'})
merged = world.merge(df, on='Country')
fig = px.choropleth(
merged,
locations='Country',
locationmode='country names',
color="Cost of Living Index",
hover_name="Country",
hover_data={
'Cost of Living Index': True,
'Rent Index': True,
'Cost of Living Plus Rent Index': True,
'Groceries Index': True,
'Restaurant Price Index': True,
'Local Purchasing Power Index': True
},
color_continuous_scale=px.colors.sequential.Plasma,
title="Countries by Cost of Living Index"
)
fig.show()