{ "cells": [ { "cell_type": "markdown", "metadata": { "id": "ojlhGzdxhkwR" }, "source": [ "# Pandas. Загрузка библиотек" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "xChor81V6mtD" }, "outputs": [], "source": [ "## Описание и загрузка библиотеки" ] }, { "cell_type": "markdown", "metadata": { "id": "Z22T_R766hsO" }, "source": [ " - Pandas - библиотека для обработки и анализа данных. Предназначена для данных разной природы - матричных, панельных данных, временных рядов. Претендует на звание самого мощного и гибкого средства для анализа данных с открытым исходным кодом." ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "id": "DqYWosnHhkwU" }, "outputs": [], "source": [ "import pandas as pd # Загружаем модуль pandas" ] }, { "cell_type": "markdown", "metadata": { "id": "ZNKpaic1hkwb" }, "source": [ "В пандас есть две структуры данных:\n", "- Series: одномерный массив с именованными индексами (чаще всего, данные одного типа)\n", "- DataFrame: двухмерный массив, имеет табличную структуру, легко изменяется по размерам, может содержать в себе данные разных типов\n", "\n", "Оба типа можно создавать вручную с помощью функций из самой библиотеки:\n", "- pandas.Series(data=None, index=None, dtype=None)\n", "- pandas.DataFrame(data=None, index=None, columns=None, dtype=None)\n", "\n", "- **data** - данные, которые надо записать в структуру\n", "- **index** - индексы строк\n", "- **columns** - названия столбцов\n", "- **dtype** - тип данных\n", "\n", "Кроме data, остальные параметры опциональны\n" ] }, { "cell_type": "markdown", "metadata": { "id": "tMHOWBBWhkwf" }, "source": [ "Мы, конечно, можем сами создавать датафреймы!\n", "\n", "Например, кто-то нашел нам кусок данных и просит воспроизвести этот датасет:\n", "\n", "\n", "\n", "Давайте разберемся, что здесь, что и запишем в известную нам конструкцию - листы. " ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "id": "9yW-A-fRhkwi" }, "outputs": [], "source": [ "columns = ['country', 'province', 'region_1', 'region_2'] # Создаем список, в котором будут храниться названия столбцов\n", "index = [0, 1, 10, 100] # Создаем список, в котором будут индексы строк\n", "\n", "# Создаем список с данными, каждая строка таблицы - отдельный список\n", "data = [['Italy', 'Sicily & Sardinia', 'Etna', 'NaN'], \n", " ['Portugal', 'Douro', 'NaN', 'NaN'],\n", " ['US', 'California', 'Napa Valley', 'Napa'],\n", " ['US', 'New York', 'Finger Lakes', 'Finger Lakes']]" ] }, { "cell_type": "markdown", "metadata": { "id": "6jUo7y0uhkwo" }, "source": [ "А теперь соберем в датафрейм" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 173 }, "id": "jMEdfOOdhkwp", "outputId": "b5fae3e6-3e8d-4297-d468-0be74894b070", "scrolled": true }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
countryprovinceregion_1region_2
0ItalySicily & SardiniaEtnaNaN
1PortugalDouroNaNNaN
10USCaliforniaNapa ValleyNapa
100USNew YorkFinger LakesFinger Lakes
\n", "
" ], "text/plain": [ " country province region_1 region_2\n", "0 Italy Sicily & Sardinia Etna NaN\n", "1 Portugal Douro NaN NaN\n", "10 US California Napa Valley Napa\n", "100 US New York Finger Lakes Finger Lakes" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df = pd.DataFrame(data, columns = columns, index = index) # Создаем ДатаФрейм (в качестве параметров передаем называние столбцов, индексы и сами данные)\n", "df # Отображаем наш ДатаФрейм (лучше без использования функции print())" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "id": "TIJhU5vEhkwv" }, "outputs": [], "source": [ "## Загрузка и запись данных" ] }, { "cell_type": "markdown", "metadata": { "id": "CjIlX-Ar6vd7" }, "source": [ "\n", "- Функции типа **pd.read_формат** и **pd.to_формат**\n", "считывают и записывают данные соответственно.
Полный список можно найти в документации:\n", "https://pandas.pydata.org/pandas-docs/stable/user_guide/io.html\n", "\n", "Научимся считывать данные в формате csv (comma separated value) функцией:\n", "\n", "- pd.read_csv(): \n", "\n", "Аргументов у нее очень много, критически важные:\n", " - **filepath_or_buffer** - текстовая строка с названием (адресом) файла\n", " - **sep** - разделитель между данными\n", " - **header** - номер строки, в которой в файле указаны названия столбцов, None, если нет\n", " - **names** - список с названиями колонок\n", " - **index_col** - или номер столбца, или список, или ничего - колонка, из которой надо взять названия строк" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "id": "mWdKBTMNhkwx" }, "outputs": [], "source": [ "data = pd.read_csv('wine_base.csv') # С помощью метода read_csv загружаем файл wine_base.csv и записываем данные в data" ] }, { "cell_type": "markdown", "metadata": { "id": "g8zunGkmhkw2" }, "source": [ "**Смотрим, что загрузилось**\n" ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 204 }, "id": "slhGLHJNhkw4", "outputId": "58af12df-d33f-4a2a-e3f6-5a763ba68831" }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
Unnamed: 0countrydescriptiondesignationpointspriceprovinceregion_1region_2varietywinery
150925150925ItalyMany people feel Fiano represents southern Ita...NaN9120.0Southern ItalyFiano di AvellinoNaNWhite BlendFeudi di San Gregorio
150926150926FranceOffers an intriguing nose with ginger, lime an...Cuvée Prestige9127.0ChampagneChampagneNaNChampagne BlendH.Germain
150927150927ItalyThis classic example comes from a cru vineyard...Terre di Dora9120.0Southern ItalyFiano di AvellinoNaNWhite BlendTerredora
150928150928FranceA perfect salmon shade, with scents of peaches...Grand Brut Rosé9052.0ChampagneChampagneNaNChampagne BlendGosset
150929150929ItalyMore Pinot Grigios should taste like this. A r...NaN9015.0Northeastern ItalyAlto AdigeNaNPinot GrigioAlois Lageder
\n", "
" ], "text/plain": [ " Unnamed: 0 country description \\\n", "150925 150925 Italy Many people feel Fiano represents southern Ita... \n", "150926 150926 France Offers an intriguing nose with ginger, lime an... \n", "150927 150927 Italy This classic example comes from a cru vineyard... \n", "150928 150928 France A perfect salmon shade, with scents of peaches... \n", "150929 150929 Italy More Pinot Grigios should taste like this. A r... \n", "\n", " designation points price province region_1 \\\n", "150925 NaN 91 20.0 Southern Italy Fiano di Avellino \n", "150926 Cuvée Prestige 91 27.0 Champagne Champagne \n", "150927 Terre di Dora 91 20.0 Southern Italy Fiano di Avellino \n", "150928 Grand Brut Rosé 90 52.0 Champagne Champagne \n", "150929 NaN 90 15.0 Northeastern Italy Alto Adige \n", "\n", " region_2 variety winery \n", "150925 NaN White Blend Feudi di San Gregorio \n", "150926 NaN Champagne Blend H.Germain \n", "150927 NaN White Blend Terredora \n", "150928 NaN Champagne Blend Gosset \n", "150929 NaN Pinot Grigio Alois Lageder " ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.tail() # С помощью метода head выводим первые 5 строк нашего ДатаФрейма" ] }, { "cell_type": "markdown", "metadata": { "id": "TAEcUwXohkw9" }, "source": [ "Что-то не то с первым столбцом, немного поправим" ] }, { "cell_type": "code", "execution_count": 18, "metadata": { "id": "UQ_ne0wIhkw-" }, "outputs": [], "source": [ "data = pd.read_csv('wine_base.csv', index_col = 0) # В параметре index_col указываем столбец, который будет использоваться как индекс нашего датафрейма" ] }, { "cell_type": "code", "execution_count": 19, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 924 }, "id": "u5iBpJ0jhkxC", "outputId": "b8c9ab01-2747-467a-e833-870c9d83d11b", "scrolled": true }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
countrydescriptiondesignationpointspriceprovinceregion_1region_2varietywinery
0USThis tremendous 100% varietal wine hails from ...Martha's Vineyard96235.0CaliforniaNapa ValleyNapaCabernet SauvignonHeitz
1SpainRipe aromas of fig, blackberry and cassis are ...Carodorum Selección Especial Reserva96110.0Northern SpainToroNaNTinta de ToroBodega Carmen Rodríguez
2USMac Watson honors the memory of a wine once ma...Special Selected Late Harvest9690.0CaliforniaKnights ValleySonomaSauvignon BlancMacauley
3USThis spent 20 months in 30% new French oak, an...Reserve9665.0OregonWillamette ValleyWillamette ValleyPinot NoirPonzi
4FranceThis is the top wine from La Bégude, named aft...La Brûlade9566.0ProvenceBandolNaNProvence red blendDomaine de la Bégude
5SpainDeep, dense and pure from the opening bell, th...Numanthia9573.0Northern SpainToroNaNTinta de ToroNumanthia
6SpainSlightly gritty black-fruit aromas include a s...San Román9565.0Northern SpainToroNaNTinta de ToroMaurodos
7SpainLush cedary black-fruit aromas are luxe and of...Carodorum Único Crianza95110.0Northern SpainToroNaNTinta de ToroBodega Carmen Rodríguez
8USThis re-named vineyard was formerly bottled as...Silice9565.0OregonChehalem MountainsWillamette ValleyPinot NoirBergström
9USThe producer sources from two blocks of the vi...Gap's Crown Vineyard9560.0CaliforniaSonoma CoastSonomaPinot NoirBlue Farm
10ItalyElegance, complexity and structure come togeth...Ronco della Chiesa9580.0Northeastern ItalyCollioNaNFriulanoBorgo del Tiglio
11USFrom 18-year-old vines, this supple well-balan...Estate Vineyard Wadensvil Block9548.0OregonRibbon RidgeWillamette ValleyPinot NoirPatricia Green Cellars
12USA standout even in this terrific lineup of 201...Weber Vineyard9548.0OregonDundee HillsWillamette ValleyPinot NoirPatricia Green Cellars
13FranceThis wine is in peak condition. The tannins an...Château Montus Prestige9590.0Southwest FranceMadiranNaNTannatVignobles Brumont
14USWith its sophisticated mix of mineral, acid an...Grace Vineyard95185.0OregonDundee HillsWillamette ValleyPinot NoirDomaine Serene
15USFirst made in 2006, this succulent luscious Ch...Sigrid9590.0OregonWillamette ValleyWillamette ValleyChardonnayBergström
16USThis blockbuster, powerhouse of a wine suggest...Rainin Vineyard95325.0CaliforniaDiamond Mountain DistrictNapaCabernet SauvignonHall
17SpainNicely oaked blackberry, licorice, vanilla and...6 Años Reserva Premium9580.0Northern SpainRibera del DueroNaNTempranilloValduero
18FranceComing from a seven-acre vineyard named after ...Le Pigeonnier95290.0Southwest FranceCahorsNaNMalbecChâteau Lagrézette
19USThis fresh and lively medium-bodied wine is be...Gap's Crown Vineyard9575.0CaliforniaSonoma CoastSonomaPinot NoirGary Farrell
\n", "
" ], "text/plain": [ " country description \\\n", "0 US This tremendous 100% varietal wine hails from ... \n", "1 Spain Ripe aromas of fig, blackberry and cassis are ... \n", "2 US Mac Watson honors the memory of a wine once ma... \n", "3 US This spent 20 months in 30% new French oak, an... \n", "4 France This is the top wine from La Bégude, named aft... \n", "5 Spain Deep, dense and pure from the opening bell, th... \n", "6 Spain Slightly gritty black-fruit aromas include a s... \n", "7 Spain Lush cedary black-fruit aromas are luxe and of... \n", "8 US This re-named vineyard was formerly bottled as... \n", "9 US The producer sources from two blocks of the vi... \n", "10 Italy Elegance, complexity and structure come togeth... \n", "11 US From 18-year-old vines, this supple well-balan... \n", "12 US A standout even in this terrific lineup of 201... \n", "13 France This wine is in peak condition. The tannins an... \n", "14 US With its sophisticated mix of mineral, acid an... \n", "15 US First made in 2006, this succulent luscious Ch... \n", "16 US This blockbuster, powerhouse of a wine suggest... \n", "17 Spain Nicely oaked blackberry, licorice, vanilla and... \n", "18 France Coming from a seven-acre vineyard named after ... \n", "19 US This fresh and lively medium-bodied wine is be... \n", "\n", " designation points price province \\\n", "0 Martha's Vineyard 96 235.0 California \n", "1 Carodorum Selección Especial Reserva 96 110.0 Northern Spain \n", "2 Special Selected Late Harvest 96 90.0 California \n", "3 Reserve 96 65.0 Oregon \n", "4 La Brûlade 95 66.0 Provence \n", "5 Numanthia 95 73.0 Northern Spain \n", "6 San Román 95 65.0 Northern Spain \n", "7 Carodorum Único Crianza 95 110.0 Northern Spain \n", "8 Silice 95 65.0 Oregon \n", "9 Gap's Crown Vineyard 95 60.0 California \n", "10 Ronco della Chiesa 95 80.0 Northeastern Italy \n", "11 Estate Vineyard Wadensvil Block 95 48.0 Oregon \n", "12 Weber Vineyard 95 48.0 Oregon \n", "13 Château Montus Prestige 95 90.0 Southwest France \n", "14 Grace Vineyard 95 185.0 Oregon \n", "15 Sigrid 95 90.0 Oregon \n", "16 Rainin Vineyard 95 325.0 California \n", "17 6 Años Reserva Premium 95 80.0 Northern Spain \n", "18 Le Pigeonnier 95 290.0 Southwest France \n", "19 Gap's Crown Vineyard 95 75.0 California \n", "\n", " region_1 region_2 variety \\\n", "0 Napa Valley Napa Cabernet Sauvignon \n", "1 Toro NaN Tinta de Toro \n", "2 Knights Valley Sonoma Sauvignon Blanc \n", "3 Willamette Valley Willamette Valley Pinot Noir \n", "4 Bandol NaN Provence red blend \n", "5 Toro NaN Tinta de Toro \n", "6 Toro NaN Tinta de Toro \n", "7 Toro NaN Tinta de Toro \n", "8 Chehalem Mountains Willamette Valley Pinot Noir \n", "9 Sonoma Coast Sonoma Pinot Noir \n", "10 Collio NaN Friulano \n", "11 Ribbon Ridge Willamette Valley Pinot Noir \n", "12 Dundee Hills Willamette Valley Pinot Noir \n", "13 Madiran NaN Tannat \n", "14 Dundee Hills Willamette Valley Pinot Noir \n", "15 Willamette Valley Willamette Valley Chardonnay \n", "16 Diamond Mountain District Napa Cabernet Sauvignon \n", "17 Ribera del Duero NaN Tempranillo \n", "18 Cahors NaN Malbec \n", "19 Sonoma Coast Sonoma Pinot Noir \n", "\n", " winery \n", "0 Heitz \n", "1 Bodega Carmen Rodríguez \n", "2 Macauley \n", "3 Ponzi \n", "4 Domaine de la Bégude \n", "5 Numanthia \n", "6 Maurodos \n", "7 Bodega Carmen Rodríguez \n", "8 Bergström \n", "9 Blue Farm \n", "10 Borgo del Tiglio \n", "11 Patricia Green Cellars \n", "12 Patricia Green Cellars \n", "13 Vignobles Brumont \n", "14 Domaine Serene \n", "15 Bergström \n", "16 Hall \n", "17 Valduero \n", "18 Château Lagrézette \n", "19 Gary Farrell " ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.head(20) # С помощью метода head выводим первые 20 строк нашего ДатаФрейма" ] }, { "cell_type": "markdown", "metadata": { "id": "UnU4xLLzhkxG" }, "source": [ "**Информация о загруженных данных**:\n", "\n", "- Посчитаем, сколько записей\n", "- Посмотрим, какого типа данные\n", "- Проверим, есть ли пропуски" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 34 }, "id": "Z-MKWiELhkxP", "outputId": "68ca424e-83eb-4d17-d779-1ea7f1a6b4ae" }, "outputs": [ { "data": { "text/plain": [ "(150930, 10)" ] }, "execution_count": 8, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.shape # Параметр .shape (так же как и в numpy-массивах) показывает размерность нашего датафрейма" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 34 }, "id": "SEr52zb4hkxT", "outputId": "d72fe356-c89d-4d61-c62b-a64359f748d2" }, "outputs": [ { "data": { "text/plain": [ "1509300" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.size # Параметр .size (так же как и в numpy-массивах) показывает количество элементов в нашем датафрейме" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 204 }, "id": "sw8ATDX1hkxJ", "outputId": "2cfce98c-00bf-4093-8bf5-6573e0cd909f", "scrolled": true }, "outputs": [ { "data": { "text/plain": [ "country 150925\n", "description 150930\n", "designation 105195\n", "points 150930\n", "price 137235\n", "province 150925\n", "region_1 125870\n", "region_2 60953\n", "variety 150930\n", "winery 150930\n", "dtype: int64" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.count() # Метод count считает сколько всего непустых записей в каждом столбце" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 204 }, "id": "OwVkE1MKX6mW", "outputId": "9a9f1142-de9c-4ffa-e051-bb58af728151" }, "outputs": [ { "data": { "text/plain": [ "country 100\n", "description 100\n", "designation 84\n", "points 100\n", "price 96\n", "province 100\n", "region_1 92\n", "region_2 43\n", "variety 100\n", "winery 100\n", "dtype: int64" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.head(100).count() # Применим метод .count() к первым ста записям нашего датафрейма" ] }, { "cell_type": "markdown", "metadata": { "id": "5AjpVmYFhkxX" }, "source": [ "- Метод info() заодно показывает, какого типа данные в столбцах" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 306 }, "id": "G8RHx3kvhkxZ", "outputId": "cf46dd23-3acf-4d2e-c8c4-046fa7b1f8d6" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "\n", "Int64Index: 150930 entries, 0 to 150929\n", "Data columns (total 10 columns):\n", " # Column Non-Null Count Dtype \n", "--- ------ -------------- ----- \n", " 0 country 150925 non-null object \n", " 1 description 150930 non-null object \n", " 2 designation 105195 non-null object \n", " 3 points 150930 non-null int64 \n", " 4 price 137235 non-null float64\n", " 5 province 150925 non-null object \n", " 6 region_1 125870 non-null object \n", " 7 region_2 60953 non-null object \n", " 8 variety 150930 non-null object \n", " 9 winery 150930 non-null object \n", "dtypes: float64(1), int64(1), object(8)\n", "memory usage: 12.7+ MB\n" ] } ], "source": [ "data.info() # Метод .info() показывает тип каждого столбца и занимаемую память" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 204 }, "id": "cMRzYwQdhkxd", "outputId": "4afa01d4-ec65-452a-fc89-c503253c1efa" }, "outputs": [ { "data": { "text/plain": [ "country object\n", "description object\n", "designation object\n", "points int64\n", "price float64\n", "province object\n", "region_1 object\n", "region_2 object\n", "variety object\n", "winery object\n", "dtype: object" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.dtypes # Параметр .dtypes показывает просто тип каждого столбца" ] }, { "cell_type": "markdown", "metadata": { "id": "S3TniwKUhkxh" }, "source": [ "Начнем проверять на пропуски! \n", "\n", "- .isnull() - выдает табличку, где False - ячейка заполнена, True - ячейка пуста :( Ближайшая родня - isna()" ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 204 }, "id": "uq1iywLbYsxS", "outputId": "fcc31e0d-6e49-4967-ac34-d03865227b1f" }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
countrydescriptiondesignationpointspriceprovinceregion_1region_2varietywinery
0USThis tremendous 100% varietal wine hails from ...Martha's Vineyard96235.0CaliforniaNapa ValleyNapaCabernet SauvignonHeitz
1SpainRipe aromas of fig, blackberry and cassis are ...Carodorum Selección Especial Reserva96110.0Northern SpainToroNaNTinta de ToroBodega Carmen Rodríguez
2USMac Watson honors the memory of a wine once ma...Special Selected Late Harvest9690.0CaliforniaKnights ValleySonomaSauvignon BlancMacauley
3USThis spent 20 months in 30% new French oak, an...Reserve9665.0OregonWillamette ValleyWillamette ValleyPinot NoirPonzi
4FranceThis is the top wine from La Bégude, named aft...La Brûlade9566.0ProvenceBandolNaNProvence red blendDomaine de la Bégude
\n", "
" ], "text/plain": [ " country description \\\n", "0 US This tremendous 100% varietal wine hails from ... \n", "1 Spain Ripe aromas of fig, blackberry and cassis are ... \n", "2 US Mac Watson honors the memory of a wine once ma... \n", "3 US This spent 20 months in 30% new French oak, an... \n", "4 France This is the top wine from La Bégude, named aft... \n", "\n", " designation points price province \\\n", "0 Martha's Vineyard 96 235.0 California \n", "1 Carodorum Selección Especial Reserva 96 110.0 Northern Spain \n", "2 Special Selected Late Harvest 96 90.0 California \n", "3 Reserve 96 65.0 Oregon \n", "4 La Brûlade 95 66.0 Provence \n", "\n", " region_1 region_2 variety \\\n", "0 Napa Valley Napa Cabernet Sauvignon \n", "1 Toro NaN Tinta de Toro \n", "2 Knights Valley Sonoma Sauvignon Blanc \n", "3 Willamette Valley Willamette Valley Pinot Noir \n", "4 Bandol NaN Provence red blend \n", "\n", " winery \n", "0 Heitz \n", "1 Bodega Carmen Rodríguez \n", "2 Macauley \n", "3 Ponzi \n", "4 Domaine de la Bégude " ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.head() # Отобразим первые 5 строк нашего датафрейма" ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 204 }, "id": "_oxBR6lAzfgu", "outputId": "1b2f600d-ea50-4289-cfd6-976ea1526877" }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
countrydescriptiondesignationpointspriceprovinceregion_1region_2varietywinery
0FalseFalseFalseFalseFalseFalseFalseFalseFalseFalse
1FalseFalseFalseFalseFalseFalseFalseTrueFalseFalse
2FalseFalseFalseFalseFalseFalseFalseFalseFalseFalse
3FalseFalseFalseFalseFalseFalseFalseFalseFalseFalse
4FalseFalseFalseFalseFalseFalseFalseTrueFalseFalse
\n", "
" ], "text/plain": [ " country description designation points price province region_1 \\\n", "0 False False False False False False False \n", "1 False False False False False False False \n", "2 False False False False False False False \n", "3 False False False False False False False \n", "4 False False False False False False False \n", "\n", " region_2 variety winery \n", "0 False False False \n", "1 True False False \n", "2 False False False \n", "3 False False False \n", "4 True False False " ] }, "execution_count": 16, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.isna().head() # Метод .isna() вместо каждого значения подставит True (значение NaN) или False (действительное значение)" ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 204 }, "id": "ZjTn7cM5zyta", "outputId": "b3889e78-08c3-4bdf-c4ec-260d35eed9ea" }, "outputs": [ { "data": { "text/plain": [ "country 5\n", "description 0\n", "designation 45735\n", "points 0\n", "price 13695\n", "province 5\n", "region_1 25060\n", "region_2 89977\n", "variety 0\n", "winery 0\n", "dtype: int64" ] }, "execution_count": 17, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.isna().sum() # Подсчитаем количество пропусков в каждом столбце с помощью метода .sum()" ] }, { "cell_type": "code", "execution_count": 18, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 204 }, "id": "D7aHOhOGY5pe", "outputId": "ce904bd7-3087-40a2-824e-7f7047f358db" }, "outputs": [ { "data": { "text/plain": [ "country 0\n", "description 0\n", "designation 16\n", "points 0\n", "price 4\n", "province 0\n", "region_1 8\n", "region_2 57\n", "variety 0\n", "winery 0\n", "dtype: int64" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.head(100).isna().sum() # Подсчитаем количество пропусков в каждом столбце для первых ста записей" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 204 }, "id": "ZaiGPw-KY9eQ", "outputId": "3ffbc798-c5bc-4970-c6c3-1608da30afe4" }, "outputs": [ { "data": { "text/plain": [ "country 0\n", "description 0\n", "designation 16\n", "points 0\n", "price 4\n", "province 0\n", "region_1 8\n", "region_2 57\n", "variety 0\n", "winery 0\n", "dtype: int64" ] }, "execution_count": 20, "metadata": { "tags": [] }, "output_type": "execute_result" } ], "source": [ "data.isna().head(100).sum() # Подсчитаем количество пропусков в каждом столбце для первых ста записей (равнозначно предыдущей записи)" ] }, { "cell_type": "code", "execution_count": 21, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 204 }, "id": "NHeX2czDhkxi", "outputId": "9995758b-2f88-47ca-ab63-37cb364875dd" }, "outputs": [ { "data": { "text/plain": [ "country 0.000033\n", "description 0.000000\n", "designation 0.303021\n", "points 0.000000\n", "price 0.090737\n", "province 0.000033\n", "region_1 0.166037\n", "region_2 0.596151\n", "variety 0.000000\n", "winery 0.000000\n", "dtype: float64" ] }, "execution_count": 21, "metadata": {}, "output_type": "execute_result" } ], "source": [ "round(data.isna().sum() / data.shape[0], 6) # Посчитаем какую часть составляют пропуски от общего количества элементов" ] }, { "cell_type": "code", "execution_count": 24, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 34 }, "id": "tvAQTignhkxo", "outputId": "7d223855-7d97-4529-bb74-572e21ed89a2" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "174477\n" ] } ], "source": [ "proc = data.isna().sum().sum() # Подсчитаем сколько всего пропусков (во всех столбцах) в нашем датафрейме\n", "print(proc) # Отобразим количество посчитанных пропусков" ] }, { "cell_type": "code", "execution_count": 25, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 34 }, "id": "EOZz-GAPhkxr", "outputId": "b7997cfd-a292-48ff-d431-ff425d210a7c" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "11.6%\n" ] } ], "source": [ "# Переведем полученное значение в процентное отображение\n", "proc = data.isna().sum().sum() / data.size\n", "print(round(100*proc,1), '%', sep='')" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "OuW1gRtlhkxz" }, "outputs": [], "source": [ "### Как оценить пропуски визуально" ] }, { "cell_type": "code", "execution_count": 26, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 735 }, "id": "ToPE3VkWhkx1", "outputId": "6a5c7213-1a94-4823-e5cf-3d19468a890d" }, "outputs": [ { "data": { "image/png": "iVBORw0KGgoAAAANSUhEUgAABGoAAAKsCAYAAAC01luVAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAgAElEQVR4nO3de7BnWVUf8LUuGIQIMQhqrhFJ8EHUSmsJ5SNqUBw6loWSKsbEgPgq8ZHykYSYGFExiYmvkqpoqSDBIUpEByEaKtqMCPIUlGEuKGA0io805Sv4IEZ5zMkf5zT86JnbM7/f3T1nrT6fT1VX3+7f7e5z7+5z9trfvc755TRNAQAAAMD6jtY+AAAAAABmghoAAACAIgQ1AAAAAEUIagAAAACKENQAAAAAFCGoAQAAACji7ld68bqj6713NwAAcKoLF0/i/PG5tQ8DoJWbbr0xT3tNRw0AAHAwIQ3AWFfsqAHWceHiydqHwBko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+/yIuPQAqB+MuQB6Vcyp2pU6Mi55akT89PJQotM8M+Z25tcf+GVck6ZpujnmYvKWmG8Xu9TO9piI+JJlvH4l5tAsYn7o0+sy85djPnFPYj65fjsiXrt8/j+5k//8PXJ+4PPXRMSlHZJnRcS/zPkBcA/aOc6/iDnVvXG51ebWiPiBQ77ma8Ggcdv1LRHxiMy8OSI+M+b21D+7g8P4xpgXLDfFXBRdYgyvrjdExBcs1877RsST42zf13eNV8xt5T+y/D2viYgnT9P0x0OPnl2Xj+X3n/aJ0zS9LeZQ+3uW8/ummHcinxbzvf83L+f3U8IO/1ldcVymaXpzRHx9RLww5mvpzdM0/eTy2ltiHo8PmabpVXf2HzS+403T9PyYb7F/xXJNe3ZE3Hu5veynYh6758T83J8/uezPDpmvMvMDM/N3I+Kfx/zmFr+bmfc5w5e1GRXGLyK+KebbDb8v54fW/tKhX88WLeu/e0fE/16um8+MiIcs38fHxHvWjqf9Ha+PeaP9+cs1+aZ49y00T4157fHM5XPfFvN1uf1iv4iXxPy9fsU0Tb8X850pl9/2dCWnrUluz0/FvDHY+ranCG/PfZDM/N6Y71f8z2sfC1d+S3Xuejm/G8I7p2l6x7KT/P1XaFdkJZn5wJgfAP3RKx8KZ2QsazIu25CZ7zNN01sz814xb148ftkAoQHjx+1ZuoJvjojrp2n6tbWPhzsv53coffI0TZ+y9rGclZ2UPWXmq2PuzPkXax8LFPWAiPjxZZJ7W0R86crHAwBXy1Mz8yNj7lp6hkV+O8aP97D8f3hezM8GE9I0kpn/OuZ3EG79bJpLdNQAAEABmflF8e5b+C952TRN/3SN42E/xg8YRVADAAAAUES7hwkDAAAAXKsENQAAAABFCGoAAAAAihDUAAAAABQhqAEAAAAo4v8DLh0+kgrj9mMAAAAASUVORK5CYII=\n", "text/plain": [ "
" ] }, "metadata": { "needs_background": "light" }, "output_type": "display_data" } ], "source": [ "import matplotlib.pyplot as plt # Загружаем модуль matplotlib.pyplot\n", "import seaborn as sns # Загружаем модуль seaborn\n", "%matplotlib inline\n", "\n", "fig, ax = plt.subplots(figsize=(20,12)) # Создаем область под график\n", "sns_heatmap = sns.heatmap(data.isnull(), yticklabels=False, cbar=False, cmap='viridis') # Визуализируем прпуски\n", "plt.show() # Отображаем график" ] }, { "cell_type": "markdown", "metadata": { "id": "E8w2yGJ1hkx6" }, "source": [ "Что с ним делать?\n", "\n", "Выбора не очень много:
\n", "\n", "1) Удалять: \n", "- dropna(axis=0, how='any'): axis = 0 - удаляем построчно, axis = 1 выкидываем столбец; how ='any' - выкидываем, если есть хотя бы одна ячейка пустая. how = 'all' - выкидываем, если есть полностью пустая строка или столбец\n", "\n", "2) Вставлять информацию самим:\n", "- fillna() - это отдельное искусство, как заполнять. " ] }, { "cell_type": "code", "execution_count": 28, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 495 }, "id": "uZgh1E3nhkx6", "outputId": "3a6709c7-3fbc-4260-bcd9-69c47228b013" }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
countrydescriptiondesignationpointspriceprovinceregion_1region_2varietywinery
0USThis tremendous 100% varietal wine hails from ...Martha's Vineyard96235.0CaliforniaNapa ValleyNapaCabernet SauvignonHeitz
1SpainRipe aromas of fig, blackberry and cassis are ...Carodorum Selección Especial Reserva96110.0Northern SpainToroPythonTinta de ToroBodega Carmen Rodríguez
2USMac Watson honors the memory of a wine once ma...Special Selected Late Harvest9690.0CaliforniaKnights ValleySonomaSauvignon BlancMacauley
3USThis spent 20 months in 30% new French oak, an...Reserve9665.0OregonWillamette ValleyWillamette ValleyPinot NoirPonzi
4FranceThis is the top wine from La Bégude, named aft...La Brûlade9566.0ProvenceBandolPythonProvence red blendDomaine de la Bégude
5SpainDeep, dense and pure from the opening bell, th...Numanthia9573.0Northern SpainToroPythonTinta de ToroNumanthia
6SpainSlightly gritty black-fruit aromas include a s...San Román9565.0Northern SpainToroPythonTinta de ToroMaurodos
7SpainLush cedary black-fruit aromas are luxe and of...Carodorum Único Crianza95110.0Northern SpainToroPythonTinta de ToroBodega Carmen Rodríguez
8USThis re-named vineyard was formerly bottled as...Silice9565.0OregonChehalem MountainsWillamette ValleyPinot NoirBergström
9USThe producer sources from two blocks of the vi...Gap's Crown Vineyard9560.0CaliforniaSonoma CoastSonomaPinot NoirBlue Farm
\n", "
" ], "text/plain": [ " country description \\\n", "0 US This tremendous 100% varietal wine hails from ... \n", "1 Spain Ripe aromas of fig, blackberry and cassis are ... \n", "2 US Mac Watson honors the memory of a wine once ma... \n", "3 US This spent 20 months in 30% new French oak, an... \n", "4 France This is the top wine from La Bégude, named aft... \n", "5 Spain Deep, dense and pure from the opening bell, th... \n", "6 Spain Slightly gritty black-fruit aromas include a s... \n", "7 Spain Lush cedary black-fruit aromas are luxe and of... \n", "8 US This re-named vineyard was formerly bottled as... \n", "9 US The producer sources from two blocks of the vi... \n", "\n", " designation points price province \\\n", "0 Martha's Vineyard 96 235.0 California \n", "1 Carodorum Selección Especial Reserva 96 110.0 Northern Spain \n", "2 Special Selected Late Harvest 96 90.0 California \n", "3 Reserve 96 65.0 Oregon \n", "4 La Brûlade 95 66.0 Provence \n", "5 Numanthia 95 73.0 Northern Spain \n", "6 San Román 95 65.0 Northern Spain \n", "7 Carodorum Único Crianza 95 110.0 Northern Spain \n", "8 Silice 95 65.0 Oregon \n", "9 Gap's Crown Vineyard 95 60.0 California \n", "\n", " region_1 region_2 variety \\\n", "0 Napa Valley Napa Cabernet Sauvignon \n", "1 Toro Python Tinta de Toro \n", "2 Knights Valley Sonoma Sauvignon Blanc \n", "3 Willamette Valley Willamette Valley Pinot Noir \n", "4 Bandol Python Provence red blend \n", "5 Toro Python Tinta de Toro \n", "6 Toro Python Tinta de Toro \n", "7 Toro Python Tinta de Toro \n", "8 Chehalem Mountains Willamette Valley Pinot Noir \n", "9 Sonoma Coast Sonoma Pinot Noir \n", "\n", " winery \n", "0 Heitz \n", "1 Bodega Carmen Rodríguez \n", "2 Macauley \n", "3 Ponzi \n", "4 Domaine de la Bégude \n", "5 Numanthia \n", "6 Maurodos \n", "7 Bodega Carmen Rodríguez \n", "8 Bergström \n", "9 Blue Farm " ] }, "execution_count": 28, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.fillna(\"Python\").head(10) # С помощью метода .fillna() заменяем все пропуски словом Python" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "mBsHwML6hkyF" }, "outputs": [], "source": [ "### Описательные статистики\n", "\n", "Теперь посмотрим, а что содержательно у нас есть на руках. \n", "\n", "Глазами просматривать не будем, а попросим посчитать основные описательные статистики. Причем сразу все.\n", "\n", "- describe() - метод, который возвращает табличку с описательными статистиками. В таком виде считает все для числовых столбцов" ] }, { "cell_type": "code", "execution_count": 29, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 297 }, "id": "ZWz60or1hkyG", "outputId": "134781c0-28b6-4137-85d1-8376216860c6", "scrolled": true }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
pointsprice
count150930.000000137235.000000
mean87.88841833.131482
std3.22239236.322536
min80.0000004.000000
25%86.00000016.000000
50%88.00000024.000000
75%90.00000040.000000
max100.0000002300.000000
\n", "
" ], "text/plain": [ " points price\n", "count 150930.000000 137235.000000\n", "mean 87.888418 33.131482\n", "std 3.222392 36.322536\n", "min 80.000000 4.000000\n", "25% 86.000000 16.000000\n", "50% 88.000000 24.000000\n", "75% 90.000000 40.000000\n", "max 100.000000 2300.000000" ] }, "execution_count": 29, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.describe() # Отобразим описательные статистики нашего датафрейма (только числовые данные)" ] }, { "cell_type": "markdown", "metadata": { "id": "0aeamrWMhkyK" }, "source": [ "Немножко магии, и для нечисловых данные тоже будут свои описательные статистики. " ] }, { "cell_type": "code", "execution_count": 30, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 173 }, "id": "jKTF-2BHhkyK", "outputId": "244a91a6-e8b4-42a9-d464-3728bc5c3dc5", "scrolled": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
countrydescriptiondesignationprovinceregion_1region_2varietywinery
count15092515093010519515092512587060953150930150930
unique48978213062145512361863214810
topUSA little bit funky and unsettled when you pop ...ReserveCaliforniaNapa ValleyCentral CoastChardonnayWilliams Selyem
freq62397627524450862091305714482374
\n", "
" ], "text/plain": [ " country description designation \\\n", "count 150925 150930 105195 \n", "unique 48 97821 30621 \n", "top US A little bit funky and unsettled when you pop ... Reserve \n", "freq 62397 6 2752 \n", "\n", " province region_1 region_2 variety winery \n", "count 150925 125870 60953 150930 150930 \n", "unique 455 1236 18 632 14810 \n", "top California Napa Valley Central Coast Chardonnay Williams Selyem \n", "freq 44508 6209 13057 14482 374 " ] }, "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.describe(include=['O']) # # Отобразим описательные статистики нашего датафрейма ('O' - в том числе и строковые)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "-IbwBRL_hkyO" }, "outputs": [], "source": [ "### Срезы данных\n", "\n", "Допустим, нам не нужен датасет, а только определенные столбцы или строки или столбцы и строки. \n", "\n", "\n", "Как делать?\n", "Помним, что:\n", "- у столбцов есть названия\n", "- у строк есть названия\n", "- если нет названий, то они пронумерованы с нуля\n", "\n", "Основываясь на этой идее, мы начнем отбирать данные." ] }, { "cell_type": "code", "execution_count": 31, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 80 }, "id": "4uT9dn4vhkyO", "outputId": "f57acc81-2f88-41fd-ada0-028d80ed3ca7" }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
countrydescriptiondesignationpointspriceprovinceregion_1region_2varietywinery
0USThis tremendous 100% varietal wine hails from ...Martha's Vineyard96235.0CaliforniaNapa ValleyNapaCabernet SauvignonHeitz
\n", "
" ], "text/plain": [ " country description \\\n", "0 US This tremendous 100% varietal wine hails from ... \n", "\n", " designation points price province region_1 region_2 \\\n", "0 Martha's Vineyard 96 235.0 California Napa Valley Napa \n", "\n", " variety winery \n", "0 Cabernet Sauvignon Heitz " ] }, "execution_count": 31, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.head(1) # Отобразим первую строчку датафрейма" ] }, { "cell_type": "markdown", "metadata": { "id": "5b2HPHJwhkyT" }, "source": [ "#### Отбираем по столбцам. Версия 1. " ] }, { "cell_type": "code", "execution_count": 22, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 221 }, "id": "ocn9YgmnhkyZ", "outputId": "438dc10b-ff81-42d3-deea-eefa140305d5" }, "outputs": [ { "data": { "text/plain": [ "0 235.0\n", "1 110.0\n", "2 90.0\n", "3 65.0\n", "4 66.0\n", " ... \n", "150925 20.0\n", "150926 27.0\n", "150927 20.0\n", "150928 52.0\n", "150929 15.0\n", "Name: price, Length: 150930, dtype: float64" ] }, "execution_count": 22, "metadata": {}, "output_type": "execute_result" } ], "source": [ "array = data['price'] # Отобразим столбец price\n", "array" ] }, { "cell_type": "code", "execution_count": 33, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 221 }, "id": "tBeyZQLPIMIJ", "outputId": "95d6ac17-ddde-46d9-e9a8-6e265eb12085" }, "outputs": [ { "data": { "text/plain": [ "0 235.0\n", "1 110.0\n", "2 90.0\n", "3 65.0\n", "4 66.0\n", " ... \n", "150925 20.0\n", "150926 27.0\n", "150927 20.0\n", "150928 52.0\n", "150929 15.0\n", "Name: price, Length: 150930, dtype: float64" ] }, "execution_count": 33, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.price" ] }, { "cell_type": "code", "execution_count": 34, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 119 }, "id": "YVzV30CQhkyV", "outputId": "26839d1c-a250-4ec0-a388-50f50e45af89" }, "outputs": [ { "data": { "text/plain": [ "0 235.0\n", "1 110.0\n", "2 90.0\n", "3 65.0\n", "4 66.0\n", "Name: price, dtype: float64" ] }, "execution_count": 34, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.price.head() # Отобразим столбец price (альтернативные вариант)" ] }, { "cell_type": "code", "execution_count": 35, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 204 }, "id": "IDhUYDK5hkye", "outputId": "536a6bdf-0016-4faf-e984-f1bfa8d356ad" }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
pricecountry
0235.0US
1110.0Spain
290.0US
365.0US
466.0France
\n", "
" ], "text/plain": [ " price country\n", "0 235.0 US\n", "1 110.0 Spain\n", "2 90.0 US\n", "3 65.0 US\n", "4 66.0 France" ] }, "execution_count": 35, "metadata": {}, "output_type": "execute_result" } ], "source": [ "new_df = data[['price','country']].head() # Отобразим столбцы 'price' и 'country'\n", "new_df" ] }, { "cell_type": "markdown", "metadata": { "id": "Pw7bsVKPhkyg" }, "source": [ "#### Отбираем по строкам. Версия 1. " ] }, { "cell_type": "code", "execution_count": 36, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 359 }, "id": "-3ntG2CzhDyV", "outputId": "799530a2-5339-4ddf-8cbc-ef187d8a148f" }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
countrydescriptiondesignationpointspriceprovinceregion_1region_2varietywinery
10ItalyElegance, complexity and structure come togeth...Ronco della Chiesa9580.0Northeastern ItalyCollioNaNFriulanoBorgo del Tiglio
11USFrom 18-year-old vines, this supple well-balan...Estate Vineyard Wadensvil Block9548.0OregonRibbon RidgeWillamette ValleyPinot NoirPatricia Green Cellars
12USA standout even in this terrific lineup of 201...Weber Vineyard9548.0OregonDundee HillsWillamette ValleyPinot NoirPatricia Green Cellars
13FranceThis wine is in peak condition. The tannins an...Château Montus Prestige9590.0Southwest FranceMadiranNaNTannatVignobles Brumont
14USWith its sophisticated mix of mineral, acid an...Grace Vineyard95185.0OregonDundee HillsWillamette ValleyPinot NoirDomaine Serene
15USFirst made in 2006, this succulent luscious Ch...Sigrid9590.0OregonWillamette ValleyWillamette ValleyChardonnayBergström
16USThis blockbuster, powerhouse of a wine suggest...Rainin Vineyard95325.0CaliforniaDiamond Mountain DistrictNapaCabernet SauvignonHall
17SpainNicely oaked blackberry, licorice, vanilla and...6 Años Reserva Premium9580.0Northern SpainRibera del DueroNaNTempranilloValduero
18FranceComing from a seven-acre vineyard named after ...Le Pigeonnier95290.0Southwest FranceCahorsNaNMalbecChâteau Lagrézette
19USThis fresh and lively medium-bodied wine is be...Gap's Crown Vineyard9575.0CaliforniaSonoma CoastSonomaPinot NoirGary Farrell
\n", "
" ], "text/plain": [ " country description \\\n", "10 Italy Elegance, complexity and structure come togeth... \n", "11 US From 18-year-old vines, this supple well-balan... \n", "12 US A standout even in this terrific lineup of 201... \n", "13 France This wine is in peak condition. The tannins an... \n", "14 US With its sophisticated mix of mineral, acid an... \n", "15 US First made in 2006, this succulent luscious Ch... \n", "16 US This blockbuster, powerhouse of a wine suggest... \n", "17 Spain Nicely oaked blackberry, licorice, vanilla and... \n", "18 France Coming from a seven-acre vineyard named after ... \n", "19 US This fresh and lively medium-bodied wine is be... \n", "\n", " designation points price province \\\n", "10 Ronco della Chiesa 95 80.0 Northeastern Italy \n", "11 Estate Vineyard Wadensvil Block 95 48.0 Oregon \n", "12 Weber Vineyard 95 48.0 Oregon \n", "13 Château Montus Prestige 95 90.0 Southwest France \n", "14 Grace Vineyard 95 185.0 Oregon \n", "15 Sigrid 95 90.0 Oregon \n", "16 Rainin Vineyard 95 325.0 California \n", "17 6 Años Reserva Premium 95 80.0 Northern Spain \n", "18 Le Pigeonnier 95 290.0 Southwest France \n", "19 Gap's Crown Vineyard 95 75.0 California \n", "\n", " region_1 region_2 variety \\\n", "10 Collio NaN Friulano \n", "11 Ribbon Ridge Willamette Valley Pinot Noir \n", "12 Dundee Hills Willamette Valley Pinot Noir \n", "13 Madiran NaN Tannat \n", "14 Dundee Hills Willamette Valley Pinot Noir \n", "15 Willamette Valley Willamette Valley Chardonnay \n", "16 Diamond Mountain District Napa Cabernet Sauvignon \n", "17 Ribera del Duero NaN Tempranillo \n", "18 Cahors NaN Malbec \n", "19 Sonoma Coast Sonoma Pinot Noir \n", "\n", " winery \n", "10 Borgo del Tiglio \n", "11 Patricia Green Cellars \n", "12 Patricia Green Cellars \n", "13 Vignobles Brumont \n", "14 Domaine Serene \n", "15 Bergström \n", "16 Hall \n", "17 Valduero \n", "18 Château Lagrézette \n", "19 Gary Farrell " ] }, "execution_count": 36, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data[10:20] # Отобразим с 10й по 20ю строки датафрейма" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 173 }, "id": "DaW5dRU7hkyh", "outputId": "9665e0f7-f195-4217-b8a1-674700cdc917" }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
countrydescriptiondesignationpointspriceprovinceregion_1region_2varietywinery
10ItalyElegance, complexity and structure come togeth...Ronco della Chiesa9580.0Northeastern ItalyCollioNaNFriulanoBorgo del Tiglio
13FranceThis wine is in peak condition. The tannins an...Château Montus Prestige9590.0Southwest FranceMadiranNaNTannatVignobles Brumont
16USThis blockbuster, powerhouse of a wine suggest...Rainin Vineyard95325.0CaliforniaDiamond Mountain DistrictNapaCabernet SauvignonHall
19USThis fresh and lively medium-bodied wine is be...Gap's Crown Vineyard9575.0CaliforniaSonoma CoastSonomaPinot NoirGary Farrell
\n", "
" ], "text/plain": [ " country ... winery\n", "10 Italy ... Borgo del Tiglio\n", "13 France ... Vignobles Brumont\n", "16 US ... Hall\n", "19 US ... Gary Farrell\n", "\n", "[4 rows x 10 columns]" ] }, "execution_count": 34, "metadata": { "tags": [] }, "output_type": "execute_result" } ], "source": [ "data[10:20:3] # Отобразим с 10й по 20ю строки датафрейма с шагом 2" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 359 }, "id": "zXqL-lBEhGkG", "outputId": "c741c699-f40d-4417-9bb4-bc849da4f19b" }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
countrydescriptiondesignationpointspriceprovinceregion_1region_2varietywinery
0USThis tremendous 100% varietal wine hails from ...Martha's Vineyard96235.0CaliforniaNapa ValleyNapaCabernet SauvignonHeitz
5SpainDeep, dense and pure from the opening bell, th...Numanthia9573.0Northern SpainToroNaNTinta de ToroNumanthia
10ItalyElegance, complexity and structure come togeth...Ronco della Chiesa9580.0Northeastern ItalyCollioNaNFriulanoBorgo del Tiglio
15USFirst made in 2006, this succulent luscious Ch...Sigrid9590.0OregonWillamette ValleyWillamette ValleyChardonnayBergström
20USHeitz has made this stellar rosé from the rare...Grignolino9524.0CaliforniaNapa ValleyNapaRoséHeitz
25New ZealandYields were down in 2015, but intensity is up,...Maté's Vineyard9457.0KumeuNaNNaNChardonnayKumeu River
30BulgariaThis Bulgarian Mavrud presents the nose with s...Bergulé9015.0BulgariaNaNNaNMavrudVilla Melnik
35ItalyForest floor, tilled soil, mature berry and a ...Riserva90135.0TuscanyBrunello di MontalcinoNaNSangioveseCarillon
40SpainEarthy plum and cherry aromas score points for...Amandi9017.0GaliciaRibeira SacraNaNMencíaDon Bernardino
45ItalyA blend of 90% Sangiovese and 10% Canaiolo, th...Vigneto Odoardo Beccari Riserva9030.0TuscanyChianti ClassicoNaNRed BlendVignavecchia
\n", "
" ], "text/plain": [ " country ... winery\n", "0 US ... Heitz\n", "5 Spain ... Numanthia\n", "10 Italy ... Borgo del Tiglio\n", "15 US ... Bergström\n", "20 US ... Heitz\n", "25 New Zealand ... Kumeu River\n", "30 Bulgaria ... Villa Melnik\n", "35 Italy ... Carillon\n", "40 Spain ... Don Bernardino\n", "45 Italy ... Vignavecchia\n", "\n", "[10 rows x 10 columns]" ] }, "execution_count": 35, "metadata": { "tags": [] }, "output_type": "execute_result" } ], "source": [ "data[::5].head(10) # Отобразим каждую 5ю строку датафрейма" ] }, { "cell_type": "markdown", "metadata": { "id": "pV0kczWfhkyk" }, "source": [ "#### Отбор по столбцам. Версия 2. Все еще по названиям " ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 495 }, "id": "blyn4oRnJOlm", "outputId": "cc0258b0-2735-4d7f-cb92-ac9b23b2a83e" }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
countrydescriptiondesignationpointspriceprovinceregion_1region_2varietywinery
0USThis tremendous 100% varietal wine hails from ...Martha's Vineyard96235.0CaliforniaNapa ValleyNapaCabernet SauvignonHeitz
1SpainRipe aromas of fig, blackberry and cassis are ...Carodorum Selección Especial Reserva96110.0Northern SpainToroNaNTinta de ToroBodega Carmen Rodríguez
2USMac Watson honors the memory of a wine once ma...Special Selected Late Harvest9690.0CaliforniaKnights ValleySonomaSauvignon BlancMacauley
3USThis spent 20 months in 30% new French oak, an...Reserve9665.0OregonWillamette ValleyWillamette ValleyPinot NoirPonzi
4FranceThis is the top wine from La Bégude, named aft...La Brûlade9566.0ProvenceBandolNaNProvence red blendDomaine de la Bégude
5SpainDeep, dense and pure from the opening bell, th...Numanthia9573.0Northern SpainToroNaNTinta de ToroNumanthia
6SpainSlightly gritty black-fruit aromas include a s...San Román9565.0Northern SpainToroNaNTinta de ToroMaurodos
7SpainLush cedary black-fruit aromas are luxe and of...Carodorum Único Crianza95110.0Northern SpainToroNaNTinta de ToroBodega Carmen Rodríguez
8USThis re-named vineyard was formerly bottled as...Silice9565.0OregonChehalem MountainsWillamette ValleyPinot NoirBergström
9USThe producer sources from two blocks of the vi...Gap's Crown Vineyard9560.0CaliforniaSonoma CoastSonomaPinot NoirBlue Farm
\n", "
" ], "text/plain": [ " country ... winery\n", "0 US ... Heitz\n", "1 Spain ... Bodega Carmen Rodríguez\n", "2 US ... Macauley\n", "3 US ... Ponzi\n", "4 France ... Domaine de la Bégude\n", "5 Spain ... Numanthia\n", "6 Spain ... Maurodos\n", "7 Spain ... Bodega Carmen Rodríguez\n", "8 US ... Bergström\n", "9 US ... Blue Farm\n", "\n", "[10 rows x 10 columns]" ] }, "execution_count": 36, "metadata": { "tags": [] }, "output_type": "execute_result" } ], "source": [ "data.head(10)" ] }, { "cell_type": "code", "execution_count": 37, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 173 }, "id": "LfRYRSsohkyk", "outputId": "c7f8b402-bba9-4da4-eebe-6402c24030c2" }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
pricepoints
466.095
573.095
665.095
7110.095
\n", "
" ], "text/plain": [ " price points\n", "4 66.0 95\n", "5 73.0 95\n", "6 65.0 95\n", "7 110.0 95" ] }, "execution_count": 37, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.loc[4:7, ['price', 'points']] # Отобразим два столбца 'price' и 'points', и в них строки с индексами с 4 по 7" ] }, { "cell_type": "markdown", "metadata": { "id": "CK4-ntzDhkyo" }, "source": [ "#### Отбор по строкам. Версия 2. Все еще по названиям " ] }, { "cell_type": "code", "execution_count": 38, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 235 }, "id": "eqAQs0YIhkyq", "outputId": "d0bab15c-91be-41a2-ef6f-82f2faf5e702" }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
countrydescriptiondesignationpointspriceprovinceregion_1region_2varietywinery
0USThis tremendous 100% varietal wine hails from ...Martha's Vineyard96235.0CaliforniaNapa ValleyNapaCabernet SauvignonHeitz
1SpainRipe aromas of fig, blackberry and cassis are ...Carodorum Selección Especial Reserva96110.0Northern SpainToroNaNTinta de ToroBodega Carmen Rodríguez
2USMac Watson honors the memory of a wine once ma...Special Selected Late Harvest9690.0CaliforniaKnights ValleySonomaSauvignon BlancMacauley
3USThis spent 20 months in 30% new French oak, an...Reserve9665.0OregonWillamette ValleyWillamette ValleyPinot NoirPonzi
4FranceThis is the top wine from La Bégude, named aft...La Brûlade9566.0ProvenceBandolNaNProvence red blendDomaine de la Bégude
5SpainDeep, dense and pure from the opening bell, th...Numanthia9573.0Northern SpainToroNaNTinta de ToroNumanthia
\n", "
" ], "text/plain": [ " country description \\\n", "0 US This tremendous 100% varietal wine hails from ... \n", "1 Spain Ripe aromas of fig, blackberry and cassis are ... \n", "2 US Mac Watson honors the memory of a wine once ma... \n", "3 US This spent 20 months in 30% new French oak, an... \n", "4 France This is the top wine from La Bégude, named aft... \n", "5 Spain Deep, dense and pure from the opening bell, th... \n", "\n", " designation points price province \\\n", "0 Martha's Vineyard 96 235.0 California \n", "1 Carodorum Selección Especial Reserva 96 110.0 Northern Spain \n", "2 Special Selected Late Harvest 96 90.0 California \n", "3 Reserve 96 65.0 Oregon \n", "4 La Brûlade 95 66.0 Provence \n", "5 Numanthia 95 73.0 Northern Spain \n", "\n", " region_1 region_2 variety \\\n", "0 Napa Valley Napa Cabernet Sauvignon \n", "1 Toro NaN Tinta de Toro \n", "2 Knights Valley Sonoma Sauvignon Blanc \n", "3 Willamette Valley Willamette Valley Pinot Noir \n", "4 Bandol NaN Provence red blend \n", "5 Toro NaN Tinta de Toro \n", "\n", " winery \n", "0 Heitz \n", "1 Bodega Carmen Rodríguez \n", "2 Macauley \n", "3 Ponzi \n", "4 Domaine de la Bégude \n", "5 Numanthia " ] }, "execution_count": 38, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.loc[:5,:] # Отобразим строки с индексом от 0 до 5 (то же, что и data.loc[:5])" ] }, { "cell_type": "markdown", "metadata": { "id": "NGugpgJfhkyv" }, "source": [ "#### Отбор по строчкам и столбцам. Версия 3. По номеру строк и столбцов" ] }, { "cell_type": "code", "execution_count": 39, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 204 }, "id": "CG0aSTW8hkyv", "outputId": "af2503a1-524e-431c-f61e-5d0a5590a9b1", "scrolled": false }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
descriptionpoints
0This tremendous 100% varietal wine hails from ...96
5Deep, dense and pure from the opening bell, th...95
10Elegance, complexity and structure come togeth...95
15First made in 2006, this succulent luscious Ch...95
20Heitz has made this stellar rosé from the rare...95
\n", "
" ], "text/plain": [ " description points\n", "0 This tremendous 100% varietal wine hails from ... 96\n", "5 Deep, dense and pure from the opening bell, th... 95\n", "10 Elegance, complexity and structure come togeth... 95\n", "15 First made in 2006, this succulent luscious Ch... 95\n", "20 Heitz has made this stellar rosé from the rare... 95" ] }, "execution_count": 39, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.iloc[::5, [1,3]].head() # Отобразим каждую 5 строку и 1 и 3 столбец" ] }, { "cell_type": "markdown", "metadata": { "id": "sIao6149hkyy" }, "source": [ "#### Отбор с условиями\n", "\n", "Так, а если мне нужны вина дороже $15 долларов? Как быть?" ] }, { "cell_type": "code", "execution_count": 40, "metadata": { "id": "YsIrLdRnhkyy" }, "outputs": [], "source": [ "#задаем маску\n", "mask = data['price'] > 15" ] }, { "cell_type": "code", "execution_count": 41, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 119 }, "id": "nfVB6YBbhky0", "outputId": "ebfb750f-f4f2-43a3-c62b-4e39273046de" }, "outputs": [ { "data": { "text/plain": [ "0 True\n", "1 True\n", "2 True\n", "3 True\n", "4 True\n", "Name: price, dtype: bool" ] }, "execution_count": 41, "metadata": {}, "output_type": "execute_result" } ], "source": [ "mask.head() # Отобразим маску" ] }, { "cell_type": "code", "execution_count": 42, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 359 }, "id": "FADnit0Ghky2", "outputId": "16cf6881-4c3c-408e-f661-4141182143d5" }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
countrydescriptiondesignationpointspriceprovinceregion_1region_2varietywinery
0USThis tremendous 100% varietal wine hails from ...Martha's Vineyard96235.0CaliforniaNapa ValleyNapaCabernet SauvignonHeitz
1SpainRipe aromas of fig, blackberry and cassis are ...Carodorum Selección Especial Reserva96110.0Northern SpainToroNaNTinta de ToroBodega Carmen Rodríguez
2USMac Watson honors the memory of a wine once ma...Special Selected Late Harvest9690.0CaliforniaKnights ValleySonomaSauvignon BlancMacauley
3USThis spent 20 months in 30% new French oak, an...Reserve9665.0OregonWillamette ValleyWillamette ValleyPinot NoirPonzi
4FranceThis is the top wine from La Bégude, named aft...La Brûlade9566.0ProvenceBandolNaNProvence red blendDomaine de la Bégude
.................................
150924FranceReally fine for a low-acid vintage, there's an...Diamant Bleu9170.0ChampagneChampagneNaNChampagne BlendHeidsieck & Co Monopole
150925ItalyMany people feel Fiano represents southern Ita...NaN9120.0Southern ItalyFiano di AvellinoNaNWhite BlendFeudi di San Gregorio
150926FranceOffers an intriguing nose with ginger, lime an...Cuvée Prestige9127.0ChampagneChampagneNaNChampagne BlendH.Germain
150927ItalyThis classic example comes from a cru vineyard...Terre di Dora9120.0Southern ItalyFiano di AvellinoNaNWhite BlendTerredora
150928FranceA perfect salmon shade, with scents of peaches...Grand Brut Rosé9052.0ChampagneChampagneNaNChampagne BlendGosset
\n", "

103342 rows × 10 columns

\n", "
" ], "text/plain": [ " country description \\\n", "0 US This tremendous 100% varietal wine hails from ... \n", "1 Spain Ripe aromas of fig, blackberry and cassis are ... \n", "2 US Mac Watson honors the memory of a wine once ma... \n", "3 US This spent 20 months in 30% new French oak, an... \n", "4 France This is the top wine from La Bégude, named aft... \n", "... ... ... \n", "150924 France Really fine for a low-acid vintage, there's an... \n", "150925 Italy Many people feel Fiano represents southern Ita... \n", "150926 France Offers an intriguing nose with ginger, lime an... \n", "150927 Italy This classic example comes from a cru vineyard... \n", "150928 France A perfect salmon shade, with scents of peaches... \n", "\n", " designation points price province \\\n", "0 Martha's Vineyard 96 235.0 California \n", "1 Carodorum Selección Especial Reserva 96 110.0 Northern Spain \n", "2 Special Selected Late Harvest 96 90.0 California \n", "3 Reserve 96 65.0 Oregon \n", "4 La Brûlade 95 66.0 Provence \n", "... ... ... ... ... \n", "150924 Diamant Bleu 91 70.0 Champagne \n", "150925 NaN 91 20.0 Southern Italy \n", "150926 Cuvée Prestige 91 27.0 Champagne \n", "150927 Terre di Dora 91 20.0 Southern Italy \n", "150928 Grand Brut Rosé 90 52.0 Champagne \n", "\n", " region_1 region_2 variety \\\n", "0 Napa Valley Napa Cabernet Sauvignon \n", "1 Toro NaN Tinta de Toro \n", "2 Knights Valley Sonoma Sauvignon Blanc \n", "3 Willamette Valley Willamette Valley Pinot Noir \n", "4 Bandol NaN Provence red blend \n", "... ... ... ... \n", "150924 Champagne NaN Champagne Blend \n", "150925 Fiano di Avellino NaN White Blend \n", "150926 Champagne NaN Champagne Blend \n", "150927 Fiano di Avellino NaN White Blend \n", "150928 Champagne NaN Champagne Blend \n", "\n", " winery \n", "0 Heitz \n", "1 Bodega Carmen Rodríguez \n", "2 Macauley \n", "3 Ponzi \n", "4 Domaine de la Bégude \n", "... ... \n", "150924 Heidsieck & Co Monopole \n", "150925 Feudi di San Gregorio \n", "150926 H.Germain \n", "150927 Terredora \n", "150928 Gosset \n", "\n", "[103342 rows x 10 columns]" ] }, "execution_count": 42, "metadata": {}, "output_type": "execute_result" } ], "source": [ "#и отбираем данные\n", "temp = data[mask] # Выбираем данные из датафрейма в соответствии с маской и записываем их в новый даатафрейм temp\n", "temp # Отображаем temp" ] }, { "cell_type": "code", "execution_count": 43, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 204 }, "id": "EHT3VYtNhky4", "outputId": "84091e0c-6995-4d73-b63a-c69aeec6ecd4" }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
countrydescriptiondesignationpointspriceprovinceregion_1region_2varietywinery
16USThis blockbuster, powerhouse of a wine suggest...Rainin Vineyard95325.0CaliforniaDiamond Mountain DistrictNapaCabernet SauvignonHall
898ItalyAromas of crushed plum, asphalt, oak, toast, e...Sorì Tildin92500.0PiedmontLangheNaNRed BlendGaja
2145FranceFull of ripe fruit, opulent and concentrated, ...NaN100848.0BordeauxPessac-LéognanNaNBordeaux-style White BlendChâteau Haut-Brion
2155FranceThere is a sense of pure juicy black-currant f...NaN97450.0BordeauxMargauxNaNBordeaux-style Red BlendChâteau Margaux
2159FranceWith seriously dense tannins, this shows great...NaN97330.0BordeauxPessac-LéognanNaNBordeaux-style Red BlendChâteau Haut-Brion
\n", "
" ], "text/plain": [ " country description \\\n", "16 US This blockbuster, powerhouse of a wine suggest... \n", "898 Italy Aromas of crushed plum, asphalt, oak, toast, e... \n", "2145 France Full of ripe fruit, opulent and concentrated, ... \n", "2155 France There is a sense of pure juicy black-currant f... \n", "2159 France With seriously dense tannins, this shows great... \n", "\n", " designation points price province region_1 \\\n", "16 Rainin Vineyard 95 325.0 California Diamond Mountain District \n", "898 Sorì Tildin 92 500.0 Piedmont Langhe \n", "2145 NaN 100 848.0 Bordeaux Pessac-Léognan \n", "2155 NaN 97 450.0 Bordeaux Margaux \n", "2159 NaN 97 330.0 Bordeaux Pessac-Léognan \n", "\n", " region_2 variety winery \n", "16 Napa Cabernet Sauvignon Hall \n", "898 NaN Red Blend Gaja \n", "2145 NaN Bordeaux-style White Blend Château Haut-Brion \n", "2155 NaN Bordeaux-style Red Blend Château Margaux \n", "2159 NaN Bordeaux-style Red Blend Château Haut-Brion " ] }, "execution_count": 43, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data[data.price>300].head()# Альтернативный вариант" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 616 }, "id": "Moi8GwyVhky8", "outputId": "f4020760-204a-42f0-9df3-28242583e16e" }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
countrydescriptiondesignationpointspriceprovinceregion_1region_2varietywinery
0USThis tremendous 100% varietal wine hails from ...Martha's Vineyard96235.0CaliforniaNapa ValleyNapaCabernet SauvignonHeitz
16USThis blockbuster, powerhouse of a wine suggest...Rainin Vineyard95325.0CaliforniaDiamond Mountain DistrictNapaCabernet SauvignonHall
18FranceComing from a seven-acre vineyard named after ...Le Pigeonnier95290.0Southwest FranceCahorsNaNMalbecChâteau Lagrézette
2145FranceFull of ripe fruit, opulent and concentrated, ...NaN100848.0BordeauxPessac-LéognanNaNBordeaux-style White BlendChâteau Haut-Brion
2155FranceThere is a sense of pure juicy black-currant f...NaN97450.0BordeauxMargauxNaNBordeaux-style Red BlendChâteau Margaux
2159FranceWith seriously dense tannins, this shows great...NaN97330.0BordeauxPessac-LéognanNaNBordeaux-style Red BlendChâteau Haut-Brion
2434FranceWith 83% Sémillon in the blend, this wine has ...NaN97698.0BordeauxPessac-LéognanNaNBordeaux-style White BlendChâteau La Mission Haut-Brion
2673FranceAs with Clos de Vougeot in red, every producer...NaN90238.0BurgundyCorton-CharlemagneNaNChardonnayJean-Luc and Paul Aegerter
2733FranceRichly endowed, the wine is beautifully concen...NaN95202.0BordeauxPessac-LéognanNaNBordeaux-style Red BlendChâteau La Mission Haut-Brion
2742FranceThis is a powerfully structured wine from a 18...NaN95250.0BordeauxPomerolNaNBordeaux-style Red BlendChâteau Trotanoy
7796FranceThis is full of fruit and weighty tannins. Com...NaN96240.0BurgundyChambertinNaNPinot NoirDomaine Rossignol-Trapet
7798FranceInitially, this is a richly ripe wine with tro...NaN96315.0BurgundyChevalier-MontrachetNaNChardonnayBouchard Père & Fils
8071FranceRounded and rich, it is full of dark fruits an...Clos des Cortons Faiveley95225.0BurgundyCorton-RognetNaNPinot NoirDomaine Faiveley
8072FranceThis is the big one, one of the most treasured...NaN95520.0BurgundyMontrachetNaNChardonnayLouis Latour
8074FranceA small, acre-sized parcel gives a wine that h...NaN95300.0BurgundyChambertin Clos de BèzeNaNPinot NoirChanson Père et Fils
\n", "
" ], "text/plain": [ " country ... winery\n", "0 US ... Heitz\n", "16 US ... Hall\n", "18 France ... Château Lagrézette\n", "2145 France ... Château Haut-Brion\n", "2155 France ... Château Margaux\n", "2159 France ... Château Haut-Brion\n", "2434 France ... Château La Mission Haut-Brion\n", "2673 France ... Jean-Luc and Paul Aegerter\n", "2733 France ... Château La Mission Haut-Brion\n", "2742 France ... Château Trotanoy\n", "7796 France ... Domaine Rossignol-Trapet\n", "7798 France ... Bouchard Père & Fils\n", "8071 France ... Domaine Faiveley\n", "8072 France ... Louis Latour\n", "8074 France ... Chanson Père et Fils\n", "\n", "[15 rows x 10 columns]" ] }, "execution_count": 44, "metadata": { "tags": [] }, "output_type": "execute_result" } ], "source": [ "data[(data.price > 200) & ((data.country == 'US') | (data.country == 'France'))].head(15) # Составное условие" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "Da0WfR_5hky_" }, "outputs": [], "source": [ "### Мультииндексация" ] }, { "cell_type": "code", "execution_count": 44, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 204 }, "id": "gIqtjR45hky_", "outputId": "48a1fdf1-4c7f-4c3c-8e76-b9e773cb15c7" }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
countrydescriptiondesignationpointspriceprovinceregion_1region_2varietywinery
0USThis tremendous 100% varietal wine hails from ...Martha's Vineyard96235.0CaliforniaNapa ValleyNapaCabernet SauvignonHeitz
1SpainRipe aromas of fig, blackberry and cassis are ...Carodorum Selección Especial Reserva96110.0Northern SpainToroNaNTinta de ToroBodega Carmen Rodríguez
2USMac Watson honors the memory of a wine once ma...Special Selected Late Harvest9690.0CaliforniaKnights ValleySonomaSauvignon BlancMacauley
3USThis spent 20 months in 30% new French oak, an...Reserve9665.0OregonWillamette ValleyWillamette ValleyPinot NoirPonzi
4FranceThis is the top wine from La Bégude, named aft...La Brûlade9566.0ProvenceBandolNaNProvence red blendDomaine de la Bégude
\n", "
" ], "text/plain": [ " country description \\\n", "0 US This tremendous 100% varietal wine hails from ... \n", "1 Spain Ripe aromas of fig, blackberry and cassis are ... \n", "2 US Mac Watson honors the memory of a wine once ma... \n", "3 US This spent 20 months in 30% new French oak, an... \n", "4 France This is the top wine from La Bégude, named aft... \n", "\n", " designation points price province \\\n", "0 Martha's Vineyard 96 235.0 California \n", "1 Carodorum Selección Especial Reserva 96 110.0 Northern Spain \n", "2 Special Selected Late Harvest 96 90.0 California \n", "3 Reserve 96 65.0 Oregon \n", "4 La Brûlade 95 66.0 Provence \n", "\n", " region_1 region_2 variety \\\n", "0 Napa Valley Napa Cabernet Sauvignon \n", "1 Toro NaN Tinta de Toro \n", "2 Knights Valley Sonoma Sauvignon Blanc \n", "3 Willamette Valley Willamette Valley Pinot Noir \n", "4 Bandol NaN Provence red blend \n", "\n", " winery \n", "0 Heitz \n", "1 Bodega Carmen Rodríguez \n", "2 Macauley \n", "3 Ponzi \n", "4 Domaine de la Bégude " ] }, "execution_count": 44, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.head() # Отобразим наш датафрем" ] }, { "cell_type": "code", "execution_count": 46, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 1000 }, "id": "JizHrXguhkzC", "outputId": "4b793963-14d9-4f87-bb3f-b26bb14d2d8e" }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
descriptiondesignationpointsprovinceregion_1region_2varietywinery
countryprice
Albania20.020220022
Argentina4.032333033
5.091999099
6.0741974747407474
7.0611961616106161
...........................
230.022222022
250.011111011
Australia5.011011111101111
6.092999099
7.0512151515105151
\n", "

100 rows × 8 columns

\n", "
" ], "text/plain": [ " description designation points province region_1 \\\n", "country price \n", "Albania 20.0 2 0 2 2 0 \n", "Argentina 4.0 3 2 3 3 3 \n", " 5.0 9 1 9 9 9 \n", " 6.0 74 19 74 74 74 \n", " 7.0 61 19 61 61 61 \n", "... ... ... ... ... ... \n", " 230.0 2 2 2 2 2 \n", " 250.0 1 1 1 1 1 \n", "Australia 5.0 11 0 11 11 11 \n", " 6.0 9 2 9 9 9 \n", " 7.0 51 21 51 51 51 \n", "\n", " region_2 variety winery \n", "country price \n", "Albania 20.0 0 2 2 \n", "Argentina 4.0 0 3 3 \n", " 5.0 0 9 9 \n", " 6.0 0 74 74 \n", " 7.0 0 61 61 \n", "... ... ... ... \n", " 230.0 0 2 2 \n", " 250.0 0 1 1 \n", "Australia 5.0 0 11 11 \n", " 6.0 0 9 9 \n", " 7.0 0 51 51 \n", "\n", "[100 rows x 8 columns]" ] }, "execution_count": 46, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data_ = data.groupby(['country', 'price']).count() # Сграппируем данные сначала по странам, а затем по price\n", "data_.head(100) # Отобразим первые 50 строк нового датафрейма" ] }, { "cell_type": "code", "execution_count": 47, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 450 }, "id": "hE9aG1imhkzG", "outputId": "b2abe0e9-93f7-4044-e88c-844918452e52" }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
descriptiondesignationpointsprovinceregion_1region_2varietywinery
price
4.092999999
5.03316333333323333
6.05813585858585858
7.020658206206206203206206
8.0458188458458456444458458
...........................
350.050555455
450.010111111
500.032333333
625.022222222
2013.011111111
\n", "

149 rows × 8 columns

\n", "
" ], "text/plain": [ " description designation points province region_1 region_2 \\\n", "price \n", "4.0 9 2 9 9 9 9 \n", "5.0 33 16 33 33 33 32 \n", "6.0 58 13 58 58 58 58 \n", "7.0 206 58 206 206 206 203 \n", "8.0 458 188 458 458 456 444 \n", "... ... ... ... ... ... ... \n", "350.0 5 0 5 5 5 4 \n", "450.0 1 0 1 1 1 1 \n", "500.0 3 2 3 3 3 3 \n", "625.0 2 2 2 2 2 2 \n", "2013.0 1 1 1 1 1 1 \n", "\n", " variety winery \n", "price \n", "4.0 9 9 \n", "5.0 33 33 \n", "6.0 58 58 \n", "7.0 206 206 \n", "8.0 458 458 \n", "... ... ... \n", "350.0 5 5 \n", "450.0 1 1 \n", "500.0 3 3 \n", "625.0 2 2 \n", "2013.0 1 1 \n", "\n", "[149 rows x 8 columns]" ] }, "execution_count": 47, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data_.loc['US'] # Отобразим все данные для 'US'" ] }, { "cell_type": "code", "execution_count": 48, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 170 }, "id": "ZteYvkfehkzL", "outputId": "938087ed-492f-4ddf-c3f1-16ca3b38f331" }, "outputs": [ { "data": { "text/plain": [ "description 318\n", "designation 261\n", "points 318\n", "province 318\n", "region_1 318\n", "region_2 317\n", "variety 318\n", "winery 318\n", "Name: (US, 100.0), dtype: int64" ] }, "execution_count": 48, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data_.loc['US', 100] # Отобразим данные для 'US', у кого 100 points" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "6o6JX1OnhkzP" }, "outputs": [], "source": [ "#### Как изменять значения в табличке" ] }, { "cell_type": "code", "execution_count": 49, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 204 }, "id": "sVulAc0HsaLu", "outputId": "6fca9bb4-357b-4398-e509-6191a1ee9e74" }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
countrydescriptiondesignationpointspriceprovinceregion_1region_2varietywinery
0USThis tremendous 100% varietal wine hails from ...Martha's Vineyard96235.0CaliforniaNapa ValleyNapaCabernet SauvignonHeitz
1SpainRipe aromas of fig, blackberry and cassis are ...Carodorum Selección Especial Reserva96110.0Northern SpainToroNaNTinta de ToroBodega Carmen Rodríguez
2USMac Watson honors the memory of a wine once ma...Special Selected Late Harvest9690.0CaliforniaKnights ValleySonomaSauvignon BlancMacauley
3USThis spent 20 months in 30% new French oak, an...Reserve9665.0OregonWillamette ValleyWillamette ValleyPinot NoirPonzi
4FranceThis is the top wine from La Bégude, named aft...La Brûlade9566.0ProvenceBandolNaNProvence red blendDomaine de la Bégude
\n", "
" ], "text/plain": [ " country description \\\n", "0 US This tremendous 100% varietal wine hails from ... \n", "1 Spain Ripe aromas of fig, blackberry and cassis are ... \n", "2 US Mac Watson honors the memory of a wine once ma... \n", "3 US This spent 20 months in 30% new French oak, an... \n", "4 France This is the top wine from La Bégude, named aft... \n", "\n", " designation points price province \\\n", "0 Martha's Vineyard 96 235.0 California \n", "1 Carodorum Selección Especial Reserva 96 110.0 Northern Spain \n", "2 Special Selected Late Harvest 96 90.0 California \n", "3 Reserve 96 65.0 Oregon \n", "4 La Brûlade 95 66.0 Provence \n", "\n", " region_1 region_2 variety \\\n", "0 Napa Valley Napa Cabernet Sauvignon \n", "1 Toro NaN Tinta de Toro \n", "2 Knights Valley Sonoma Sauvignon Blanc \n", "3 Willamette Valley Willamette Valley Pinot Noir \n", "4 Bandol NaN Provence red blend \n", "\n", " winery \n", "0 Heitz \n", "1 Bodega Carmen Rodríguez \n", "2 Macauley \n", "3 Ponzi \n", "4 Domaine de la Bégude " ] }, "execution_count": 49, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data_backup = data.copy() # Создаем копию нашего датафрейма и записываем в переменную data_backup\n", "data.head()" ] }, { "cell_type": "code", "execution_count": 50, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 297 }, "id": "eMhSX4jqhkzP", "outputId": "5ee71b23-0935-46c4-925f-912e28eeda25" }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
countrydescriptiondesignationpointspriceprovinceregion_1region_2varietywinery
0USkotikiMartha's Vineyard96235.0CaliforniaNapa ValleyNapaCabernet SauvignonHeitz
1SpainRipe aromas of fig, blackberry and cassis are ...Carodorum Selección Especial Reserva96110.0Northern SpainToroNaNTinta de ToroBodega Carmen Rodríguez
2USMac Watson honors the memory of a wine once ma...1299690.0CaliforniaKnights ValleySonomaSauvignon BlancMacauley
3USThis spent 20 months in 30% new French oak, an...newnewnewOregonWillamette ValleyWillamette ValleyPinot NoirPonzi
4FranceThis is the top wine from La Bégude, named aft...newnewnewProvenceBandolNaNProvence red blendDomaine de la Bégude
5SpainDeep, dense and pure from the opening bell, th...Numanthia9573.0Northern SpainToroNaNTinta de ToroNumanthia
6SpainSlightly gritty black-fruit aromas include a s...San Román9565.0Northern SpainToroNaNTinta de ToroMaurodos
7SpainLush cedary black-fruit aromas are luxe and of...Carodorum Único Crianza95110.0Northern SpainToroNaNTinta de ToroBodega Carmen Rodríguez
\n", "
" ], "text/plain": [ " country description \\\n", "0 US kotiki \n", "1 Spain Ripe aromas of fig, blackberry and cassis are ... \n", "2 US Mac Watson honors the memory of a wine once ma... \n", "3 US This spent 20 months in 30% new French oak, an... \n", "4 France This is the top wine from La Bégude, named aft... \n", "5 Spain Deep, dense and pure from the opening bell, th... \n", "6 Spain Slightly gritty black-fruit aromas include a s... \n", "7 Spain Lush cedary black-fruit aromas are luxe and of... \n", "\n", " designation points price province \\\n", "0 Martha's Vineyard 96 235.0 California \n", "1 Carodorum Selección Especial Reserva 96 110.0 Northern Spain \n", "2 129 96 90.0 California \n", "3 new new new Oregon \n", "4 new new new Provence \n", "5 Numanthia 95 73.0 Northern Spain \n", "6 San Román 95 65.0 Northern Spain \n", "7 Carodorum Único Crianza 95 110.0 Northern Spain \n", "\n", " region_1 region_2 variety \\\n", "0 Napa Valley Napa Cabernet Sauvignon \n", "1 Toro NaN Tinta de Toro \n", "2 Knights Valley Sonoma Sauvignon Blanc \n", "3 Willamette Valley Willamette Valley Pinot Noir \n", "4 Bandol NaN Provence red blend \n", "5 Toro NaN Tinta de Toro \n", "6 Toro NaN Tinta de Toro \n", "7 Toro NaN Tinta de Toro \n", "\n", " winery \n", "0 Heitz \n", "1 Bodega Carmen Rodríguez \n", "2 Macauley \n", "3 Ponzi \n", "4 Domaine de la Bégude \n", "5 Numanthia \n", "6 Maurodos \n", "7 Bodega Carmen Rodríguez " ] }, "execution_count": 50, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.iloc[0,1] = 'kotiki' # Вставляем новое значение в 0 строку и 1 стоблец\n", "data.iloc[2,2] = '129' # Вставляем новое значение в 2 строку и 2 стоблец\n", "data.iloc[3:5,2:5] = 'new' # Вставляем новое значение с 3 по 5 строку и со 2го по 5ый стоблец\n", "data.head(8)" ] }, { "cell_type": "code", "execution_count": 51, "metadata": { "id": "RZvBCkMCsiOT" }, "outputs": [], "source": [ "data = data_backup.copy() # Восстанавливаем данные из копии" ] }, { "cell_type": "code", "execution_count": 52, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 204 }, "id": "SNliNx3TPCTX", "outputId": "2f0ccacf-df6b-4499-c844-12be866957dc" }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
countrydescriptiondesignationpointspriceprovinceregion_1region_2varietywinery
0USThis tremendous 100% varietal wine hails from ...Martha's Vineyard96235.0CaliforniaNapa ValleyNapaCabernet SauvignonHeitz
1SpainRipe aromas of fig, blackberry and cassis are ...Carodorum Selección Especial Reserva96110.0Northern SpainToroNaNTinta de ToroBodega Carmen Rodríguez
2USMac Watson honors the memory of a wine once ma...Special Selected Late Harvest9690.0CaliforniaKnights ValleySonomaSauvignon BlancMacauley
3USThis spent 20 months in 30% new French oak, an...Reserve9665.0OregonWillamette ValleyWillamette ValleyPinot NoirPonzi
4FranceThis is the top wine from La Bégude, named aft...La Brûlade9566.0ProvenceBandolNaNProvence red blendDomaine de la Bégude
\n", "
" ], "text/plain": [ " country description \\\n", "0 US This tremendous 100% varietal wine hails from ... \n", "1 Spain Ripe aromas of fig, blackberry and cassis are ... \n", "2 US Mac Watson honors the memory of a wine once ma... \n", "3 US This spent 20 months in 30% new French oak, an... \n", "4 France This is the top wine from La Bégude, named aft... \n", "\n", " designation points price province \\\n", "0 Martha's Vineyard 96 235.0 California \n", "1 Carodorum Selección Especial Reserva 96 110.0 Northern Spain \n", "2 Special Selected Late Harvest 96 90.0 California \n", "3 Reserve 96 65.0 Oregon \n", "4 La Brûlade 95 66.0 Provence \n", "\n", " region_1 region_2 variety \\\n", "0 Napa Valley Napa Cabernet Sauvignon \n", "1 Toro NaN Tinta de Toro \n", "2 Knights Valley Sonoma Sauvignon Blanc \n", "3 Willamette Valley Willamette Valley Pinot Noir \n", "4 Bandol NaN Provence red blend \n", "\n", " winery \n", "0 Heitz \n", "1 Bodega Carmen Rodríguez \n", "2 Macauley \n", "3 Ponzi \n", "4 Domaine de la Bégude " ] }, "execution_count": 52, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.head()" ] }, { "cell_type": "code", "execution_count": 53, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 204 }, "id": "qXlU-wqyhkzT", "outputId": "b65e6f8a-0562-43d7-b09a-ff2c8f9eab35" }, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
countrydescriptiondesignationpointspriceprovinceregion_1region_2varietywinery
0USThis tremendous 100% varietal wine hails from ...Martha's Vineyard2001000.0CaliforniaNapa ValleySyberiaCabernet SauvignonHeitz
1SpainRipe aromas of fig, blackberry and cassis are ...Carodorum Selección Especial Reserva2001000.0Northern SpainToroNaNTinta de ToroBodega Carmen Rodríguez
2USMac Watson honors the memory of a wine once ma...Special Selected Late Harvest9690.0CaliforniaKnights ValleySyberiaSauvignon BlancMacauley
3USThis spent 20 months in 30% new French oak, an...Reserve9665.0OregonWillamette ValleySyberiaPinot NoirPonzi
4FranceThis is the top wine from La Bégude, named aft...La Brûlade9566.0ProvenceBandolNaNProvence red blendDomaine de la Bégude
\n", "
" ], "text/plain": [ " country description \\\n", "0 US This tremendous 100% varietal wine hails from ... \n", "1 Spain Ripe aromas of fig, blackberry and cassis are ... \n", "2 US Mac Watson honors the memory of a wine once ma... \n", "3 US This spent 20 months in 30% new French oak, an... \n", "4 France This is the top wine from La Bégude, named aft... \n", "\n", " designation points price province \\\n", "0 Martha's Vineyard 200 1000.0 California \n", "1 Carodorum Selección Especial Reserva 200 1000.0 Northern Spain \n", "2 Special Selected Late Harvest 96 90.0 California \n", "3 Reserve 96 65.0 Oregon \n", "4 La Brûlade 95 66.0 Provence \n", "\n", " region_1 region_2 variety winery \n", "0 Napa Valley Syberia Cabernet Sauvignon Heitz \n", "1 Toro NaN Tinta de Toro Bodega Carmen Rodríguez \n", "2 Knights Valley Syberia Sauvignon Blanc Macauley \n", "3 Willamette Valley Syberia Pinot Noir Ponzi \n", "4 Bandol NaN Provence red blend Domaine de la Bégude " ] }, "execution_count": 53, "metadata": {}, "output_type": "execute_result" } ], "source": [ "data.loc[data.country == 'US', 'region_2'] = 'Syberia'\n", "data.loc[data.price > 100, 'points'] = 200\n", "data.loc[data.price > 100, 'price'] = 1000\n", "data.head()" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "id": "6PumqSIU7Q7U" }, "outputs": [], "source": [ "## Перевод в Numpy\n" ] }, { "cell_type": "code", "execution_count": 54, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 51 }, "id": "Obs9TzQ9E8ss", "outputId": "7ea94ae7-0ee5-4773-be88-14ab92522349" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "(150930, 10)\n" ] }, { "data": { "text/plain": [ "dtype('O')" ] }, "execution_count": 54, "metadata": {}, "output_type": "execute_result" } ], "source": [ "np_data = data.values # Получаем данные из датафрейма и записываем их в переменную np_data\n", "print(np_data.shape) # Выводим размерность np_data\n", "np_data.dtype" ] }, { "cell_type": "code", "execution_count": 55, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 105 }, "id": "y1n1cNpdrFqQ", "outputId": "f6f3c2df-9732-40ed-8569-5d53223b9a24" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['US'\n", " 'This tremendous 100% varietal wine hails from Oakville and was aged over three years in oak. Juicy red-cherry fruit and a compelling hint of caramel greet the palate, framed by elegant, fine tannins and a subtle minty tone in the background. Balanced and rewarding from start to finish, it has years ahead of it to develop further nuance. Enjoy 2022–2030.'\n", " \"Martha's Vineyard\" 200 1000.0 'California' 'Napa Valley' 'Syberia'\n", " 'Cabernet Sauvignon' 'Heitz']\n" ] } ], "source": [ "print(np_data[0]) # Выводим 0ой элемент из массива" ] }, { "cell_type": "code", "execution_count": 56, "metadata": { "colab": { "base_uri": "https://localhost:8080/", "height": 717 }, "id": "UsAcU8mBnWwn", "outputId": "4eec37c8-c418-4140-de98-c4ec5b6bbe8b" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "['US'\n", " 'This tremendous 100% varietal wine hails from Oakville and was aged over three years in oak. Juicy red-cherry fruit and a compelling hint of caramel greet the palate, framed by elegant, fine tannins and a subtle minty tone in the background. Balanced and rewarding from start to finish, it has years ahead of it to develop further nuance. Enjoy 2022–2030.'\n", " \"Martha's Vineyard\" 200 1000.0 'California' 'Napa Valley' 'Syberia'\n", " 'Cabernet Sauvignon' 'Heitz']\n", "['Spain'\n", " 'Ripe aromas of fig, blackberry and cassis are softened and sweetened by a slathering of oaky chocolate and vanilla. This is full, layered, intense and cushioned on the palate, with rich flavors of chocolaty black fruits and baking spices. A toasty, everlasting finish is heady but ideally balanced. Drink through 2023.'\n", " 'Carodorum Selección Especial Reserva' 200 1000.0 'Northern Spain' 'Toro'\n", " nan 'Tinta de Toro' 'Bodega Carmen Rodríguez']\n", "['US'\n", " 'Mac Watson honors the memory of a wine once made by his mother in this tremendously delicious, balanced and complex botrytised white. Dark gold in color, it layers toasted hazelnut, pear compote and orange peel flavors, reveling in the succulence of its 122 g/L of residual sugar.'\n", " 'Special Selected Late Harvest' 96 90.0 'California' 'Knights Valley'\n", " 'Syberia' 'Sauvignon Blanc' 'Macauley']\n", "['US'\n", " \"This spent 20 months in 30% new French oak, and incorporates fruit from Ponzi's Aurora, Abetina and Madrona vineyards, among others. Aromatic, dense and toasty, it deftly blends aromas and flavors of toast, cigar box, blackberry, black cherry, coffee and graphite. Tannins are polished to a fine sheen, and frame a finish loaded with dark chocolate and espresso. Drink now through 2032.\"\n", " 'Reserve' 96 65.0 'Oregon' 'Willamette Valley' 'Syberia' 'Pinot Noir'\n", " 'Ponzi']\n", "['France'\n", " 'This is the top wine from La Bégude, named after the highest point in the vineyard at 1200 feet. It has structure, density and considerable acidity that is still calming down. With 18 months in wood, the wine has developing an extra richness and concentration. Produced by the Tari family, formerly of Château Giscours in Margaux, it is a wine made for aging. Drink from 2020.'\n", " 'La Brûlade' 95 66.0 'Provence' 'Bandol' nan 'Provence red blend'\n", " 'Domaine de la Bégude']\n", "['Spain'\n", " 'Deep, dense and pure from the opening bell, this Toro is a winner. Aromas of dark ripe black fruits are cool and moderately oaked. This feels massive on the palate but sensationally balanced. Flavors of blackberry, coffee, mocha and toasty oak finish spicy, smooth and heady. Drink this exemplary Toro through 2023.'\n", " 'Numanthia' 95 73.0 'Northern Spain' 'Toro' nan 'Tinta de Toro'\n", " 'Numanthia']\n", "['Spain'\n", " \"Slightly gritty black-fruit aromas include a sweet note of pastry along with a hint of prune. Wall-to-wall saturation ensures that all corners of one's mouth are covered. Flavors of blackberry, mocha and chocolate are highly impressive and expressive, while this settles nicely on a long finish. Drink now through 2024.\"\n", " 'San Román' 95 65.0 'Northern Spain' 'Toro' nan 'Tinta de Toro'\n", " 'Maurodos']\n", "['Spain'\n", " 'Lush cedary black-fruit aromas are luxe and offer notes of marzipan and vanilla. This bruiser is massive and tannic on the palate, but still lush and friendly. Chocolate is a key flavor, while baked berry and cassis flavors are hardly wallflowers. On the finish, this is tannic and deep as a sea trench. Drink this saturated black-colored Toro through 2023.'\n", " 'Carodorum Único Crianza' 200 1000.0 'Northern Spain' 'Toro' nan\n", " 'Tinta de Toro' 'Bodega Carmen Rodríguez']\n", "['US'\n", " \"This re-named vineyard was formerly bottled as deLancellotti. You'll find striking minerality underscoring chunky black fruits. Accents of citrus and graphite comingle, with exceptional midpalate concentration. This is a wine to cellar, though it is already quite enjoyable. Drink now through 2030.\"\n", " 'Silice' 95 65.0 'Oregon' 'Chehalem Mountains' 'Syberia' 'Pinot Noir'\n", " 'Bergström']\n", "['US'\n", " 'The producer sources from two blocks of the vineyard for this wine—one at a high elevation, which contributes bright acidity. Crunchy cranberry, pomegranate and orange peel flavors surround silky, succulent layers of texture that present as fleshy fruit. That delicately lush flavor has considerable length.'\n", " \"Gap's Crown Vineyard\" 95 60.0 'California' 'Sonoma Coast' 'Syberia'\n", " 'Pinot Noir' 'Blue Farm']\n" ] } ], "source": [ "# Выведем первые 10 элементов из np_data\n", "for i in range(10):\n", " print(np_data[i])" ] }, { "cell_type": "markdown", "metadata": { "id": "8F6G2AUnKFCA" }, "source": [ "# **Глоссарий**\n", "\n", "\n", "pd.DataFrame(данные, columns = [колонки, если есть], index = [индексы ,если есть]) - создать датафрейм\n", "\n", "pd.read_csv(полный адрес расположения файла) - открыть .csv файл\n", "\n", "------------\n", "\n", ".head() - посмотреть верхушку датафрейма (первые n строк)\n", "\n", ".tail() - посмотреть конец датафрейма (последние n строк)\n", "\n", ".columns - список колонок датафрейма\n", "\n", ".values - вывести массив всех значений датафрейма\n", "\n", ".index - список индексов датафрейма\n", "\n", ".tolist() - перевести в список\n", "\n", ".count() - посчитать количество определенных величин во фрейме\n", "\n", ".describe() - посмотреть основные статистические характеристики фрейма\n", "\n", ".shape - форма фрейма (строки, колонки)\n", "\n", ".size - размер фрейма строки*колонки\n", "\n", ".info() - информация о данных каждой колонки\n", "\n", ".dtypes - тип данных каждой колонки\n", "\n", ".isnull() - где недостает значений\n", "\n", ".isna()- есть ли значения None\n", "\n", ".dropna() - выкинуть строки/колонки с None\n", "\n", ".fillna() - заполнить заданным значеним ячейки, где есть None\n", "\n", ".loc[] - вывести значения по названиям колонок\n", "\n", ".iloc[] - вывести значения по индексам колонок\n", "\n", ".drop() - выкинуть определенные значения\n", "\n", "--------------\n", "\n", "pd.to_datetime(колонка, которую переводим в формат временного ряда)\n", "\n", ".groupby() - сгруппировать по конкретному признаку\n", "\n", ".copy() - создать копию\n", "\n", ".sort_values() - сортировка значений\n", "\n", "pd.concat([df1,df2]) - конкатенация фреймов\n", "\n", ".merge(второй_датафрейм, on = 'общая колонка, по которой склеиваем', how = 'с какой стороны') - конкатенация фреймов через общий признак\n", "\n", "-------------\n", "\n", "\n", ".corr() - вычислить корреляцию\n", "\n", ".median() - вычислить медиану\n", "\n", ".cumsum() - вычислить куммулятивную сумму\n", "\n", ".cumprod() - вычислить коммулятивное произведение\n", "\n", ".cummax() - вычислить коммулятивный максимум\n", "\n", "-------------\n", "\n", ".quantile([]) - вычислить квантили\n", "\n", ".nunique() - уникальные значения для n-колонок/строк\n", "\n", ".unique() - уникальные значения определенной колонки/строк\n", "\n", "------------\n", "\n", ".apply(функция) - применить функцию для колонки/строки\n", "\n", ".agg(набор_функций) - применить ряд функций для колонки/строки\n" ] } ], "metadata": { "colab": { "provenance": [], "toc_visible": true }, "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.10.9" } }, "nbformat": 4, "nbformat_minor": 1 }