{
  "cells": [
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "vEArhzdYIBrn"
      },
      "source": [
        "# Pandas Series"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "ij4QQTTtH7UQ"
      },
      "source": [
        "## Import Pandas\n",
        "## Import Numpy"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "I5nOdIKWH4C_"
      },
      "outputs": [],
      "source": []
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "4fqiA76IIHoA"
      },
      "source": [
        "### 1. Create a Series from a List\n",
        "\n",
        "- Given the following two lists\n",
        "\n",
        "```\n",
        "my_values = [10, 20, 30, 40, 50]\n",
        "my_indicies = ['a', 'b', 'c', 'd', 'e']\n",
        "```\n",
        "\n",
        "- Create a Series with the above values and indices"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "MocxUUskIHug"
      },
      "outputs": [],
      "source": [
        "# Create a Series with the above values and indices"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "m-TNZ1KwIR5N"
      },
      "source": [
        "### 2. Access Elements by Index\n",
        "\n",
        "- Create a series, S, with values [100, 200, 300, 400] and default indicies\n",
        "- Index the series, S, to return the first and last elements"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "6YwBPsvIIR5P"
      },
      "outputs": [],
      "source": [
        "# Create the series, S"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "TcROo6r-JBFb"
      },
      "outputs": [],
      "source": [
        "# Index your series"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "4s0g9Wv7ISHT"
      },
      "source": [
        "### 3. Apply Boolean Filtering\n",
        "\n",
        "- Given the series, 'temps'\n",
        "\n",
        "```\n",
        "temps = pd.Series([23, 28, 19, 30, 25], index=['Mon', 'Tue', 'Wed', 'Thu', 'Fri'])\n",
        "\n",
        "```\n",
        "- Filter the series for days where the temperature is above 25\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "V9pMXueQISHV"
      },
      "outputs": [],
      "source": [
        "# Filter the series, temps for days above 25"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "SUyDRw4TISOS"
      },
      "source": [
        "### 4. Perform Vectorized Arithmetic\n",
        "\n",
        "- Given the following series, 'prices'\n",
        "```\n",
        "prices = pd.Series([100, 250, 400], index=['A', 'B', 'C'])\n",
        "```\n",
        "- Increase all prices by 10% and save the result to a new series, 'updated_prices'\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "So73pSedKC8s"
      },
      "outputs": [],
      "source": [
        "# Increase the values by 10%"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "YrIe5U0PISTR"
      },
      "source": [
        "### 5. Check for Missing Values\n",
        "- Create a Series with values [1, np.nan, 3, None, 5]\n",
        "- Identify the indices where the values are missing (NaN)\n",
        "- Identify the indicies where the values are populated"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "ySAD_Yh8KqtZ"
      },
      "source": []
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "_Mu0w1mDISTR"
      },
      "outputs": [],
      "source": [
        "# Create your series"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "gJbbrl80K8t8"
      },
      "outputs": [],
      "source": [
        "# Check your series for NaN"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "usSWhExpK_4F"
      },
      "outputs": [],
      "source": [
        "# Determine which indicies are populated"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "i31kkWQrISYS"
      },
      "source": [
        "### 6. Map a Function to a Series\n",
        "- Given the series, 'cities'\n",
        "\n",
        "```\n",
        "cities = pd.Series(['new york', 'LONDON', 'ToKyo'])\n",
        "```\n",
        "\n",
        "- Convert all values to lowercase using a built-in string function"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "dNhGifuWISYT"
      },
      "outputs": [],
      "source": [
        "# Use a string function to convert strings in a series to lowercase strings"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "qWAAii25ISc1"
      },
      "source": [
        "### 7. Combine Two Series with Arithmetic\n",
        "\n",
        "- Given the following two series, s1 and s2\n",
        "\n",
        "\n",
        "```\n",
        "s1 = pd.Series([1, 2, 3], index=['a', 'b', 'c'])\n",
        "s2 = pd.Series([4, 5, 6], index=['b', 'c', 'd'])\n",
        "\n",
        "```\n",
        "\n",
        "- Add them together and explain what happens to non-matching indices."
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "urjoCLdPISc2"
      },
      "outputs": [],
      "source": [
        "# Add your series element-wise"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "6OI9p3syLt4e"
      },
      "source": [
        "- Modify this markdown element to describe what happend to the non-matching indicies\n",
        "- (TYPE YOUR ANSWER HERE)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "nXWH_yc-IShH"
      },
      "source": [
        "### 8. Use .apply() with a Custom Function\n",
        "- Create a series, 'my_vals' with integers 0 to 5, and default indicies\n",
        "- Define a function that takes 1 integer input, N ,and returns the factorial (Nx(N-1)x(N-2)...x(2)x(1)) the input integer\n",
        "- Use the .apply() method to compute the factorial of each number in the series, 'my_vals'"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "T2433sx0L3Yl"
      },
      "outputs": [],
      "source": [
        "# Create your series"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "6tZXSP6JIShH"
      },
      "outputs": [],
      "source": [
        "# Define your custom factorial function"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "7nCvEDHkMjll"
      },
      "outputs": [],
      "source": [
        "# Use the .apply() method to apply your custom function to each element in your series"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "iAdaJkFdISlg"
      },
      "source": [
        "### 9. Use .where() to Conditionally Replace Values\n",
        "- Given a series of exam scores\n",
        "\n",
        "\n",
        "```\n",
        "scores = pd.Series([82, 55, 90, 48, 76])\n",
        "```\n",
        "- use .where() to replace scores below 70 with 'Fail', keep the rest unchanged.\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "voXDUVxsISlg"
      },
      "outputs": [],
      "source": [
        "# Apply .where() to the scores series"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "D_R52g0NISqO"
      },
      "source": [
        "### 10. Use .value_counts() and .sort_values() Together\n",
        "\n",
        "- Given the series, responses\n",
        "\n",
        "\n",
        "\n",
        "```\n",
        "responses = pd.Series(['yes', 'no', 'yes', 'maybe', 'no', 'yes'])\n",
        "\n",
        "```\n",
        "- Count the frequency of each response and sort the results in descending order\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": null,
      "metadata": {
        "id": "hV-c3NIdISqO"
      },
      "outputs": [],
      "source": [
        "# Get frequency and sort in one line of code"
      ]
    }
  ],
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "display_name": "Python 3",
      "name": "python3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}
