/
mssnle
/
study
Обзор
Документация
Войти
/
mssnle
/
study
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
pd1
22 строки
909 B
mssnle
update pd1
31 окт 2025, 14:27
31 окт 2025, 14:27
4e44c8d
Код
Авторство
О чём код?
import pandas as pd def filter_high_life_expectancy(): df = pd.read_csv("C:/Users/Анастасия/Downloads/world-data-2023.csv") life_expectancy_col = None for col in df.columns: if 'Life expectancy' in col: life_expectancy_col = col break if life_expectancy_col is None: raise KeyError("Не найдена колонка с продолжительностью жизни.") df[life_expectancy_col] = pd.to_numeric(df[life_expectancy_col].astype(str).str.replace(',', ''), errors='coerce') avg_life_expectancy = df[life_expectancy_col].mean() high_life_expectancy_df = df[df[life_expectancy_col] > avg_life_expectancy].copy() country_col = 'Country' if country_col not in df.columns: for col in df.columns: if 'Country' in col: country_col = col break