AIM-PIbd-32-Katysheva-N-E/lab_1/lab1.ipynb
2024-09-13 23:22:35 +04:00

8.9 KiB

Начало лабораборной

Выгрузка данных из csv файла в датафрейм

In [8]:
import pandas as pd
import numpy as np
import matplotlib.dates as md

df = pd.read_csv("..//..//static//csv//StudentsPerformance.csv")
print (df.columns)
Index(['gender', 'race/ethnicity', 'parental level of education', 'lunch',
       'test preparation course', 'math score', 'reading score',
       'writing score'],
      dtype='object')
In [10]:
df.index(2)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[10], line 1
----> 1 df.index(2)

TypeError: 'RangeIndex' object is not callable
In [3]:
df.plot.hist(column=["math score"], bins=80)
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[3], line 1
----> 1 df.plot.hist(column=["math score"], bins=80)

File c:\Users\Наталья\Desktop\5semestr\AIM\aimenv\Lib\site-packages\pandas\plotting\_core.py:1409, in PlotAccessor.hist(self, by, bins, **kwargs)
   1349 def hist(
   1350     self, by: IndexLabel | None = None, bins: int = 10, **kwargs
   1351 ) -> PlotAccessor:
   1352     """
   1353     Draw one histogram of the DataFrame's columns.
   1354 
   (...)
   1407         >>> ax = df.plot.hist(column=["age"], by="gender", figsize=(10, 8))
   1408     """
-> 1409     return self(kind="hist", by=by, bins=bins, **kwargs)

File c:\Users\Наталья\Desktop\5semestr\AIM\aimenv\Lib\site-packages\pandas\plotting\_core.py:947, in PlotAccessor.__call__(self, *args, **kwargs)
    946 def __call__(self, *args, **kwargs):
--> 947     plot_backend = _get_plot_backend(kwargs.pop("backend", None))
    949     x, y, kind, kwargs = self._get_call_args(
    950         plot_backend.__name__, self._parent, args, kwargs
    951     )
    953     kind = self._kind_aliases.get(kind, kind)

File c:\Users\Наталья\Desktop\5semestr\AIM\aimenv\Lib\site-packages\pandas\plotting\_core.py:1944, in _get_plot_backend(backend)
   1941 if backend_str in _backends:
   1942     return _backends[backend_str]
-> 1944 module = _load_backend(backend_str)
   1945 _backends[backend_str] = module
   1946 return module

File c:\Users\Наталья\Desktop\5semestr\AIM\aimenv\Lib\site-packages\pandas\plotting\_core.py:1874, in _load_backend(backend)
   1872         module = importlib.import_module("pandas.plotting._matplotlib")
   1873     except ImportError:
-> 1874         raise ImportError(
   1875             "matplotlib is required for plotting when the "
   1876             'default backend "matplotlib" is selected.'
   1877         ) from None
   1878     return module
   1880 found_backend = False

ImportError: matplotlib is required for plotting when the default backend "matplotlib" is selected.