- import pandas as pd
- import matplotlib.pyplot as plt
- # Чтение данных из файла
- file_path = 'C:/Users/yusup/Downloads/user_base .xlsx'
- df = pd.read_excel(file_path)
- # Определение класса Person
- class Person:
- def __init__(self, name, city, monthly_salary):
- self.name = name
- self.city = city
- self.monthly_salary = monthly_salary
- def calculate_annual_salary(self):
- return self.monthly_salary * 12
- # Создание экземпляров Person
- people = []
- for index, row in df.iterrows():
- person = Person(row['Имя'], row['Город'], row['Зарплата'])
- people.append(person)
- # Построение гистограммы
- city_counts = df['Город'].value_counts()
- city_counts.plot(kind='bar', title='Количество людей в каждом городе')
- plt.xlabel('Город')
- plt.ylabel('Количество людей')
- plt.show()
- # Построение графика зарплаты
- city_salaries = df.groupby('Город')['Зарплата'].mean()
- city_salaries.plot(kind='bar', title='Средний уровень зарплаты в каждом городе')
- plt.xlabel('Город')
- plt.ylabel('Средняя зарплата')
- plt.show()
- # Группировка данных по городам и вычисление средней зарплаты
- city_salaries = df.groupby('City')['Monthly Salary'].mean()
- # Построение графика
- plt.figure(figsize=(10, 6))
- plt.bar(city_salaries.index, city_salaries.values)
- plt.xlabel('Город')
- plt.ylabel('Средняя зарплата')
- plt.title('Средний уровень зарплаты в каждом городе')
- plt.xticks(rotation=45)
- plt.show()
- # Группировка данных по городам и подсчет количества людей
- city_counts = df['Город'].value_counts()
- # Построение гистограммы
- plt.figure(figsize=(10, 6))
- plt.bar(city_counts.index, city_counts.values)
- plt.xlabel('Город')
- plt.ylabel('Количество людей')
- plt.title('Распределение количества людей по городам')
- plt.xticks(rotation=45)
- plt.show()
[text] ага
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Editor
You can edit this paste and save as new: