LABA_2
This commit is contained in:
commit
82763149c2
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
.venv/
|
||||||
3
.idea/.gitignore
generated
vendored
Normal file
3
.idea/.gitignore
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
10
.idea/AC.iml
generated
Normal file
10
.idea/AC.iml
generated
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="PYTHON_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/.venv" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="jdk" jdkName="Python 3.13 (AC)" jdkType="Python SDK" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
||||||
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
6
.idea/inspectionProfiles/profiles_settings.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<component name="InspectionProjectProfileManager">
|
||||||
|
<settings>
|
||||||
|
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||||
|
<version value="1.0" />
|
||||||
|
</settings>
|
||||||
|
</component>
|
||||||
7
.idea/misc.xml
generated
Normal file
7
.idea/misc.xml
generated
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Black">
|
||||||
|
<option name="sdkName" value="Python 3.13" />
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.13 (AC)" project-jdk-type="Python SDK" />
|
||||||
|
</project>
|
||||||
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/AC.iml" filepath="$PROJECT_DIR$/.idea/AC.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
6
.ipynb_checkpoints/Untitled-checkpoint.ipynb
Normal file
6
.ipynb_checkpoints/Untitled-checkpoint.ipynb
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"cells": [],
|
||||||
|
"metadata": {},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
||||||
6
.ipynb_checkpoints/matplotlib-checkpoint.ipynb
Normal file
6
.ipynb_checkpoints/matplotlib-checkpoint.ipynb
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"cells": [],
|
||||||
|
"metadata": {},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
||||||
6
.ipynb_checkpoints/numpy-checkpoint.ipynb
Normal file
6
.ipynb_checkpoints/numpy-checkpoint.ipynb
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"cells": [],
|
||||||
|
"metadata": {},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
||||||
6
.ipynb_checkpoints/pandas-checkpoint.ipynb
Normal file
6
.ipynb_checkpoints/pandas-checkpoint.ipynb
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"cells": [],
|
||||||
|
"metadata": {},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
||||||
6
.ipynb_checkpoints/seaborn-checkpoint.ipynb
Normal file
6
.ipynb_checkpoints/seaborn-checkpoint.ipynb
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"cells": [],
|
||||||
|
"metadata": {},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
||||||
6
.ipynb_checkpoints/tqdm-checkpoint.ipynb
Normal file
6
.ipynb_checkpoints/tqdm-checkpoint.ipynb
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"cells": [],
|
||||||
|
"metadata": {},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
||||||
6
Untitled.ipynb
Normal file
6
Untitled.ipynb
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"cells": [],
|
||||||
|
"metadata": {},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
||||||
16
main.py
Normal file
16
main.py
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
# This is a sample Python script.
|
||||||
|
|
||||||
|
# Press Shift+F10 to execute it or replace it with your code.
|
||||||
|
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
|
||||||
|
|
||||||
|
|
||||||
|
def print_hi(name):
|
||||||
|
# Use a breakpoint in the code line below to debug your script.
|
||||||
|
print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint.
|
||||||
|
|
||||||
|
|
||||||
|
# Press the green button in the gutter to run the script.
|
||||||
|
if __name__ == '__main__':
|
||||||
|
print_hi('PyCharm')
|
||||||
|
|
||||||
|
# See PyCharm help at https://www.jetbrains.com/help/pycharm/
|
||||||
95
matplotlib.ipynb
Normal file
95
matplotlib.ipynb
Normal file
File diff suppressed because one or more lines are too long
107
numpy.ipynb
Normal file
107
numpy.ipynb
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 2,
|
||||||
|
"id": "dee9612a-be34-4974-83a7-19463c8731cc",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"--- 1. Двумерный массив ---\n",
|
||||||
|
"[[1 2]\n",
|
||||||
|
" [3 4]]\n",
|
||||||
|
"\n",
|
||||||
|
"--- 2. Равномерные интервалы (linspace) ---\n",
|
||||||
|
"[0. 0.55555556 1.11111111 1.66666667 2.22222222 2.77777778\n",
|
||||||
|
" 3.33333333 3.88888889 4.44444444 5. ]\n",
|
||||||
|
"\n",
|
||||||
|
"--- 3. Случайные числа (randn) ---\n",
|
||||||
|
"[[-0.21233837 -0.06728663]\n",
|
||||||
|
" [-0.00379929 1.34918302]]\n",
|
||||||
|
"\n",
|
||||||
|
"--- 4. Результат np.dot() ---\n",
|
||||||
|
"[[-0.21993694 2.63107942]\n",
|
||||||
|
" [-0.65221224 5.19487221]]\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/plain": [
|
||||||
|
"array([[-0.21993694, 2.63107942],\n",
|
||||||
|
" [-0.65221224, 5.19487221]])"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"execution_count": 2,
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "execute_result"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import numpy as np\n",
|
||||||
|
"\n",
|
||||||
|
"# 1. Создание двумерного массива (матрицы 2x2)\n",
|
||||||
|
"matrix_2x2 = np.array([[1, 2], [3, 4]])\n",
|
||||||
|
"\n",
|
||||||
|
"# 2. Использование np.linspace() \n",
|
||||||
|
"# Создаем 10 равномерно распределенных чисел от 0 до 5\n",
|
||||||
|
"lin_points = np.linspace(0, 5, 10)\n",
|
||||||
|
"\n",
|
||||||
|
"# 3. Использование np.random.randn()\n",
|
||||||
|
"# Генерируем случайную матрицу 2x2 из нормального распределения\n",
|
||||||
|
"random_matrix = np.random.randn(2, 2)\n",
|
||||||
|
"\n",
|
||||||
|
"# 4. Использование np.dot()\n",
|
||||||
|
"# Выполняем умножение двух матриц (нашей первой матрицы и случайной)\n",
|
||||||
|
"matrix_product = np.dot(matrix_2x2, random_matrix)\n",
|
||||||
|
"\n",
|
||||||
|
"# Вывод всех результатов\n",
|
||||||
|
"print(\"--- 1. Двумерный массив ---\")\n",
|
||||||
|
"print(matrix_2x2)\n",
|
||||||
|
"\n",
|
||||||
|
"print(\"\\n--- 2. Равномерные интервалы (linspace) ---\")\n",
|
||||||
|
"print(lin_points)\n",
|
||||||
|
"\n",
|
||||||
|
"print(\"\\n--- 3. Случайные числа (randn) ---\")\n",
|
||||||
|
"print(random_matrix)\n",
|
||||||
|
"\n",
|
||||||
|
"print(\"\\n--- 4. Результат np.dot() ---\")\n",
|
||||||
|
"print(matrix_product)\n",
|
||||||
|
"\n",
|
||||||
|
"# Последняя строчка для отображения в интерактивной среде\n",
|
||||||
|
"matrix_product"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "e65894d4-712a-4dab-90ff-15e3b17cfcc1",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3 (ipykernel)",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.13.5"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
||||||
160
pandas.ipynb
Normal file
160
pandas.ipynb
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 1,
|
||||||
|
"id": "42a5aacc-5e39-4262-99dc-f4fc3a2c58a4",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/html": [
|
||||||
|
"<div>\n",
|
||||||
|
"<style scoped>\n",
|
||||||
|
" .dataframe tbody tr th:only-of-type {\n",
|
||||||
|
" vertical-align: middle;\n",
|
||||||
|
" }\n",
|
||||||
|
"\n",
|
||||||
|
" .dataframe tbody tr th {\n",
|
||||||
|
" vertical-align: top;\n",
|
||||||
|
" }\n",
|
||||||
|
"\n",
|
||||||
|
" .dataframe thead th {\n",
|
||||||
|
" text-align: right;\n",
|
||||||
|
" }\n",
|
||||||
|
"</style>\n",
|
||||||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
||||||
|
" <thead>\n",
|
||||||
|
" <tr style=\"text-align: right;\">\n",
|
||||||
|
" <th></th>\n",
|
||||||
|
" <th>Имя</th>\n",
|
||||||
|
" <th>Возраст</th>\n",
|
||||||
|
" <th>Баллы</th>\n",
|
||||||
|
" <th>Категория</th>\n",
|
||||||
|
" <th>Прогноз_балла</th>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" </thead>\n",
|
||||||
|
" <tbody>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>0</th>\n",
|
||||||
|
" <td>Анна</td>\n",
|
||||||
|
" <td>21</td>\n",
|
||||||
|
" <td>89</td>\n",
|
||||||
|
" <td>A</td>\n",
|
||||||
|
" <td>106.8</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>1</th>\n",
|
||||||
|
" <td>Борис</td>\n",
|
||||||
|
" <td>22</td>\n",
|
||||||
|
" <td>76</td>\n",
|
||||||
|
" <td>B</td>\n",
|
||||||
|
" <td>91.2</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>2</th>\n",
|
||||||
|
" <td>Виктор</td>\n",
|
||||||
|
" <td>23</td>\n",
|
||||||
|
" <td>95</td>\n",
|
||||||
|
" <td>A</td>\n",
|
||||||
|
" <td>114.0</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>3</th>\n",
|
||||||
|
" <td>Галина</td>\n",
|
||||||
|
" <td>24</td>\n",
|
||||||
|
" <td>82</td>\n",
|
||||||
|
" <td>B</td>\n",
|
||||||
|
" <td>98.4</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>4</th>\n",
|
||||||
|
" <td>Дмитрий</td>\n",
|
||||||
|
" <td>21</td>\n",
|
||||||
|
" <td>91</td>\n",
|
||||||
|
" <td>A</td>\n",
|
||||||
|
" <td>109.2</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>5</th>\n",
|
||||||
|
" <td>Елена</td>\n",
|
||||||
|
" <td>25</td>\n",
|
||||||
|
" <td>88</td>\n",
|
||||||
|
" <td>C</td>\n",
|
||||||
|
" <td>105.6</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" </tbody>\n",
|
||||||
|
"</table>\n",
|
||||||
|
"</div>"
|
||||||
|
],
|
||||||
|
"text/plain": [
|
||||||
|
" Имя Возраст Баллы Категория Прогноз_балла\n",
|
||||||
|
"0 Анна 21 89 A 106.8\n",
|
||||||
|
"1 Борис 22 76 B 91.2\n",
|
||||||
|
"2 Виктор 23 95 A 114.0\n",
|
||||||
|
"3 Галина 24 82 B 98.4\n",
|
||||||
|
"4 Дмитрий 21 91 A 109.2\n",
|
||||||
|
"5 Елена 25 88 C 105.6"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"execution_count": 1,
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "execute_result"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import pandas as pd\n",
|
||||||
|
"\n",
|
||||||
|
"# Создаем расширенный DataFrame (с добавлением категории)\n",
|
||||||
|
"data = {\n",
|
||||||
|
" \"Имя\": [\"Анна\", \"Борис\", \"Виктор\", \"Галина\", \"Дмитрий\", \"Елена\"],\n",
|
||||||
|
" \"Возраст\": [21, 22, 23, 24, 21, 25],\n",
|
||||||
|
" \"Баллы\": [89, 76, 95, 82, 91, 88],\n",
|
||||||
|
" \"Категория\": [\"A\", \"B\", \"A\", \"B\", \"A\", \"C\"]\n",
|
||||||
|
"}\n",
|
||||||
|
"df = pd.DataFrame(data)\n",
|
||||||
|
"\n",
|
||||||
|
"# 1. Добавляем новый столбец с коэффициентом 1.2 (отличие от примера)\n",
|
||||||
|
"df[\"Прогноз_балла\"] = df[\"Баллы\"] * 1.2\n",
|
||||||
|
"\n",
|
||||||
|
"# 2. Группировка данных по категории\n",
|
||||||
|
"grouped = df.groupby(\"Категория\").agg({\"Баллы\": [\"mean\", \"max\"]})\n",
|
||||||
|
"\n",
|
||||||
|
"# 3. Фильтрация\n",
|
||||||
|
"filtered_df = df[df[\"Баллы\"] > 85]\n",
|
||||||
|
"\n",
|
||||||
|
"# Вывод результата в последней строке\n",
|
||||||
|
"df"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "5d0af1f0-3cd7-4720-b1e3-361b88b300d6",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3 (ipykernel)",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.13.5"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
||||||
131
seaborn.ipynb
Normal file
131
seaborn.ipynb
Normal file
File diff suppressed because one or more lines are too long
26
top_movies.csv
Normal file
26
top_movies.csv
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
title,popularity,vote_average,vote_count,release_year
|
||||||
|
The Shawshank Redemption,85.5,8.7,21000,1994
|
||||||
|
The Godfather,70.2,8.7,16000,1972
|
||||||
|
The Dark Knight,92.1,8.5,27000,2008
|
||||||
|
Inception,120.4,8.3,31000,2010
|
||||||
|
Pulp Fiction,65.8,8.5,23000,1994
|
||||||
|
Interstellar,150.2,8.3,28000,2014
|
||||||
|
The Matrix,75.4,8.2,24000,1999
|
||||||
|
Forrest Gump,55.9,8.2,22000,1994
|
||||||
|
Avengers: Endgame,250.7,8.3,20000,2019
|
||||||
|
Spider-Man: No Way Home,310.5,8.1,15000,2021
|
||||||
|
Parasite,45.3,8.5,12000,2019
|
||||||
|
The Lion King,35.2,8.2,14000,1994
|
||||||
|
Fight Club,60.1,8.4,24000,1999
|
||||||
|
Spirited Away,38.7,8.5,11000,2001
|
||||||
|
Gladiator,42.5,8.2,15000,2000
|
||||||
|
Joker,180.3,8.2,19000,2019
|
||||||
|
The Green Mile,30.2,8.5,13000,1999
|
||||||
|
Titanic,110.1,7.9,21000,1997
|
||||||
|
Avatar,140.8,7.5,25000,2009
|
||||||
|
The Wolf of Wall Street,95.4,8.0,18000,2013
|
||||||
|
Star Wars: A New Hope,50.2,8.2,17000,1977
|
||||||
|
Mad Max: Fury Road,88.1,8.1,19000,2015
|
||||||
|
La La Land,40.5,7.9,14000,2016
|
||||||
|
The Silence of the Lambs,33.2,8.3,13000,1991
|
||||||
|
Goodfellas,28.4,8.5,10000,1990
|
||||||
|
166
tqdm.ipynb
Normal file
166
tqdm.ipynb
Normal file
@ -0,0 +1,166 @@
|
|||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 1,
|
||||||
|
"id": "6ac02338-6e18-4fbc-874a-67d98f58cd38",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"Запуск обработки данных с tqdm...\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "stderr",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"Обработка строк: 100%|\u001b[32m███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████\u001b[0m| 1000/1000 [00:05<00:00, 174.99row/s]\u001b[0m\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"\n",
|
||||||
|
"Обработка завершена!\n"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "stderr",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"Общий прогресс: 0%| | 0/5 [00:00<?, ?it/s]\n",
|
||||||
|
"Этап 1: 0%| | 0/100 [00:00<?, ?it/s]\u001b[A\n",
|
||||||
|
"Этап 1: 10%|██████████████████ | 10/100 [00:00<00:00, 94.51it/s]\u001b[A\n",
|
||||||
|
"Этап 1: 20%|████████████████████████████████████▏ | 20/100 [00:00<00:00, 93.67it/s]\u001b[A\n",
|
||||||
|
"Этап 1: 30%|██████████████████████████████████████████████████████▎ | 30/100 [00:00<00:00, 93.27it/s]\u001b[A\n",
|
||||||
|
"Этап 1: 40%|████████████████████████████████████████████████████████████████████████▍ | 40/100 [00:00<00:00, 93.07it/s]\u001b[A\n",
|
||||||
|
"Этап 1: 50%|██████████████████████████████████████████████████████████████████████████████████████████▌ | 50/100 [00:00<00:00, 92.95it/s]\u001b[A\n",
|
||||||
|
"Этап 1: 60%|████████████████████████████████████████████████████████████████████████████████████████████████████████████▌ | 60/100 [00:00<00:00, 92.65it/s]\u001b[A\n",
|
||||||
|
"Этап 1: 70%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▋ | 70/100 [00:00<00:00, 91.36it/s]\u001b[A\n",
|
||||||
|
"Этап 1: 80%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▊ | 80/100 [00:00<00:00, 91.22it/s]\u001b[A\n",
|
||||||
|
"Этап 1: 90%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▉ | 90/100 [00:00<00:00, 91.55it/s]\u001b[A\n",
|
||||||
|
"Этап 1: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 92.34it/s]\u001b[A\n",
|
||||||
|
"Общий прогресс: 20%|███████████████████████████████████▏ | 1/5 [00:01<00:04, 1.09s/it]\u001b[A\n",
|
||||||
|
"Этап 2: 0%| | 0/100 [00:00<?, ?it/s]\u001b[A\n",
|
||||||
|
"Этап 2: 10%|██████████████████ | 10/100 [00:00<00:00, 93.73it/s]\u001b[A\n",
|
||||||
|
"Этап 2: 20%|████████████████████████████████████▏ | 20/100 [00:00<00:00, 94.35it/s]\u001b[A\n",
|
||||||
|
"Этап 2: 30%|██████████████████████████████████████████████████████▎ | 30/100 [00:00<00:00, 95.35it/s]\u001b[A\n",
|
||||||
|
"Этап 2: 40%|████████████████████████████████████████████████████████████████████████▍ | 40/100 [00:00<00:00, 94.90it/s]\u001b[A\n",
|
||||||
|
"Этап 2: 50%|██████████████████████████████████████████████████████████████████████████████████████████▌ | 50/100 [00:00<00:00, 94.21it/s]\u001b[A\n",
|
||||||
|
"Этап 2: 60%|████████████████████████████████████████████████████████████████████████████████████████████████████████████▌ | 60/100 [00:00<00:00, 93.83it/s]\u001b[A\n",
|
||||||
|
"Этап 2: 70%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▋ | 70/100 [00:00<00:00, 93.05it/s]\u001b[A\n",
|
||||||
|
"Этап 2: 80%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▊ | 80/100 [00:00<00:00, 93.72it/s]\u001b[A\n",
|
||||||
|
"Этап 2: 90%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▉ | 90/100 [00:00<00:00, 92.32it/s]\u001b[A\n",
|
||||||
|
"Этап 2: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 92.27it/s]\u001b[A\n",
|
||||||
|
"Общий прогресс: 40%|██████████████████████████████████████████████████████████████████████▍ | 2/5 [00:02<00:03, 1.08s/it]\u001b[A\n",
|
||||||
|
"Этап 3: 0%| | 0/100 [00:00<?, ?it/s]\u001b[A\n",
|
||||||
|
"Этап 3: 10%|██████████████████ | 10/100 [00:00<00:00, 94.59it/s]\u001b[A\n",
|
||||||
|
"Этап 3: 20%|████████████████████████████████████▏ | 20/100 [00:00<00:00, 92.75it/s]\u001b[A\n",
|
||||||
|
"Этап 3: 30%|██████████████████████████████████████████████████████▎ | 30/100 [00:00<00:00, 93.11it/s]\u001b[A\n",
|
||||||
|
"Этап 3: 40%|████████████████████████████████████████████████████████████████████████▍ | 40/100 [00:00<00:00, 93.59it/s]\u001b[A\n",
|
||||||
|
"Этап 3: 50%|██████████████████████████████████████████████████████████████████████████████████████████▌ | 50/100 [00:00<00:00, 93.34it/s]\u001b[A\n",
|
||||||
|
"Этап 3: 60%|████████████████████████████████████████████████████████████████████████████████████████████████████████████▌ | 60/100 [00:00<00:00, 92.72it/s]\u001b[A\n",
|
||||||
|
"Этап 3: 70%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▋ | 70/100 [00:00<00:00, 92.58it/s]\u001b[A\n",
|
||||||
|
"Этап 3: 80%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▊ | 80/100 [00:00<00:00, 93.01it/s]\u001b[A\n",
|
||||||
|
"Этап 3: 90%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▉ | 90/100 [00:00<00:00, 93.08it/s]\u001b[A\n",
|
||||||
|
"Этап 3: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 91.88it/s]\u001b[A\n",
|
||||||
|
"Общий прогресс: 60%|█████████████████████████████████████████████████████████████████████████████████████████████████████████▌ | 3/5 [00:03<00:02, 1.08s/it]\u001b[A\n",
|
||||||
|
"Этап 4: 0%| | 0/100 [00:00<?, ?it/s]\u001b[A\n",
|
||||||
|
"Этап 4: 10%|██████████████████ | 10/100 [00:00<00:00, 94.63it/s]\u001b[A\n",
|
||||||
|
"Этап 4: 20%|████████████████████████████████████▏ | 20/100 [00:00<00:00, 93.68it/s]\u001b[A\n",
|
||||||
|
"Этап 4: 30%|██████████████████████████████████████████████████████▎ | 30/100 [00:00<00:00, 93.20it/s]\u001b[A\n",
|
||||||
|
"Этап 4: 40%|████████████████████████████████████████████████████████████████████████▍ | 40/100 [00:00<00:00, 92.15it/s]\u001b[A\n",
|
||||||
|
"Этап 4: 50%|██████████████████████████████████████████████████████████████████████████████████████████▌ | 50/100 [00:00<00:00, 92.53it/s]\u001b[A\n",
|
||||||
|
"Этап 4: 60%|████████████████████████████████████████████████████████████████████████████████████████████████████████████▌ | 60/100 [00:00<00:00, 92.56it/s]\u001b[A\n",
|
||||||
|
"Этап 4: 70%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▋ | 70/100 [00:00<00:00, 92.67it/s]\u001b[A\n",
|
||||||
|
"Этап 4: 80%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▊ | 80/100 [00:00<00:00, 92.54it/s]\u001b[A\n",
|
||||||
|
"Этап 4: 90%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▉ | 90/100 [00:00<00:00, 92.48it/s]\u001b[A\n",
|
||||||
|
"Этап 4: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 92.38it/s]\u001b[A\n",
|
||||||
|
"Общий прогресс: 80%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▊ | 4/5 [00:04<00:01, 1.08s/it]\u001b[A\n",
|
||||||
|
"Этап 5: 0%| | 0/100 [00:00<?, ?it/s]\u001b[A\n",
|
||||||
|
"Этап 5: 10%|██████████████████ | 10/100 [00:00<00:00, 93.30it/s]\u001b[A\n",
|
||||||
|
"Этап 5: 20%|████████████████████████████████████▏ | 20/100 [00:00<00:00, 92.38it/s]\u001b[A\n",
|
||||||
|
"Этап 5: 30%|██████████████████████████████████████████████████████▎ | 30/100 [00:00<00:00, 92.08it/s]\u001b[A\n",
|
||||||
|
"Этап 5: 40%|████████████████████████████████████████████████████████████████████████▍ | 40/100 [00:00<00:00, 92.83it/s]\u001b[A\n",
|
||||||
|
"Этап 5: 50%|██████████████████████████████████████████████████████████████████████████████████████████▌ | 50/100 [00:00<00:00, 92.51it/s]\u001b[A\n",
|
||||||
|
"Этап 5: 60%|████████████████████████████████████████████████████████████████████████████████████████████████████████████▌ | 60/100 [00:00<00:00, 92.76it/s]\u001b[A\n",
|
||||||
|
"Этап 5: 70%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▋ | 70/100 [00:00<00:00, 92.60it/s]\u001b[A\n",
|
||||||
|
"Этап 5: 80%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▊ | 80/100 [00:00<00:00, 92.75it/s]\u001b[A\n",
|
||||||
|
"Этап 5: 90%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▉ | 90/100 [00:00<00:00, 93.10it/s]\u001b[A\n",
|
||||||
|
"Этап 5: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 100/100 [00:01<00:00, 92.48it/s]\u001b[A\n",
|
||||||
|
"Общий прогресс: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 5/5 [00:05<00:00, 1.08s/it]\u001b[A\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"import pandas as pd\n",
|
||||||
|
"import numpy as np\n",
|
||||||
|
"from tqdm import tqdm\n",
|
||||||
|
"import time\n",
|
||||||
|
"\n",
|
||||||
|
"# 1. Подготовка данных (создаем DataFrame на 1000 строк)\n",
|
||||||
|
"df = pd.DataFrame({\n",
|
||||||
|
" 'ID': range(1000),\n",
|
||||||
|
" 'Data': np.random.randn(1000)\n",
|
||||||
|
"})\n",
|
||||||
|
"\n",
|
||||||
|
"print(\"Запуск обработки данных с tqdm...\")\n",
|
||||||
|
"\n",
|
||||||
|
"# 2. Использование tqdm для итерации по DataFrame (iterrows)\n",
|
||||||
|
"# Добавляем кастомную стилизацию через аргументы:\n",
|
||||||
|
"# desc — описание процесса\n",
|
||||||
|
"# unit — единица измерения\n",
|
||||||
|
"# colour — цвет бара (поддерживается в современных терминалах/ноутбуках)\n",
|
||||||
|
"for index, row in tqdm(df.iterrows(), \n",
|
||||||
|
" total=df.shape[0], \n",
|
||||||
|
" desc=\"Обработка строк\", \n",
|
||||||
|
" unit=\"row\", \n",
|
||||||
|
" colour=\"green\"):\n",
|
||||||
|
" \n",
|
||||||
|
" # Симуляция сложной обработки данных\n",
|
||||||
|
" time.sleep(0.005) \n",
|
||||||
|
" _ = row['Data'] ** 2\n",
|
||||||
|
"\n",
|
||||||
|
"print(\"\\nОбработка завершена!\")\n",
|
||||||
|
"\n",
|
||||||
|
"# 3. Пример с вложенным циклом и кастомным описанием\n",
|
||||||
|
"for i in tqdm(range(5), desc=\"Общий прогресс\", position=0):\n",
|
||||||
|
" for j in tqdm(range(100), desc=f\"Этап {i+1}\", position=1, leave=False):\n",
|
||||||
|
" time.sleep(0.01)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "991a6680-77de-40b0-a078-c595653cc3ed",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3 (ipykernel)",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.13.5"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user