всё ещё балуюсь

This commit is contained in:
revengel66 2024-09-13 23:22:35 +04:00
parent da8f00a7a7
commit 3b82c638b1

View File

@ -11,7 +11,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": 8,
"metadata": {},
"outputs": [
{
@ -27,6 +27,8 @@
],
"source": [
"import pandas as pd\n",
"import numpy as np\n",
"import matplotlib.dates as md\n",
"\n",
"df = pd.read_csv(\"..//..//static//csv//StudentsPerformance.csv\")\n",
"print (df.columns)"
@ -34,53 +36,49 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"<class 'pandas.core.frame.DataFrame'>\n",
"RangeIndex: 1000 entries, 0 to 999\n",
"Data columns (total 8 columns):\n",
" # Column Non-Null Count Dtype \n",
"--- ------ -------------- ----- \n",
" 0 gender 1000 non-null object\n",
" 1 race/ethnicity 1000 non-null object\n",
" 2 parental level of education 1000 non-null object\n",
" 3 lunch 1000 non-null object\n",
" 4 test preparation course 1000 non-null object\n",
" 5 math score 1000 non-null int64 \n",
" 6 reading score 1000 non-null int64 \n",
" 7 writing score 1000 non-null int64 \n",
"dtypes: int64(3), object(5)\n",
"memory usage: 62.6+ KB\n"
"ename": "TypeError",
"evalue": "'RangeIndex' object is not callable",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[1;32mIn[10], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43mdf\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mindex\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m2\u001b[39;49m\u001b[43m)\u001b[49m\n",
"\u001b[1;31mTypeError\u001b[0m: 'RangeIndex' object is not callable"
]
}
],
"source": [
"df.info()"
"df.index(2)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
" count mean std min 25% 50% 75% max\n",
"math score 1000.0 66.089 15.163080 0.0 57.00 66.0 77.0 100.0\n",
"reading score 1000.0 69.169 14.600192 17.0 59.00 70.0 79.0 100.0\n",
"writing score 1000.0 68.054 15.195657 10.0 57.75 69.0 79.0 100.0\n"
"ename": "ImportError",
"evalue": "matplotlib is required for plotting when the default backend \"matplotlib\" is selected.",
"output_type": "error",
"traceback": [
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[1;31mImportError\u001b[0m Traceback (most recent call last)",
"Cell \u001b[1;32mIn[3], line 1\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[43mdf\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mplot\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mhist\u001b[49m\u001b[43m(\u001b[49m\u001b[43mcolumn\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mmath score\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mbins\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;241;43m80\u001b[39;49m\u001b[43m)\u001b[49m\n",
"File \u001b[1;32mc:\\Users\\Наталья\\Desktop\\5semestr\\AIM\\aimenv\\Lib\\site-packages\\pandas\\plotting\\_core.py:1409\u001b[0m, in \u001b[0;36mPlotAccessor.hist\u001b[1;34m(self, by, bins, **kwargs)\u001b[0m\n\u001b[0;32m 1349\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mhist\u001b[39m(\n\u001b[0;32m 1350\u001b[0m \u001b[38;5;28mself\u001b[39m, by: IndexLabel \u001b[38;5;241m|\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mNone\u001b[39;00m, bins: \u001b[38;5;28mint\u001b[39m \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m10\u001b[39m, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs\n\u001b[0;32m 1351\u001b[0m ) \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m>\u001b[39m PlotAccessor:\n\u001b[0;32m 1352\u001b[0m \u001b[38;5;250m \u001b[39m\u001b[38;5;124;03m\"\"\"\u001b[39;00m\n\u001b[0;32m 1353\u001b[0m \u001b[38;5;124;03m Draw one histogram of the DataFrame's columns.\u001b[39;00m\n\u001b[0;32m 1354\u001b[0m \n\u001b[1;32m (...)\u001b[0m\n\u001b[0;32m 1407\u001b[0m \u001b[38;5;124;03m >>> ax = df.plot.hist(column=[\"age\"], by=\"gender\", figsize=(10, 8))\u001b[39;00m\n\u001b[0;32m 1408\u001b[0m \u001b[38;5;124;03m \"\"\"\u001b[39;00m\n\u001b[1;32m-> 1409\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;28;43mself\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mkind\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mhist\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mby\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mby\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mbins\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mbins\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n",
"File \u001b[1;32mc:\\Users\\Наталья\\Desktop\\5semestr\\AIM\\aimenv\\Lib\\site-packages\\pandas\\plotting\\_core.py:947\u001b[0m, in \u001b[0;36mPlotAccessor.__call__\u001b[1;34m(self, *args, **kwargs)\u001b[0m\n\u001b[0;32m 946\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21m__call__\u001b[39m(\u001b[38;5;28mself\u001b[39m, \u001b[38;5;241m*\u001b[39margs, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs):\n\u001b[1;32m--> 947\u001b[0m plot_backend \u001b[38;5;241m=\u001b[39m \u001b[43m_get_plot_backend\u001b[49m\u001b[43m(\u001b[49m\u001b[43mkwargs\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mpop\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mbackend\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;28;43;01mNone\u001b[39;49;00m\u001b[43m)\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 949\u001b[0m x, y, kind, kwargs \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_get_call_args(\n\u001b[0;32m 950\u001b[0m plot_backend\u001b[38;5;241m.\u001b[39m\u001b[38;5;18m__name__\u001b[39m, \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_parent, args, kwargs\n\u001b[0;32m 951\u001b[0m )\n\u001b[0;32m 953\u001b[0m kind \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39m_kind_aliases\u001b[38;5;241m.\u001b[39mget(kind, kind)\n",
"File \u001b[1;32mc:\\Users\\Наталья\\Desktop\\5semestr\\AIM\\aimenv\\Lib\\site-packages\\pandas\\plotting\\_core.py:1944\u001b[0m, in \u001b[0;36m_get_plot_backend\u001b[1;34m(backend)\u001b[0m\n\u001b[0;32m 1941\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m backend_str \u001b[38;5;129;01min\u001b[39;00m _backends:\n\u001b[0;32m 1942\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m _backends[backend_str]\n\u001b[1;32m-> 1944\u001b[0m module \u001b[38;5;241m=\u001b[39m \u001b[43m_load_backend\u001b[49m\u001b[43m(\u001b[49m\u001b[43mbackend_str\u001b[49m\u001b[43m)\u001b[49m\n\u001b[0;32m 1945\u001b[0m _backends[backend_str] \u001b[38;5;241m=\u001b[39m module\n\u001b[0;32m 1946\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m module\n",
"File \u001b[1;32mc:\\Users\\Наталья\\Desktop\\5semestr\\AIM\\aimenv\\Lib\\site-packages\\pandas\\plotting\\_core.py:1874\u001b[0m, in \u001b[0;36m_load_backend\u001b[1;34m(backend)\u001b[0m\n\u001b[0;32m 1872\u001b[0m module \u001b[38;5;241m=\u001b[39m importlib\u001b[38;5;241m.\u001b[39mimport_module(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mpandas.plotting._matplotlib\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m 1873\u001b[0m \u001b[38;5;28;01mexcept\u001b[39;00m \u001b[38;5;167;01mImportError\u001b[39;00m:\n\u001b[1;32m-> 1874\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mImportError\u001b[39;00m(\n\u001b[0;32m 1875\u001b[0m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mmatplotlib is required for plotting when the \u001b[39m\u001b[38;5;124m\"\u001b[39m\n\u001b[0;32m 1876\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mdefault backend \u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mmatplotlib\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m is selected.\u001b[39m\u001b[38;5;124m'\u001b[39m\n\u001b[0;32m 1877\u001b[0m ) \u001b[38;5;28;01mfrom\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m\n\u001b[0;32m 1878\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m module\n\u001b[0;32m 1880\u001b[0m found_backend \u001b[38;5;241m=\u001b[39m \u001b[38;5;28;01mFalse\u001b[39;00m\n",
"\u001b[1;31mImportError\u001b[0m: matplotlib is required for plotting when the default backend \"matplotlib\" is selected."
]
}
],
"source": [
"print(df.describe().transpose())"
"\n",
"df.plot.hist(column=[\"math score\"], bins=80)"
]
}
],