Colab Notebook

Overview

The pandas library provides high-performance, easy-to-use data structures and data analysis tools. The main data structure is the DataFrame, which you can think of as an in-memory 2D table (like a spreadsheet, with column names and row labels). Many features available in Excel are available programmatically, such as creating pivot tables, computing columns based on other columns, plotting graphs, etc. You can also group rows by column value, or join tables much like in SQL. Pandas is also great at handling time series.

Prerequisites:

  • NumPy – if you are not familiar with NumPy, we recommend that you go through the NumPy tutorial now.

Setup

First, let’s import pandas. People usually import it as pd:

```{.python .input} import pandas as pd


## `Series` objects
The `pandas` library contains these useful data structures:
* `Series` objects, that we will discuss now. A `Series` object is 1D array,
similar to a column in a spreadsheet (with a column name and row labels).
* `DataFrame` objects. This is a 2D table, similar to a spreadsheet (with column
names and row labels).
* `Panel` objects. You can see a `Panel` as a dictionary of `DataFrame`s. These
are less used, so we will not discuss them here.

#### Creating a `Series`
Let's start by creating our first `Series` object!

```{.python .input}
s = pd.Series([2,-1,3,5])
s

```{.json .output n=None} [ { “data”: { “text/plain”: “0 2\n1 -1\n2 3\n3 5\ndtype: int64” }, “execution_count”: 3, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


#### Similar to a 1D `ndarray`
`Series` objects behave much like one-dimensional NumPy `ndarray`s, and you can
often pass them as parameters to NumPy functions:

```{.python .input}
import numpy as np
np.exp(s)

```{.json .output n=None} [ { “data”: { “text/plain”: “0 7.389056\n1 0.367879\n2 20.085537\n3 148.413159\ndtype: float64” }, “execution_count”: 4, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


Arithmetic operations on `Series` are also possible, and they apply
*elementwise*, just like for `ndarray`s:

```{.python .input}
s + [1000,2000,3000,4000]

```{.json .output n=None} [ { “data”: { “text/plain”: “0 1002\n1 1999\n2 3003\n3 4005\ndtype: int64” }, “execution_count”: 5, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


Similar to NumPy, if you add a single number to a `Series`, that number is added
to all items in the `Series`. This is called * broadcasting*:

```{.python .input}
s + 1000

```{.json .output n=None} [ { “data”: { “text/plain”: “0 1002\n1 999\n2 1003\n3 1005\ndtype: int64” }, “execution_count”: 6, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


The same is true for all binary operations such as `*` or `/`, and even
conditional operations:

```{.python .input}
s < 0

```{.json .output n=None} [ { “data”: { “text/plain”: “0 False\n1 True\n2 False\n3 False\ndtype: bool” }, “execution_count”: 7, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


#### Index labels
Each item in a `Series` object has a unique identifier called the *index label*.
By default, it is simply the rank of the item in the `Series` (starting at `0`)
but you can also set the index labels manually:

```{.python .input}
s2 = pd.Series([68, 83, 112, 68], index=["alice", "bob", "charles", "darwin"])
s2

```{.json .output n=None} [ { “data”: { “text/plain”: “alice 68\nbob 83\ncharles 112\ndarwin 68\ndtype: int64” }, “execution_count”: 8, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


You can then use the `Series` just like a `dict`:

```{.python .input}
s2["bob"]

```{.json .output n=None} [ { “data”: { “text/plain”: “83” }, “execution_count”: 9, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


You can still access the items by integer location, like in a regular array:

```{.python .input}
s2[1]

```{.json .output n=None} [ { “data”: { “text/plain”: “83” }, “execution_count”: 10, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


To make it clear when you are accessing by label or by integer location, it is
recommended to always use the `loc` attribute when accessing by label, and the
`iloc` attribute when accessing by integer location:

```{.python .input}
s2.loc["bob"]

```{.json .output n=None} [ { “data”: { “text/plain”: “83” }, “execution_count”: 11, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


```{.python .input}
s2.iloc[1]

```{.json .output n=None} [ { “data”: { “text/plain”: “83” }, “execution_count”: 12, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


Slicing a `Series` also slices the index labels:

```{.python .input}
s2.iloc[1:3]

```{.json .output n=None} [ { “data”: { “text/plain”: “bob 83\ncharles 112\ndtype: int64” }, “execution_count”: 13, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


This can lead to unexpected results when using the default numeric labels, so be
careful:

```{.python .input}
surprise = pd.Series([1000, 1001, 1002, 1003])
surprise

```{.json .output n=None} [ { “data”: { “text/plain”: “0 1000\n1 1001\n2 1002\n3 1003\ndtype: int64” }, “execution_count”: 14, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


```{.python .input}
surprise_slice = surprise[2:]
surprise_slice

```{.json .output n=None} [ { “data”: { “text/plain”: “2 1002\n3 1003\ndtype: int64” }, “execution_count”: 15, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


Oh look! The first element has index label `2`. The element with index label `0`
is absent from the slice:

```{.python .input}
try:
    surprise_slice[0]
except KeyError as e:
    print("Key error:", e)

```{.json .output n=None} [ { “name”: “stdout”, “output_type”: “stream”, “text”: “Key error: 0\n” } ]


But remember that you can access elements by integer location using the `iloc`
attribute. This illustrates another reason why it's always better to use `loc`
and `iloc` to access `Series` objects:

```{.python .input}
surprise_slice.iloc[0]

```{.json .output n=None} [ { “data”: { “text/plain”: “1002” }, “execution_count”: 17, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


#### Init from `dict`
You can create a `Series` object from a `dict`. The keys will be used as index
labels:

```{.python .input}
weights = {"alice": 68, "bob": 83, "colin": 86, "darwin": 68}
s3 = pd.Series(weights)
s3

```{.json .output n=None} [ { “data”: { “text/plain”: “alice 68\nbob 83\ncolin 86\ndarwin 68\ndtype: int64” }, “execution_count”: 18, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


You can control which elements you want to include in the `Series` and in what
order by explicitly specifying the desired `index`:

```{.python .input}
s4 = pd.Series(weights, index = ["colin", "alice"])
s4

```{.json .output n=None} [ { “data”: { “text/plain”: “colin 86\nalice 68\ndtype: int64” }, “execution_count”: 19, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


#### Automatic alignment
When an operation involves multiple `Series` objects, `pandas` automatically
aligns items by matching index labels.

```{.python .input}
print(s2.keys())
print(s3.keys())

s2 + s3

```{.json .output n=None} [ { “name”: “stdout”, “output_type”: “stream”, “text”: “Index([‘alice’, ‘bob’, ‘charles’, ‘darwin’], dtype=’object’)\nIndex([‘alice’, ‘bob’, ‘colin’, ‘darwin’], dtype=’object’)\n” }, { “data”: { “text/plain”: “alice 136.0\nbob 166.0\ncharles NaN\ncolin NaN\ndarwin 136.0\ndtype: float64” }, “execution_count”: 20, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


The resulting `Series` contains the union of index labels from `s2` and `s3`.
Since `"colin"` is missing from `s2` and `"charles"` is missing from `s3`, these
items have a `NaN` result value. (ie. Not-a-Number means *missing*).

Automatic alignment is very handy when working with data that may come from
various sources with varying structure and missing items. But if you forget to
set the right index labels, you can have surprising results:

```{.python .input}
s5 = pd.Series([1000,1000,1000,1000])
print("s2 =", s2.values)
print("s5 =", s5.values)

s2 + s5

```{.json .output n=None} [ { “name”: “stdout”, “output_type”: “stream”, “text”: “s2 = [ 68 83 112 68]\ns5 = [1000 1000 1000 1000]\n” }, { “data”: { “text/plain”: “alice NaN\nbob NaN\ncharles NaN\ndarwin NaN\n0 NaN\n1 NaN\n2 NaN\n3 NaN\ndtype: float64” }, “execution_count”: 21, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


Pandas could not align the `Series`, since their labels do not match at all,
hence the full `NaN` result.

#### Init with a scalar
You can also initialize a `Series` object using a scalar and a list of index
labels: all items will be set to the scalar.

```{.python .input}
meaning = pd.Series(42, ["life", "universe", "everything"])
meaning

```{.json .output n=None} [ { “data”: { “text/plain”: “life 42\nuniverse 42\neverything 42\ndtype: int64” }, “execution_count”: 22, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


#### `Series` name
A `Series` can have a `name`:

```{.python .input}
s6 = pd.Series([83, 68], index=["bob", "alice"], name="weights")
s6

```{.json .output n=None} [ { “data”: { “text/plain”: “bob 83\nalice 68\nName: weights, dtype: int64” }, “execution_count”: 23, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


#### Plotting a `Series`
Pandas makes it easy to plot `Series` data using matplotlib (for more details on
matplotlib, check out the [matplotlib tutorial](tools_matplotlib.ipynb)). Just
import matplotlib and call the `plot()` method:

```{.python .input}
%matplotlib inline
import matplotlib.pyplot as plt
temperatures = [4.4,5.1,6.1,6.2,6.1,6.1,5.7,5.2,4.7,4.1,3.9,3.5]
s7 = pd.Series(temperatures, name="Temperature")
s7.plot()
plt.show()

```{.json .output n=None} [ { “data”: { “image/png”: “iVBORw0KGgoAAAANSUhEUgAAAXcAAAD8CAYAAACMwORRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4xLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvAOZPmwAAIABJREFUeJzt3Xd8VfX9x/HX594sEiAhEMIIEPae\nCQFcVdyKYB3g1lZErdZV22qHq63Vah392VZxFcQBrjrqHnWyEkBkgyRhh0AYgZD9/f2RW3+UH8pN\nSHLueD8fjzxyx8k57/sQ3zk553u+x5xziIhIZPF5HUBERBqfyl1EJAKp3EVEIpDKXUQkAqncRUQi\nkMpdRCQCqdxFRCKQyl1EJAKp3EVEIlCMVxtu166dy8zM9GrzIiJhKS8vb5tzLu1Qy3lW7pmZmeTm\n5nq1eRGRsGRmhcEsp8MyIiIRSOUuIhKBVO4iIhFI5S4iEoFU7iIiEUjlLiISgVTuIiIRyLNx7tL0\ndpdXkVewg5VFpfRNb0VWZhtaJ8R6HUtEmoHKPYJs21PB/PwS5uaXML+ghOWbd1O73y1yzaB/h9bk\ndE8lp3sqIzNTSWsV711gEWkyKvcwtmFHGfPyS+q+CkpYW7wXgIRYHyO6tuG643uTk5lKv46tWbFl\nN/PzdzCvYDsz56/nH18WANCjXdK3RZ/TPZWMNi0wMw8/lYg0BnPOHXqpJpCdne00/UDwnHN8U7yn\nbq88UOibdpUD0DohhpGZqYwM7JEP6pRMXMx3n06pqqllycZd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ZbQBuB+4BZpnZ5UAhMNG7hAenK1RFRCKQTqiKiEQglbuISARSuYuIRCCVu4hIBFK5\ni4hEIJW7iEgEUrmLiEQglbuISAT6X/s00irHqiZcAAAAAElFTkSuQmCC\n”, “text/plain”: “<matplotlib.figure.Figure at 0x10b5bbe80>” }, “metadata”: { “tags”: [] }, “output_type”: “display_data” } ]


There are *many* options for plotting your data. It is not necessary to list
them all here: if you need a particular type of plot (histograms, pie charts,
etc.), just look for it in the excellent
[Visualization](http://pandas.pydata.org/pandas-docs/stable/visualization.html)
section of pandas' documentation, and look at the example code.

## Handling time
Many datasets have timestamps, and pandas is awesome at manipulating such data:
* it can represent periods (such as 2016Q3) and frequencies (such as "monthly"),
* it can convert periods to actual timestamps, and *vice versa*,
* it can resample data and aggregate values any way you like,
* it can handle timezones.

#### Time range
Let's start by creating a time series using `pd.date_range()`. This returns a
`DatetimeIndex` containing one datetime per hour for 12 hours starting on
October 29th 2016 at 5:30pm.

```{.python .input}
dates = pd.date_range('2016/10/29 5:30pm', periods=12, freq='H')
dates

```{.json .output n=None} [ { “data”: { “text/plain”: “DatetimeIndex([‘2016-10-29 17:30:00’, ‘2016-10-29 18:30:00’,\n ‘2016-10-29 19:30:00’, ‘2016-10-29 20:30:00’,\n ‘2016-10-29 21:30:00’, ‘2016-10-29 22:30:00’,\n ‘2016-10-29 23:30:00’, ‘2016-10-30 00:30:00’,\n ‘2016-10-30 01:30:00’, ‘2016-10-30 02:30:00’,\n ‘2016-10-30 03:30:00’, ‘2016-10-30 04:30:00’],\n dtype=’datetime64[ns]’, freq=’H’)” }, “execution_count”: 25, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


This `DatetimeIndex` may be used as an index in a `Series`:

```{.python .input}
temp_series = pd.Series(temperatures, dates)
temp_series

```{.json .output n=None} [ { “data”: { “text/plain”: “2016-10-29 17:30:00 4.4\n2016-10-29 18:30:00 5.1\n2016-10-29 19:30:00 6.1\n2016-10-29 20:30:00 6.2\n2016-10-29 21:30:00 6.1\n2016-10-29 22:30:00 6.1\n2016-10-29 23:30:00 5.7\n2016-10-30 00:30:00 5.2\n2016-10-30 01:30:00 4.7\n2016-10-30 02:30:00 4.1\n2016-10-30 03:30:00 3.9\n2016-10-30 04:30:00 3.5\nFreq: H, dtype: float64” }, “execution_count”: 26, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


Let's plot this series:

```{.python .input}
temp_series.plot(kind="bar")

plt.grid(True)
plt.show()

```{.json .output n=None} [ { “data”: { “image/png”: “iVBORw0KGgoAAAANSUhEUgAAAW4AAAFbCAYAAAD1FWSRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4xLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvAOZPmwAAIABJREFUeJzt3XmYXHWd7/H3BwIaiYbVRsMSRwRl\nzACmkZnLOKbdCILiODMu88y4YrzXK6OO9wquI+NGdPDCqKCM4HJdWkbRYUDABYLDVZZOWAKGuAYh\njwlKWAyiGP3eP87pTnVT1V3dOed3+nf683qeetJ1TnV9zvdXXd9UnTrnV4oIzMwsHzs1vQFmZjY9\nbtxmZplx4zYzy4wbt5lZZty4zcwy48ZtZpYZN24zs8y4cZuZZcaN28wsM/PquNO99947Fi9ePO3f\nu//++9ltt92q36CGs5znPOfNnbyZZq1evfqXEbFPXzeOiMovS5cujZm44oorZvR7sz3Lec5z3tzJ\nm2kWMBJ99ljvKjEzy4wbt5lZZty4zcwy48ZtZpYZN24zs8y4cZuZZcaN28wsM27cZmaZqeXMSUtj\n8SkX91z35iXbeEWP9RtOO66uTTKzBPyK28wsM27cZmaZceM2M8tMX/u4Je0OfBJ4MhDAqyLie3Vu\nWI7avs85dX1tH0+zmer3w8kzgUsj4q8l7Qo8osZtMjOzSUzZuCUtBP4CeAVARDwIPFjvZpmZWS8q\npoGd5AbS4cA5wPeBw4DVwBsi4v4Jt1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6tU1OTTKUs+HyK7ytcFhF7RsRe\nwFC57PyKs5p4MFtdX9vH03lZ56Wubbs698NMsm/oMuBkYN+OZfuWy75Rcdb6mazLobY5Ul/bx9N5\nmealrq3z0tQkU4sjYmVEbBpdEBGbImIlcGDFWbdJeoukgdEFkgYknUxx2nTVUtYG7a+v7ePpvHzz\nUtc2pqnGnbLgFwN7AVeWb7W3AKuAPYEXVZwF6R/MttfX9vF0Xr55qWsb09RRJXsApwAnAI8uF28G\nLgRWRsSW5BtVkTbXBunra/t4ms3ErJurpA6SnggsAq6OiPs7li+PiEub27JqtL2+1FKPp/PyzWvs\nuVfnDvQpduw/EXgmsNuE5csrzvkHYD3wNWADcELHujVVZqWubS7U1/bxdF6+eU0898buv847nw0F\nA2uBBeXPi4ER4A3l9etzrm2O1Nf28XRepnmpa+u8NDVXyWsoTmPeKmkx8GVJiyPiTIrJg6q0U5RT\nf0bEBknLyrwDa8iCtLVB++tr+3g6L9+81LVtD67zzifL7SwYWAYcK+nDVF/wZkmHj14pc48H9gaW\nVJwFaWuD9tfX9vF0Xr55qWvbrs6X85O8xbgcOHzCsnnAZ4HfV5y1Hx0nb0xYd3TOtc2R+to+ns7L\nNC91bZ2Xpg4H3A/YFh0nVXSsOzoi/l/yjapIm2uD9PW1fTzNZmJOHA5oZtYmTe3jNjOzGXLjNjPL\njBu3mVlm3LjNzDLz/wEJ5lbocofr5wAAAABJRU5ErkJggg==\n”, “text/plain”: “<matplotlib.figure.Figure at 0x10b68fda0>” }, “metadata”: { “tags”: [] }, “output_type”: “display_data” } ]


#### Resampling
Pandas lets us resample a time series very simply. Just call the `resample()`
method and specify a new frequency:

```{.python .input}
temp_series_freq_2H = temp_series.resample("2H")
temp_series_freq_2H

```{.json .output n=None} [ { “data”: { “text/plain”: “DatetimeIndexResampler [freq=<2 * Hours>, axis=0, closed=left, label=left, convention=start, base=0]” }, “execution_count”: 28, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


The resampling operation is actually a deferred operation, which is why we did
not get a `Series` object, but a `DatetimeIndexResampler` object instead. To
actually perform the resampling operation, we can simply call the `mean()`
method: Pandas will compute the mean of every pair of consecutive hours:

```{.python .input}
temp_series_freq_2H = temp_series_freq_2H.mean()

Let’s plot the result:

```{.python .input} temp_series_freq_2H.plot(kind=”bar”) plt.show()


```{.json .output n=None}
[
 {
  "data": {
   "image/png": "iVBORw0KGgoAAAANSUhEUgAAAW4AAAFbCAYAAAD1FWSRAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4xLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvAOZPmwAAHHNJREFUeJzt3XmUZnV95/H3RxozCtqIVNDI0sQF\nNaMstkvGTEQZFVwzJio6o6hoZ2binoySjGMgOg4dz3jweCKmVQRHDTHGKEEFNUQdIovN4sLmFhA4\nARqQUTNxQT/zx70F1dVV9dxq+un7+z58XufUoZ57H4oPt3/16fvc5Xdlm4iIqONuYweIiIjVSXFH\nRBST4o6IKCbFHRFRTIo7IqKYFHdERDEp7oiIYlLcERHFpLgjIopZM40futdee3ndunXT+NERETPp\nwgsvvMn23JD3TqW4161bx+bNm6fxoyMiZpKkq4e+N4dKIiKKSXFHRBST4o6IKCbFHRFRTIo7IqKY\nFHdERDEp7oiIYlLcERHFTOUGnKhj3bGfmurPv+qEp0/150fcFWWPOyKimEHFLWkPSR+TdIWkyyX9\n+rSDRUTE0oYeKnkncKbt35F0d+CeU8wUERErmFjcktYCvwm8BMD2T4GfTjdWREQsZ8ihkgOALcAH\nJF0s6X2Sdlv8JkkbJG2WtHnLli07PGhERHSGFPca4FDgJNuHAP8MHLv4TbY32V5ve/3c3KApZSMi\nYjsMKe5rgWttn9+//hhdkUdExAgmFrft64FrJB3YLzocuGyqqSIiYllDryp5FfDh/oqS7wIvnV6k\niOFyA1HcFQ0qbtuXAOunnCUiIgbInZMREcWkuCMiikl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XzoA29fb3gjs\nP2Kuoa6W9AZJe88vkLS3pDfS3Xbduur5M37GVTl/89lbLu7mN94EzwfuC3yx/6h+C/AFYE/geWMG\nG6h6/oyfcVXO33z2lg+V3Ac4Fng28Mv94huA04GNtm8ZK1u0L+MnZlmzxT0LJD0UeABwnu1/XrD8\nCNtnjpdsmOr5q6u+/Svnbz17y4dKkPRQSYdL2m3R8iPGyjSUpFcDnwReBVwq6dkLVr9tnFTDVc8P\nGT9jqpy/RHbbTX4BrwauBD4BXAU8e8G6i8bONyD/14Hd++/XAZuB1/SvLx47310gf8ZP8s9s9pbn\nKnkF8CjbP5K0DviYpHW230k3UVDr7uZ+6lDbV0k6jO7/YX+Sf2fI+BlX5fzNZ2/5UMlWGw84DDhS\n0jtoZONNcIOkg+df9P8vzwD2Ah4xWqrhqufP+BlX5fzNZ2/25KSks4HX275kwbI1dE/v/g+2dxkt\n3ACS9gFu84LriBese7ztfxgh1mAzkD/jZ0SV81fI3nJxN7/xol0ZPzHLmi3uiIhYWsvHuCMiYgkp\n7oiIYlLcERHFpLgjIor5/4Xj0noYGwK1AAAAAElFTkSuQmCC\n",
   "text/plain": "<matplotlib.figure.Figure at 0x10b739208>"
  },
  "metadata": {
   "tags": []
  },
  "output_type": "display_data"
 }
]

Note how the values have automatically been aggregated into 2-hour periods. If we look at the 6-8pm period, for example, we had a value of 5.1 at 6:30pm, and 6.1 at 7:30pm. After resampling, we just have one value of 5.6, which is the mean of 5.1 and 6.1. Rather than computing the mean, we could have used any other aggregation function, for example we can decide to keep the minimum value of each period:

```{.python .input} temp_series_freq_2H = temp_series.resample(“2H”).min() temp_series_freq_2H


```{.json .output n=None}
[
 {
  "data": {
   "text/plain": "2016-10-29 16:00:00    4.4\n2016-10-29 18:00:00    5.1\n2016-10-29 20:00:00    6.1\n2016-10-29 22:00:00    5.7\n2016-10-30 00:00:00    4.7\n2016-10-30 02:00:00    3.9\n2016-10-30 04:00:00    3.5\nFreq: 2H, dtype: float64"
  },
  "execution_count": 31,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Or, equivalently, we could use the apply() method instead:

```{.python .input} temp_series_freq_2H = temp_series.resample(“2H”).apply(np.min) temp_series_freq_2H


```{.json .output n=None}
[
 {
  "data": {
   "text/plain": "2016-10-29 16:00:00    4.4\n2016-10-29 18:00:00    5.1\n2016-10-29 20:00:00    6.1\n2016-10-29 22:00:00    5.7\n2016-10-30 00:00:00    4.7\n2016-10-30 02:00:00    3.9\n2016-10-30 04:00:00    3.5\nFreq: 2H, dtype: float64"
  },
  "execution_count": 32,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Upsampling and interpolation

This was an example of downsampling. We can also upsample (ie. increase the frequency), but this creates holes in our data:

```{.python .input} temp_series_freq_15min = temp_series.resample(“15Min”).mean() temp_series_freq_15min.head(n=10) ## head displays the top n values


```{.json .output n=None}
[
 {
  "data": {
   "text/plain": "2016-10-29 17:30:00    4.4\n2016-10-29 17:45:00    NaN\n2016-10-29 18:00:00    NaN\n2016-10-29 18:15:00    NaN\n2016-10-29 18:30:00    5.1\n2016-10-29 18:45:00    NaN\n2016-10-29 19:00:00    NaN\n2016-10-29 19:15:00    NaN\n2016-10-29 19:30:00    6.1\n2016-10-29 19:45:00    NaN\nFreq: 15T, dtype: float64"
  },
  "execution_count": 33,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

One solution is to fill the gaps by interpolating. We just call the interpolate() method. The default is to use linear interpolation, but we can also select another method, such as cubic interpolation:

```{.python .input} temp_series_freq_15min = temp_series.resample(“15Min”).interpolate(method=”cubic”) temp_series_freq_15min.head(n=10)


```{.json .output n=None}
[
 {
  "data": {
   "text/plain": "2016-10-29 17:30:00    4.400000\n2016-10-29 17:45:00    4.452911\n2016-10-29 18:00:00    4.605113\n2016-10-29 18:15:00    4.829758\n2016-10-29 18:30:00    5.100000\n2016-10-29 18:45:00    5.388992\n2016-10-29 19:00:00    5.669887\n2016-10-29 19:15:00    5.915839\n2016-10-29 19:30:00    6.100000\n2016-10-29 19:45:00    6.203621\nFreq: 15T, dtype: float64"
  },
  "execution_count": 34,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

```{.python .input} temp_series.plot(label=”Period: 1 hour”) temp_series_freq_15min.plot(label=”Period: 15 minutes”) plt.legend() plt.show()


```{.json .output n=None}
[
 {
  "data": {
   "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX0AAAD7CAYAAACG50QgAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4xLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvAOZPmwAAIABJREFUeJzt3Xd4FFX3wPHv2fQGARJqgNA7hCI9\n0pQiCAgW7KiIFMtPBctr91XBF7uCiIAUsYGCiojYEEEEEghFaSJIh5BAKElIu78/ZsGIoWU3md3s\n+TzPPsnuzM45s9mcuXNn5o4YY1BKKeUbHHYnoJRSqvho0VdKKR+iRV8ppXyIFn2llPIhWvSVUsqH\naNFXSikfokVfKaV8iBZ9pZTyIVr0lVLKh/jbncCZoqKiTGxsrN1pKKWUV0lMTDxkjIk+33weV/Rj\nY2NJSEiwOw2llPIqIvLXhcyn3TtKKeVDtOgrpZQP0aKvlFI+xOP69JVSBcvOzmb37t1kZmbanYqy\nUXBwMDExMQQEBBTq/Vr0lfISu3fvJiIigtjYWETE7nSUDYwxpKSksHv3bmrUqFGoZWj3jlJeIjMz\nk3LlymnB92EiQrly5Vza29OWvrfJzoQ/F8Om+bDlG8jJhJBICCkLIWUg1PkzpCyEl4fq7aF8Q9BC\nUSJowVeufge06HuDjMOw9Vur0G/9DrJPQGAE1LkcwitARqo1T3oqHNlp/Z55BEye9f7wClCzC9Tq\nCjU7Q0QFO9dGKWUjLfqe7K/l8NNY2LEU8nIgvCI0uw7q94bYePAPOvt78/Lg6B7Y/hNs+wH++BbW\nfQRAbnQj9k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LqOhc6dqGG\nqbArrq5z8cf21Mf5+vQPAW9gjVMSK9b9LU95AHhOrNsZgnXno80iEiAiDudpUK6cwmRXbF+La2ds\nb17nwg71bFdcO2P74jp7rFPDgZ59BpEQY0yGiNwFXG+M6Zxv2jSs+6p+B1wDpBlj3HZ/T7ti+1pc\nO2PrOus6l9R19lgXsZsUgnWRy735XisN9AbmAP8tqt0Ru2L7WlxdZ11nXeeiie1Jj4v90HoAK5y/\nN8E5mBAu9K16emxfi6vrrOus61yyHxd1nr6xbqt2WEROYt0dxuF8vcgvP7Yrtq/FtTO2rrOuc1HG\ntTu2x7iILaQDeA7rxtx3FueWya7YvhZX11nXuaTGtTu2Jz3OeyA3PxHpBfxgCnGlo6vsiu1rce2M\nretcvHSdfdNFFX2llFLerUhuoqKUUsozadFXSikfokVfKaV8iBZ9pZTyIVr0lVLKh2jRV0opH6JF\nXymlfMj/A19hNXiBHe8QAAAAAElFTkSuQmCC\n",
   "text/plain": "<matplotlib.figure.Figure at 0x10b8b8710>"
  },
  "metadata": {
   "tags": []
  },
  "output_type": "display_data"
 }
]

Timezones

By default datetimes are naive: they are not aware of timezones, so 2016-10-30 02:30 might mean October 30th 2016 at 2:30am in Paris or in New York. We can make datetimes timezone aware by calling the tz_localize() method:

```{.python .input} temp_series_ny = temp_series.tz_localize(“America/New_York”) temp_series_ny


```{.json .output n=None}
[
 {
  "data": {
   "text/plain": "2016-10-29 17:30:00-04:00    4.4\n2016-10-29 18:30:00-04:00    5.1\n2016-10-29 19:30:00-04:00    6.1\n2016-10-29 20:30:00-04:00    6.2\n2016-10-29 21:30:00-04:00    6.1\n2016-10-29 22:30:00-04:00    6.1\n2016-10-29 23:30:00-04:00    5.7\n2016-10-30 00:30:00-04:00    5.2\n2016-10-30 01:30:00-04:00    4.7\n2016-10-30 02:30:00-04:00    4.1\n2016-10-30 03:30:00-04:00    3.9\n2016-10-30 04:30:00-04:00    3.5\nFreq: H, dtype: float64"
  },
  "execution_count": 36,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Note that -04:00 is now appended to all the datetimes. This means that these datetimes refer to UTC - 4 hours.

We can convert these datetimes to Paris time like this:

```{.python .input} temp_series_paris = temp_series_ny.tz_convert(“Europe/Paris”) temp_series_paris


```{.json .output n=None}
[
 {
  "data": {
   "text/plain": "2016-10-29 23:30:00+02:00    4.4\n2016-10-30 00:30:00+02:00    5.1\n2016-10-30 01:30:00+02:00    6.1\n2016-10-30 02:30:00+02:00    6.2\n2016-10-30 02:30:00+01:00    6.1\n2016-10-30 03:30:00+01:00    6.1\n2016-10-30 04:30:00+01:00    5.7\n2016-10-30 05:30:00+01:00    5.2\n2016-10-30 06:30:00+01:00    4.7\n2016-10-30 07:30:00+01:00    4.1\n2016-10-30 08:30:00+01:00    3.9\n2016-10-30 09:30:00+01:00    3.5\nFreq: H, dtype: float64"
  },
  "execution_count": 37,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

You may have noticed that the UTC offset changes from +02:00 to +01:00: this is because France switches to winter time at 3am that particular night (time goes back to 2am). Notice that 2:30am occurs twice! Let’s go back to a naive representation (if you log some data hourly using local time, without storing the timezone, you might get something like this):

```{.python .input} temp_series_paris_naive = temp_series_paris.tz_localize(None) temp_series_paris_naive


```{.json .output n=None}
[
 {
  "data": {
   "text/plain": "2016-10-29 23:30:00    4.4\n2016-10-30 00:30:00    5.1\n2016-10-30 01:30:00    6.1\n2016-10-30 02:30:00    6.2\n2016-10-30 02:30:00    6.1\n2016-10-30 03:30:00    6.1\n2016-10-30 04:30:00    5.7\n2016-10-30 05:30:00    5.2\n2016-10-30 06:30:00    4.7\n2016-10-30 07:30:00    4.1\n2016-10-30 08:30:00    3.9\n2016-10-30 09:30:00    3.5\nFreq: H, dtype: float64"
  },
  "execution_count": 38,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Now 02:30 is really ambiguous. If we try to localize these naive datetimes to the Paris timezone, we get an error:

```{.python .input} try: temp_series_paris_naive.tz_localize(“Europe/Paris”) except Exception as e: print(type(e)) print(e)


```{.json .output n=None}
[
 {
  "name": "stdout",
  "output_type": "stream",
  "text": "<class 'pytz.exceptions.AmbiguousTimeError'>\nCannot infer dst time from Timestamp('2016-10-30 02:30:00'), try using the 'ambiguous' argument\n"
 }
]

Fortunately using the ambiguous argument we can tell pandas to infer the right DST (Daylight Saving Time) based on the order of the ambiguous timestamps:

```{.python .input} temp_series_paris_naive.tz_localize(“Europe/Paris”, ambiguous=”infer”)


```{.json .output n=None}
[
 {
  "data": {
   "text/plain": "2016-10-29 23:30:00+02:00    4.4\n2016-10-30 00:30:00+02:00    5.1\n2016-10-30 01:30:00+02:00    6.1\n2016-10-30 02:30:00+02:00    6.2\n2016-10-30 02:30:00+01:00    6.1\n2016-10-30 03:30:00+01:00    6.1\n2016-10-30 04:30:00+01:00    5.7\n2016-10-30 05:30:00+01:00    5.2\n2016-10-30 06:30:00+01:00    4.7\n2016-10-30 07:30:00+01:00    4.1\n2016-10-30 08:30:00+01:00    3.9\n2016-10-30 09:30:00+01:00    3.5\nFreq: H, dtype: float64"
  },
  "execution_count": 40,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Periods

The pd.period_range() function returns a PeriodIndex instead of a DatetimeIndex. For example, let’s get all quarters in 2016 and 2017:

```{.python .input} quarters = pd.period_range(‘2016Q1’, periods=8, freq=’Q’) quarters


```{.json .output n=None}
[
 {
  "data": {
   "text/plain": "PeriodIndex(['2016Q1', '2016Q2', '2016Q3', '2016Q4', '2017Q1', '2017Q2',\n             '2017Q3', '2017Q4'],\n            dtype='period[Q-DEC]', freq='Q-DEC')"
  },
  "execution_count": 41,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Adding a number N to a PeriodIndex shifts the periods by N times the PeriodIndex’s frequency:

```{.python .input} quarters + 3


```{.json .output n=None}
[
 {
  "data": {
   "text/plain": "PeriodIndex(['2016Q4', '2017Q1', '2017Q2', '2017Q3', '2017Q4', '2018Q1',\n             '2018Q2', '2018Q3'],\n            dtype='period[Q-DEC]', freq='Q-DEC')"
  },
  "execution_count": 42,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

The asfreq() method lets us change the frequency of the PeriodIndex. All periods are lengthened or shortened accordingly. For example, let’s convert all the quarterly periods to monthly periods (zooming in):

```{.python .input} quarters.asfreq(“M”)


```{.json .output n=None}
[
 {
  "data": {
   "text/plain": "PeriodIndex(['2016-03', '2016-06', '2016-09', '2016-12', '2017-03', '2017-06',\n             '2017-09', '2017-12'],\n            dtype='period[M]', freq='M')"
  },
  "execution_count": 43,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

By default, the asfreq zooms on the end of each period. We can tell it to zoom on the start of each period instead:

```{.python .input} quarters.asfreq(“M”, how=”start”)


```{.json .output n=None}
[
 {
  "data": {
   "text/plain": "PeriodIndex(['2016-01', '2016-04', '2016-07', '2016-10', '2017-01', '2017-04',\n             '2017-07', '2017-10'],\n            dtype='period[M]', freq='M')"
  },
  "execution_count": 44,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

And we can zoom out:

```{.python .input} quarters.asfreq(“A”)


```{.json .output n=None}
[
 {
  "data": {
   "text/plain": "PeriodIndex(['2016', '2016', '2016', '2016', '2017', '2017', '2017', '2017'], dtype='period[A-DEC]', freq='A-DEC')"
  },
  "execution_count": 45,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Of course we can create a Series with a PeriodIndex:

```{.python .input} quarterly_revenue = pd.Series([300, 320, 290, 390, 320, 360, 310, 410], index = quarters) quarterly_revenue


```{.json .output n=None}
[
 {
  "data": {
   "text/plain": "2016Q1    300\n2016Q2    320\n2016Q3    290\n2016Q4    390\n2017Q1    320\n2017Q2    360\n2017Q3    310\n2017Q4    410\nFreq: Q-DEC, dtype: int64"
  },
  "execution_count": 46,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

```{.python .input} quarterly_revenue.plot(kind=”line”) plt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joN1joa4eNlMBVBhj1nifv0jXLwKlgpaP\njv1u59PV5viw7yNVkcpfVT1C17j8dmPM74956TW6ZujB+99XT7cdY8whoFxExnkXLaGr2ZVSQclX\nx/4xrkWHeZSP+auq5xzgI7omNfB4F/+ArrHOF4BRdPWauMoYUy0iw4H1wGDv+g109SqpF5EpwCNA\nLLAL+JIxpsbnQSvlAz4+9pOAfcAYY0xdYD+JCmfaskEppSKM3rmrlFIRRhO/UkpFGE38SikVYTTx\nK6VUhNHEr5RSEUYTv1JKRRhN/EopFWH+PzmgvHC4jUWRAAAAAElFTkSuQmCC\n",
   "text/plain": "<matplotlib.figure.Figure at 0x10d315e80>"
  },
  "metadata": {
   "tags": []
  },
  "output_type": "display_data"
 }
]

We can convert periods to timestamps by calling to_timestamp. By default this will give us the first day of each period, but by setting how and freq, we can get the last hour of each period:

```{.python .input} last_hours = quarterly_revenue.to_timestamp(how=”end”, freq=”H”) last_hours


```{.json .output n=None}
[
 {
  "data": {
   "text/plain": "2016-03-31 23:00:00    300\n2016-06-30 23:00:00    320\n2016-09-30 23:00:00    290\n2016-12-31 23:00:00    390\n2017-03-31 23:00:00    320\n2017-06-30 23:00:00    360\n2017-09-30 23:00:00    310\n2017-12-31 23:00:00    410\nFreq: Q-DEC, dtype: int64"
  },
  "execution_count": 48,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

And back to periods by calling to_period:

```{.python .input} last_hours.to_period()


```{.json .output n=None}
[
 {
  "data": {
   "text/plain": "2016Q1    300\n2016Q2    320\n2016Q3    290\n2016Q4    390\n2017Q1    320\n2017Q2    360\n2017Q3    310\n2017Q4    410\nFreq: Q-DEC, dtype: int64"
  },
  "execution_count": 49,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Pandas also provides many other time-related functions that we recommend you check out in the documentation. To whet your appetite, here is one way to get the last business day of each month in 2016, at 9am:

```{.python .input} months_2016 = pd.period_range(“2016”, periods=12, freq=”M”) one_day_after_last_days = months_2016.asfreq(“D”) + 1 last_bdays = one_day_after_last_days.to_timestamp() - pd.tseries.offsets.BDay() last_bdays.to_period(“H”) + 9


```{.json .output n=None}
[
 {
  "data": {
   "text/plain": "PeriodIndex(['2016-01-29 09:00', '2016-02-29 09:00', '2016-03-31 09:00',\n             '2016-04-29 09:00', '2016-05-31 09:00', '2016-06-30 09:00',\n             '2016-07-29 09:00', '2016-08-31 09:00', '2016-09-30 09:00',\n             '2016-10-31 09:00', '2016-11-30 09:00', '2016-12-30 09:00'],\n            dtype='period[H]', freq='H')"
  },
  "execution_count": 50,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

DataFrame objects

A DataFrame object represents a spreadsheet, with cell values, column names and row index labels. You can define expressions to compute columns based on other columns, create pivot-tables, group rows, draw graphs, etc. You can see DataFrames as dictionaries of Series.

Creating a DataFrame

You can create a DataFrame by passing a dictionary of Series objects:

```{.python .input} people_dict = { “weight”: pd.Series([68, 83, 112], index=[“alice”, “bob”, “charles”]), “birthyear”: pd.Series([1984, 1985, 1992], index=[“bob”, “alice”, “charles”], name=”year”), “children”: pd.Series([0, 3], index=[“charles”, “bob”]), “hobby”: pd.Series([“Biking”, “Dancing”], index=[“alice”, “bob”]), } people = pd.DataFrame(people_dict) people


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>birthyear</th>\n      <th>children</th>\n      <th>hobby</th>\n      <th>weight</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>1985</td>\n      <td>NaN</td>\n      <td>Biking</td>\n      <td>68</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>1984</td>\n      <td>3.0</td>\n      <td>Dancing</td>\n      <td>83</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>1992</td>\n      <td>0.0</td>\n      <td>NaN</td>\n      <td>112</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "         birthyear  children    hobby  weight\nalice         1985       NaN   Biking      68\nbob           1984       3.0  Dancing      83\ncharles       1992       0.0      NaN     112"
  },
  "execution_count": 51,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

A few things to note:

  • the Series were automatically aligned based on their index,
  • missing values are represented as NaN,
  • Series names are ignored (the name "year" was dropped),
  • DataFrames are displayed nicely in Jupyter notebooks, woohoo!

You can access columns pretty much as you would expect. They are returned as Series objects:

```{.python .input} people[“birthyear”]


```{.json .output n=None}
[
 {
  "data": {
   "text/plain": "alice      1985\nbob        1984\ncharles    1992\nName: birthyear, dtype: int64"
  },
  "execution_count": 52,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

You can also get multiple columns at once:

```{.python .input} people[[“birthyear”, “hobby”]]


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>birthyear</th>\n      <th>hobby</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>1985</td>\n      <td>Biking</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>1984</td>\n      <td>Dancing</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>1992</td>\n      <td>NaN</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "         birthyear    hobby\nalice         1985   Biking\nbob           1984  Dancing\ncharles       1992      NaN"
  },
  "execution_count": 53,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

If you pass a list of columns and/or index row labels to the DataFrame constructor, it will guarantee that these columns and/or rows will exist, in that order, and no other column/row will exist. For example:

```{.python .input} d2 = pd.DataFrame( people_dict, columns=[“birthyear”, “weight”, “height”], index=[“bob”, “alice”, “eugene”] ) d2


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>birthyear</th>\n      <th>weight</th>\n      <th>height</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>bob</th>\n      <td>1984.0</td>\n      <td>83.0</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>alice</th>\n      <td>1985.0</td>\n      <td>68.0</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>eugene</th>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "        birthyear  weight height\nbob        1984.0    83.0    NaN\nalice      1985.0    68.0    NaN\neugene        NaN     NaN    NaN"
  },
  "execution_count": 54,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Another convenient way to create a DataFrame is to pass all the values to the constructor as an ndarray, or a list of lists, and specify the column names and row index labels separately:

```{.python .input} values = [ [1985, np.nan, “Biking”, 68], [1984, 3, “Dancing”, 83], [1992, 0, np.nan, 112] ] d3 = pd.DataFrame( values, columns=[“birthyear”, “children”, “hobby”, “weight”], index=[“alice”, “bob”, “charles”] ) d3


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>birthyear</th>\n      <th>children</th>\n      <th>hobby</th>\n      <th>weight</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>1985</td>\n      <td>NaN</td>\n      <td>Biking</td>\n      <td>68</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>1984</td>\n      <td>3.0</td>\n      <td>Dancing</td>\n      <td>83</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>1992</td>\n      <td>0.0</td>\n      <td>NaN</td>\n      <td>112</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "         birthyear  children    hobby  weight\nalice         1985       NaN   Biking      68\nbob           1984       3.0  Dancing      83\ncharles       1992       0.0      NaN     112"
  },
  "execution_count": 55,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

To specify missing values, you can either use np.nan or NumPy’s masked arrays:

```{.python .input} masked_array = np.ma.asarray(values, dtype=np.object) masked_array[(0, 2), (1, 2)] = np.ma.masked d3 = pd.DataFrame( masked_array, columns=[“birthyear”, “children”, “hobby”, “weight”], index=[“alice”, “bob”, “charles”] ) d3


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>birthyear</th>\n      <th>children</th>\n      <th>hobby</th>\n      <th>weight</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>1985</td>\n      <td>NaN</td>\n      <td>Biking</td>\n      <td>68</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>1984</td>\n      <td>3</td>\n      <td>Dancing</td>\n      <td>83</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>1992</td>\n      <td>0</td>\n      <td>NaN</td>\n      <td>112</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "        birthyear children    hobby weight\nalice        1985      NaN   Biking     68\nbob          1984        3  Dancing     83\ncharles      1992        0      NaN    112"
  },
  "execution_count": 56,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Instead of an ndarray, you can also pass a DataFrame object:

```{.python .input} d4 = pd.DataFrame( d3, columns=[“hobby”, “children”], index=[“alice”, “bob”] ) d4


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>hobby</th>\n      <th>children</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>Biking</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>Dancing</td>\n      <td>3</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "         hobby children\nalice   Biking      NaN\nbob    Dancing        3"
  },
  "execution_count": 57,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

It is also possible to create a DataFrame with a dictionary (or list) of dictionaries (or list):

```{.python .input} people = pd.DataFrame({ “birthyear”: {“alice”:1985, “bob”: 1984, “charles”: 1992}, “hobby”: {“alice”:”Biking”, “bob”: “Dancing”}, “weight”: {“alice”:68, “bob”: 83, “charles”: 112}, “children”: {“bob”: 3, “charles”: 0} }) people


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>birthyear</th>\n      <th>children</th>\n      <th>hobby</th>\n      <th>weight</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>1985</td>\n      <td>NaN</td>\n      <td>Biking</td>\n      <td>68</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>1984</td>\n      <td>3.0</td>\n      <td>Dancing</td>\n      <td>83</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>1992</td>\n      <td>0.0</td>\n      <td>NaN</td>\n      <td>112</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "         birthyear  children    hobby  weight\nalice         1985       NaN   Biking      68\nbob           1984       3.0  Dancing      83\ncharles       1992       0.0      NaN     112"
  },
  "execution_count": 58,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Multi-indexing

If all columns are tuples of the same size, then they are understood as a multi- index. The same goes for row index labels. For example:

```{.python .input} d5 = pd.DataFrame( { (“public”, “birthyear”): {(“Paris”,”alice”):1985, (“Paris”,”bob”): 1984, (“London”,”charles”): 1992}, (“public”, “hobby”): {(“Paris”,”alice”):”Biking”, (“Paris”,”bob”): “Dancing”}, (“private”, “weight”): {(“Paris”,”alice”):68, (“Paris”,”bob”): 83, (“London”,”charles”): 112}, (“private”, “children”): {(“Paris”, “alice”):np.nan, (“Paris”,”bob”): 3, (“London”,”charles”): 0} } ) d5


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr>\n      <th></th>\n      <th></th>\n      <th colspan=\"2\" halign=\"left\">private</th>\n      <th colspan=\"2\" halign=\"left\">public</th>\n    </tr>\n    <tr>\n      <th></th>\n      <th></th>\n      <th>children</th>\n      <th>weight</th>\n      <th>birthyear</th>\n      <th>hobby</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>London</th>\n      <th>charles</th>\n      <td>0.0</td>\n      <td>112</td>\n      <td>1992</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th rowspan=\"2\" valign=\"top\">Paris</th>\n      <th>alice</th>\n      <td>NaN</td>\n      <td>68</td>\n      <td>1985</td>\n      <td>Biking</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>3.0</td>\n      <td>83</td>\n      <td>1984</td>\n      <td>Dancing</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "                private           public         \n               children weight birthyear    hobby\nLondon charles      0.0    112      1992      NaN\nParis  alice        NaN     68      1985   Biking\n       bob          3.0     83      1984  Dancing"
  },
  "execution_count": 59,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

You can now get a DataFrame containing all the "public" columns very simply:

```{.python .input} d5[“public”]


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th></th>\n      <th>birthyear</th>\n      <th>hobby</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>London</th>\n      <th>charles</th>\n      <td>1992</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th rowspan=\"2\" valign=\"top\">Paris</th>\n      <th>alice</th>\n      <td>1985</td>\n      <td>Biking</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>1984</td>\n      <td>Dancing</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "                birthyear    hobby\nLondon charles       1992      NaN\nParis  alice         1985   Biking\n       bob           1984  Dancing"
  },
  "execution_count": 60,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

```{.python .input} d5[“public”, “hobby”] ## Same result as d5[“public”][“hobby”]


```{.json .output n=None}
[
 {
  "data": {
   "text/plain": "London  charles        NaN\nParis   alice       Biking\n        bob        Dancing\nName: (public, hobby), dtype: object"
  },
  "execution_count": 61,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Dropping a level

Let’s look at d5 again:

```{.python .input} d5


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr>\n      <th></th>\n      <th></th>\n      <th colspan=\"2\" halign=\"left\">private</th>\n      <th colspan=\"2\" halign=\"left\">public</th>\n    </tr>\n    <tr>\n      <th></th>\n      <th></th>\n      <th>children</th>\n      <th>weight</th>\n      <th>birthyear</th>\n      <th>hobby</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>London</th>\n      <th>charles</th>\n      <td>0.0</td>\n      <td>112</td>\n      <td>1992</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th rowspan=\"2\" valign=\"top\">Paris</th>\n      <th>alice</th>\n      <td>NaN</td>\n      <td>68</td>\n      <td>1985</td>\n      <td>Biking</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>3.0</td>\n      <td>83</td>\n      <td>1984</td>\n      <td>Dancing</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "                private           public         \n               children weight birthyear    hobby\nLondon charles      0.0    112      1992      NaN\nParis  alice        NaN     68      1985   Biking\n       bob          3.0     83      1984  Dancing"
  },
  "execution_count": 62,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

There are two levels of columns, and two levels of indices. We can drop a column level by calling droplevel() (the same goes for indices):

```{.python .input} d5.columns = d5.columns.droplevel(level = 0) d5


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th></th>\n      <th>children</th>\n      <th>weight</th>\n      <th>birthyear</th>\n      <th>hobby</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>London</th>\n      <th>charles</th>\n      <td>0.0</td>\n      <td>112</td>\n      <td>1992</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th rowspan=\"2\" valign=\"top\">Paris</th>\n      <th>alice</th>\n      <td>NaN</td>\n      <td>68</td>\n      <td>1985</td>\n      <td>Biking</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>3.0</td>\n      <td>83</td>\n      <td>1984</td>\n      <td>Dancing</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "                children  weight  birthyear    hobby\nLondon charles       0.0     112       1992      NaN\nParis  alice         NaN      68       1985   Biking\n       bob           3.0      83       1984  Dancing"
  },
  "execution_count": 63,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Transposing

You can swap columns and indices using the T attribute:

```{.python .input} d6 = d5.T d6


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr>\n      <th></th>\n      <th>London</th>\n      <th colspan=\"2\" halign=\"left\">Paris</th>\n    </tr>\n    <tr>\n      <th></th>\n      <th>charles</th>\n      <th>alice</th>\n      <th>bob</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>children</th>\n      <td>0</td>\n      <td>NaN</td>\n      <td>3</td>\n    </tr>\n    <tr>\n      <th>weight</th>\n      <td>112</td>\n      <td>68</td>\n      <td>83</td>\n    </tr>\n    <tr>\n      <th>birthyear</th>\n      <td>1992</td>\n      <td>1985</td>\n      <td>1984</td>\n    </tr>\n    <tr>\n      <th>hobby</th>\n      <td>NaN</td>\n      <td>Biking</td>\n      <td>Dancing</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "           London   Paris         \n          charles   alice      bob\nchildren        0     NaN        3\nweight        112      68       83\nbirthyear    1992    1985     1984\nhobby         NaN  Biking  Dancing"
  },
  "execution_count": 64,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Stacking and unstacking levels

Calling the stack() method will push the lowest column level after the lowest index:

```{.python .input} d7 = d6.stack() d7


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th></th>\n      <th>London</th>\n      <th>Paris</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th rowspan=\"2\" valign=\"top\">children</th>\n      <th>bob</th>\n      <td>NaN</td>\n      <td>3</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>0</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th rowspan=\"3\" valign=\"top\">weight</th>\n      <th>alice</th>\n      <td>NaN</td>\n      <td>68</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>NaN</td>\n      <td>83</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>112</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th rowspan=\"3\" valign=\"top\">birthyear</th>\n      <th>alice</th>\n      <td>NaN</td>\n      <td>1985</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>NaN</td>\n      <td>1984</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>1992</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th rowspan=\"2\" valign=\"top\">hobby</th>\n      <th>alice</th>\n      <td>NaN</td>\n      <td>Biking</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>NaN</td>\n      <td>Dancing</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "                  London    Paris\nchildren  bob        NaN        3\n          charles      0      NaN\nweight    alice      NaN       68\n          bob        NaN       83\n          charles    112      NaN\nbirthyear alice      NaN     1985\n          bob        NaN     1984\n          charles   1992      NaN\nhobby     alice      NaN   Biking\n          bob        NaN  Dancing"
  },
  "execution_count": 65,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Note that many NaN values appeared. This makes sense because many new combinations did not exist before (eg. there was no bob in London).

Calling unstack() will do the reverse, once again creating many NaN values.

```{.python .input} d8 = d7.unstack() d8


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr>\n      <th></th>\n      <th colspan=\"3\" halign=\"left\">London</th>\n      <th colspan=\"3\" halign=\"left\">Paris</th>\n    </tr>\n    <tr>\n      <th></th>\n      <th>alice</th>\n      <th>bob</th>\n      <th>charles</th>\n      <th>alice</th>\n      <th>bob</th>\n      <th>charles</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>children</th>\n      <td>None</td>\n      <td>NaN</td>\n      <td>0</td>\n      <td>None</td>\n      <td>3</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>weight</th>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>112</td>\n      <td>68</td>\n      <td>83</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>birthyear</th>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>1992</td>\n      <td>1985</td>\n      <td>1984</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>hobby</th>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>None</td>\n      <td>Biking</td>\n      <td>Dancing</td>\n      <td>None</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "          London                Paris                 \n           alice  bob charles   alice      bob charles\nchildren    None  NaN       0    None        3     NaN\nweight       NaN  NaN     112      68       83     NaN\nbirthyear    NaN  NaN    1992    1985     1984     NaN\nhobby        NaN  NaN    None  Biking  Dancing    None"
  },
  "execution_count": 66,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

If we call unstack again, we end up with a Series object:

```{.python .input} d9 = d8.unstack() d9


```{.json .output n=None}
[
 {
  "data": {
   "text/plain": "London  alice    children        None\n                 weight           NaN\n                 birthyear        NaN\n                 hobby            NaN\n        bob      children         NaN\n                 weight           NaN\n                 birthyear        NaN\n                 hobby            NaN\n        charles  children           0\n                 weight           112\n                 birthyear       1992\n                 hobby           None\nParis   alice    children        None\n                 weight            68\n                 birthyear       1985\n                 hobby         Biking\n        bob      children           3\n                 weight            83\n                 birthyear       1984\n                 hobby        Dancing\n        charles  children         NaN\n                 weight           NaN\n                 birthyear        NaN\n                 hobby           None\ndtype: object"
  },
  "execution_count": 67,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

The stack() and unstack() methods let you select the level to stack/unstack. You can even stack/unstack multiple levels at once:

```{.python .input} d10 = d9.unstack(level = (0,1)) d10


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr>\n      <th></th>\n      <th colspan=\"3\" halign=\"left\">London</th>\n      <th colspan=\"3\" halign=\"left\">Paris</th>\n    </tr>\n    <tr>\n      <th></th>\n      <th>alice</th>\n      <th>bob</th>\n      <th>charles</th>\n      <th>alice</th>\n      <th>bob</th>\n      <th>charles</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>children</th>\n      <td>None</td>\n      <td>NaN</td>\n      <td>0</td>\n      <td>None</td>\n      <td>3</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>weight</th>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>112</td>\n      <td>68</td>\n      <td>83</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>birthyear</th>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>1992</td>\n      <td>1985</td>\n      <td>1984</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>hobby</th>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>None</td>\n      <td>Biking</td>\n      <td>Dancing</td>\n      <td>None</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "          London                Paris                 \n           alice  bob charles   alice      bob charles\nchildren    None  NaN       0    None        3     NaN\nweight       NaN  NaN     112      68       83     NaN\nbirthyear    NaN  NaN    1992    1985     1984     NaN\nhobby        NaN  NaN    None  Biking  Dancing    None"
  },
  "execution_count": 68,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Most methods return modified copies

As you may have noticed, the stack() and unstack() methods do not modify the object they apply to. Instead, they work on a copy and return that copy. This is true of most methods in pandas.

Accessing rows

Let’s go back to the people DataFrame:

```{.python .input} people


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>birthyear</th>\n      <th>children</th>\n      <th>hobby</th>\n      <th>weight</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>1985</td>\n      <td>NaN</td>\n      <td>Biking</td>\n      <td>68</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>1984</td>\n      <td>3.0</td>\n      <td>Dancing</td>\n      <td>83</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>1992</td>\n      <td>0.0</td>\n      <td>NaN</td>\n      <td>112</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "         birthyear  children    hobby  weight\nalice         1985       NaN   Biking      68\nbob           1984       3.0  Dancing      83\ncharles       1992       0.0      NaN     112"
  },
  "execution_count": 69,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

The loc attribute lets you access rows instead of columns. The result is a Series object in which the DataFrame’s column names are mapped to row index labels:

```{.python .input} people.loc[“charles”]


```{.json .output n=None}
[
 {
  "data": {
   "text/plain": "birthyear    1992\nchildren        0\nhobby         NaN\nweight        112\nName: charles, dtype: object"
  },
  "execution_count": 70,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

You can also access rows by integer location using the iloc attribute:

```{.python .input} people.iloc[2]


```{.json .output n=None}
[
 {
  "data": {
   "text/plain": "birthyear    1992\nchildren        0\nhobby         NaN\nweight        112\nName: charles, dtype: object"
  },
  "execution_count": 71,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

You can also get a slice of rows, and this returns a DataFrame object:

```{.python .input} people.iloc[1:3]


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>birthyear</th>\n      <th>children</th>\n      <th>hobby</th>\n      <th>weight</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>bob</th>\n      <td>1984</td>\n      <td>3.0</td>\n      <td>Dancing</td>\n      <td>83</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>1992</td>\n      <td>0.0</td>\n      <td>NaN</td>\n      <td>112</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "         birthyear  children    hobby  weight\nbob           1984       3.0  Dancing      83\ncharles       1992       0.0      NaN     112"
  },
  "execution_count": 72,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Finally, you can pass a boolean array to get the matching rows:

```{.python .input} people[np.array([True, False, True])]


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>birthyear</th>\n      <th>children</th>\n      <th>hobby</th>\n      <th>weight</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>1985</td>\n      <td>NaN</td>\n      <td>Biking</td>\n      <td>68</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>1992</td>\n      <td>0.0</td>\n      <td>NaN</td>\n      <td>112</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "         birthyear  children   hobby  weight\nalice         1985       NaN  Biking      68\ncharles       1992       0.0     NaN     112"
  },
  "execution_count": 73,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

This is most useful when combined with boolean expressions:

```{.python .input} people[people[“birthyear”] < 1990]


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>birthyear</th>\n      <th>children</th>\n      <th>hobby</th>\n      <th>weight</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>1985</td>\n      <td>NaN</td>\n      <td>Biking</td>\n      <td>68</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>1984</td>\n      <td>3.0</td>\n      <td>Dancing</td>\n      <td>83</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "       birthyear  children    hobby  weight\nalice       1985       NaN   Biking      68\nbob         1984       3.0  Dancing      83"
  },
  "execution_count": 74,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Adding and removing columns

You can generally treat DataFrame objects like dictionaries of Series, so the following work fine:

```{.python .input} people


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>birthyear</th>\n      <th>children</th>\n      <th>hobby</th>\n      <th>weight</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>1985</td>\n      <td>NaN</td>\n      <td>Biking</td>\n      <td>68</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>1984</td>\n      <td>3.0</td>\n      <td>Dancing</td>\n      <td>83</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>1992</td>\n      <td>0.0</td>\n      <td>NaN</td>\n      <td>112</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "         birthyear  children    hobby  weight\nalice         1985       NaN   Biking      68\nbob           1984       3.0  Dancing      83\ncharles       1992       0.0      NaN     112"
  },
  "execution_count": 75,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

```{.python .input} people[“age”] = 2018 - people[“birthyear”] ## adds a new column “age” people[“over 30”] = people[“age”] > 30 ## adds another column “over 30” birthyears = people.pop(“birthyear”) del people[“children”]

people


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>hobby</th>\n      <th>weight</th>\n      <th>age</th>\n      <th>over 30</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>Biking</td>\n      <td>68</td>\n      <td>33</td>\n      <td>True</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>Dancing</td>\n      <td>83</td>\n      <td>34</td>\n      <td>True</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>NaN</td>\n      <td>112</td>\n      <td>26</td>\n      <td>False</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "           hobby  weight  age  over 30\nalice     Biking      68   33     True\nbob      Dancing      83   34     True\ncharles      NaN     112   26    False"
  },
  "execution_count": 76,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

```{.python .input} birthyears


```{.json .output n=None}
[
 {
  "data": {
   "text/plain": "alice      1985\nbob        1984\ncharles    1992\nName: birthyear, dtype: int64"
  },
  "execution_count": 77,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

When you add a new colum, it must have the same number of rows. Missing rows are filled with NaN, and extra rows are ignored:

```{.python .input} people[“pets”] = pd.Series({“bob”: 0, “charles”: 5, “eugene”:1}) ## alice is missing, eugene is ignored people


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>hobby</th>\n      <th>weight</th>\n      <th>age</th>\n      <th>over 30</th>\n      <th>pets</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>Biking</td>\n      <td>68</td>\n      <td>33</td>\n      <td>True</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>Dancing</td>\n      <td>83</td>\n      <td>34</td>\n      <td>True</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>NaN</td>\n      <td>112</td>\n      <td>26</td>\n      <td>False</td>\n      <td>5.0</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "           hobby  weight  age  over 30  pets\nalice     Biking      68   33     True   NaN\nbob      Dancing      83   34     True   0.0\ncharles      NaN     112   26    False   5.0"
  },
  "execution_count": 78,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

When adding a new column, it is added at the end (on the right) by default. You can also insert a column anywhere else using the insert() method:

```{.python .input} people.insert(1, “height”, [172, 181, 185]) people


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>hobby</th>\n      <th>height</th>\n      <th>weight</th>\n      <th>age</th>\n      <th>over 30</th>\n      <th>pets</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>Biking</td>\n      <td>172</td>\n      <td>68</td>\n      <td>33</td>\n      <td>True</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>Dancing</td>\n      <td>181</td>\n      <td>83</td>\n      <td>34</td>\n      <td>True</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>NaN</td>\n      <td>185</td>\n      <td>112</td>\n      <td>26</td>\n      <td>False</td>\n      <td>5.0</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "           hobby  height  weight  age  over 30  pets\nalice     Biking     172      68   33     True   NaN\nbob      Dancing     181      83   34     True   0.0\ncharles      NaN     185     112   26    False   5.0"
  },
  "execution_count": 79,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Assigning new columns

You can also create new columns by calling the assign() method. Note that this returns a new DataFrame object, the original is not modified:

```{.python .input} people.assign( body_mass_index = people[“weight”] / (people[“height”] / 100) ** 2, has_pets = people[“pets”] > 0 )


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>hobby</th>\n      <th>height</th>\n      <th>weight</th>\n      <th>age</th>\n      <th>over 30</th>\n      <th>pets</th>\n      <th>body_mass_index</th>\n      <th>has_pets</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>Biking</td>\n      <td>172</td>\n      <td>68</td>\n      <td>33</td>\n      <td>True</td>\n      <td>NaN</td>\n      <td>22.985398</td>\n      <td>False</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>Dancing</td>\n      <td>181</td>\n      <td>83</td>\n      <td>34</td>\n      <td>True</td>\n      <td>0.0</td>\n      <td>25.335002</td>\n      <td>False</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>NaN</td>\n      <td>185</td>\n      <td>112</td>\n      <td>26</td>\n      <td>False</td>\n      <td>5.0</td>\n      <td>32.724617</td>\n      <td>True</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "           hobby  height  weight  age  over 30  pets  body_mass_index  \\\nalice     Biking     172      68   33     True   NaN        22.985398   \nbob      Dancing     181      83   34     True   0.0        25.335002   \ncharles      NaN     185     112   26    False   5.0        32.724617   \n\n         has_pets  \nalice       False  \nbob         False  \ncharles      True  "
  },
  "execution_count": 80,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Note that you cannot access columns created within the same assignment:

```{.python .input} try: people.assign( body_mass_index = people[“weight”] / (people[“height”] / 100) ** 2, overweight = people[“body_mass_index”] > 25 ) except KeyError as e: print(“Key error:”, e)


```{.json .output n=None}
[
 {
  "name": "stdout",
  "output_type": "stream",
  "text": "Key error: 'body_mass_index'\n"
 }
]

The solution is to split this assignment in two consecutive assignments:

```{.python .input} d6 = people.assign(body_mass_index = people[“weight”] / (people[“height”] / 100) ** 2) d6.assign(overweight = d6[“body_mass_index”] > 25)


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>hobby</th>\n      <th>height</th>\n      <th>weight</th>\n      <th>age</th>\n      <th>over 30</th>\n      <th>pets</th>\n      <th>body_mass_index</th>\n      <th>overweight</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>Biking</td>\n      <td>172</td>\n      <td>68</td>\n      <td>33</td>\n      <td>True</td>\n      <td>NaN</td>\n      <td>22.985398</td>\n      <td>False</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>Dancing</td>\n      <td>181</td>\n      <td>83</td>\n      <td>34</td>\n      <td>True</td>\n      <td>0.0</td>\n      <td>25.335002</td>\n      <td>True</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>NaN</td>\n      <td>185</td>\n      <td>112</td>\n      <td>26</td>\n      <td>False</td>\n      <td>5.0</td>\n      <td>32.724617</td>\n      <td>True</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "           hobby  height  weight  age  over 30  pets  body_mass_index  \\\nalice     Biking     172      68   33     True   NaN        22.985398   \nbob      Dancing     181      83   34     True   0.0        25.335002   \ncharles      NaN     185     112   26    False   5.0        32.724617   \n\n         overweight  \nalice         False  \nbob            True  \ncharles        True  "
  },
  "execution_count": 82,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Having to create a temporary variable d6 is not very convenient. You may want to just chain the assigment calls, but it does not work because the people object is not actually modified by the first assignment:

```{.python .input} try: (people .assign(body_mass_index = people[“weight”] / (people[“height”] / 100) ** 2) .assign(overweight = people[“body_mass_index”] > 25) ) except KeyError as e: print(“Key error:”, e)


```{.json .output n=None}
[
 {
  "name": "stdout",
  "output_type": "stream",
  "text": "Key error: 'body_mass_index'\n"
 }
]

But fear not, there is a simple solution. You can pass a function to the assign() method (typically a lambda function), and this function will be called with the DataFrame as a parameter:

```{.python .input} (people .assign(body_mass_index = lambda df: df[“weight”] / (df[“height”] / 100) ** 2) .assign(overweight = lambda df: df[“body_mass_index”] > 25) )


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>hobby</th>\n      <th>height</th>\n      <th>weight</th>\n      <th>age</th>\n      <th>over 30</th>\n      <th>pets</th>\n      <th>body_mass_index</th>\n      <th>overweight</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>Biking</td>\n      <td>172</td>\n      <td>68</td>\n      <td>33</td>\n      <td>True</td>\n      <td>NaN</td>\n      <td>22.985398</td>\n      <td>False</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>Dancing</td>\n      <td>181</td>\n      <td>83</td>\n      <td>34</td>\n      <td>True</td>\n      <td>0.0</td>\n      <td>25.335002</td>\n      <td>True</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>NaN</td>\n      <td>185</td>\n      <td>112</td>\n      <td>26</td>\n      <td>False</td>\n      <td>5.0</td>\n      <td>32.724617</td>\n      <td>True</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "           hobby  height  weight  age  over 30  pets  body_mass_index  \\\nalice     Biking     172      68   33     True   NaN        22.985398   \nbob      Dancing     181      83   34     True   0.0        25.335002   \ncharles      NaN     185     112   26    False   5.0        32.724617   \n\n         overweight  \nalice         False  \nbob            True  \ncharles        True  "
  },
  "execution_count": 84,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Problem solved!

Evaluating an expression

A great feature supported by pandas is expression evaluation. This relies on the numexpr library which must be installed.

```{.python .input} people.eval(“weight / (height/100) ** 2 > 25”)


```{.json .output n=None}
[
 {
  "data": {
   "text/plain": "alice      False\nbob         True\ncharles     True\ndtype: bool"
  },
  "execution_count": 85,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Assignment expressions are also supported. Let’s set inplace=True to directly modify the DataFrame rather than getting a modified copy:

```{.python .input} people.eval(“body_mass_index = weight / (height/100) ** 2”, inplace=True) people


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>hobby</th>\n      <th>height</th>\n      <th>weight</th>\n      <th>age</th>\n      <th>over 30</th>\n      <th>pets</th>\n      <th>body_mass_index</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>Biking</td>\n      <td>172</td>\n      <td>68</td>\n      <td>33</td>\n      <td>True</td>\n      <td>NaN</td>\n      <td>22.985398</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>Dancing</td>\n      <td>181</td>\n      <td>83</td>\n      <td>34</td>\n      <td>True</td>\n      <td>0.0</td>\n      <td>25.335002</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>NaN</td>\n      <td>185</td>\n      <td>112</td>\n      <td>26</td>\n      <td>False</td>\n      <td>5.0</td>\n      <td>32.724617</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "           hobby  height  weight  age  over 30  pets  body_mass_index\nalice     Biking     172      68   33     True   NaN        22.985398\nbob      Dancing     181      83   34     True   0.0        25.335002\ncharles      NaN     185     112   26    False   5.0        32.724617"
  },
  "execution_count": 86,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

You can use a local or global variable in an expression by prefixing it with '@':

```{.python .input} overweight_threshold = 30 people.eval(“overweight = body_mass_index > @overweight_threshold”, inplace=True) people


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>hobby</th>\n      <th>height</th>\n      <th>weight</th>\n      <th>age</th>\n      <th>over 30</th>\n      <th>pets</th>\n      <th>body_mass_index</th>\n      <th>overweight</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>Biking</td>\n      <td>172</td>\n      <td>68</td>\n      <td>33</td>\n      <td>True</td>\n      <td>NaN</td>\n      <td>22.985398</td>\n      <td>False</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>Dancing</td>\n      <td>181</td>\n      <td>83</td>\n      <td>34</td>\n      <td>True</td>\n      <td>0.0</td>\n      <td>25.335002</td>\n      <td>False</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>NaN</td>\n      <td>185</td>\n      <td>112</td>\n      <td>26</td>\n      <td>False</td>\n      <td>5.0</td>\n      <td>32.724617</td>\n      <td>True</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "           hobby  height  weight  age  over 30  pets  body_mass_index  \\\nalice     Biking     172      68   33     True   NaN        22.985398   \nbob      Dancing     181      83   34     True   0.0        25.335002   \ncharles      NaN     185     112   26    False   5.0        32.724617   \n\n         overweight  \nalice         False  \nbob           False  \ncharles        True  "
  },
  "execution_count": 87,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Querying a DataFrame

The query() method lets you filter a DataFrame based on a query expression:

```{.python .input} people.query(“age > 30 and pets == 0”)


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>hobby</th>\n      <th>height</th>\n      <th>weight</th>\n      <th>age</th>\n      <th>over 30</th>\n      <th>pets</th>\n      <th>body_mass_index</th>\n      <th>overweight</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>bob</th>\n      <td>Dancing</td>\n      <td>181</td>\n      <td>83</td>\n      <td>34</td>\n      <td>True</td>\n      <td>0.0</td>\n      <td>25.335002</td>\n      <td>False</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "       hobby  height  weight  age  over 30  pets  body_mass_index  overweight\nbob  Dancing     181      83   34     True   0.0        25.335002       False"
  },
  "execution_count": 88,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Sorting a DataFrame

You can sort a DataFrame by calling its sort_index method. By default it sorts the rows by their index label, in ascending order, but let’s reverse the order:

```{.python .input} people.sort_index(ascending=False)


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>hobby</th>\n      <th>height</th>\n      <th>weight</th>\n      <th>age</th>\n      <th>over 30</th>\n      <th>pets</th>\n      <th>body_mass_index</th>\n      <th>overweight</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>charles</th>\n      <td>NaN</td>\n      <td>185</td>\n      <td>112</td>\n      <td>26</td>\n      <td>False</td>\n      <td>5.0</td>\n      <td>32.724617</td>\n      <td>True</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>Dancing</td>\n      <td>181</td>\n      <td>83</td>\n      <td>34</td>\n      <td>True</td>\n      <td>0.0</td>\n      <td>25.335002</td>\n      <td>False</td>\n    </tr>\n    <tr>\n      <th>alice</th>\n      <td>Biking</td>\n      <td>172</td>\n      <td>68</td>\n      <td>33</td>\n      <td>True</td>\n      <td>NaN</td>\n      <td>22.985398</td>\n      <td>False</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "           hobby  height  weight  age  over 30  pets  body_mass_index  \\\ncharles      NaN     185     112   26    False   5.0        32.724617   \nbob      Dancing     181      83   34     True   0.0        25.335002   \nalice     Biking     172      68   33     True   NaN        22.985398   \n\n         overweight  \ncharles        True  \nbob           False  \nalice         False  "
  },
  "execution_count": 89,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Note that sort_index returned a sorted copy of the DataFrame. To modify people directly, we can set the inplace argument to True. Also, we can sort the columns instead of the rows by setting axis=1:

```{.python .input} people.sort_index(axis=1, inplace=True) people


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>age</th>\n      <th>body_mass_index</th>\n      <th>height</th>\n      <th>hobby</th>\n      <th>over 30</th>\n      <th>overweight</th>\n      <th>pets</th>\n      <th>weight</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>33</td>\n      <td>22.985398</td>\n      <td>172</td>\n      <td>Biking</td>\n      <td>True</td>\n      <td>False</td>\n      <td>NaN</td>\n      <td>68</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>34</td>\n      <td>25.335002</td>\n      <td>181</td>\n      <td>Dancing</td>\n      <td>True</td>\n      <td>False</td>\n      <td>0.0</td>\n      <td>83</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>26</td>\n      <td>32.724617</td>\n      <td>185</td>\n      <td>NaN</td>\n      <td>False</td>\n      <td>True</td>\n      <td>5.0</td>\n      <td>112</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "         age  body_mass_index  height    hobby  over 30  overweight  pets  \\\nalice     33        22.985398     172   Biking     True       False   NaN   \nbob       34        25.335002     181  Dancing     True       False   0.0   \ncharles   26        32.724617     185      NaN    False        True   5.0   \n\n         weight  \nalice        68  \nbob          83  \ncharles     112  "
  },
  "execution_count": 90,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

To sort the DataFrame by the values instead of the labels, we can use sort_values and specify the column to sort by:

```{.python .input} people.sort_values(by=”age”, inplace=True) people


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>age</th>\n      <th>body_mass_index</th>\n      <th>height</th>\n      <th>hobby</th>\n      <th>over 30</th>\n      <th>overweight</th>\n      <th>pets</th>\n      <th>weight</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>charles</th>\n      <td>26</td>\n      <td>32.724617</td>\n      <td>185</td>\n      <td>NaN</td>\n      <td>False</td>\n      <td>True</td>\n      <td>5.0</td>\n      <td>112</td>\n    </tr>\n    <tr>\n      <th>alice</th>\n      <td>33</td>\n      <td>22.985398</td>\n      <td>172</td>\n      <td>Biking</td>\n      <td>True</td>\n      <td>False</td>\n      <td>NaN</td>\n      <td>68</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>34</td>\n      <td>25.335002</td>\n      <td>181</td>\n      <td>Dancing</td>\n      <td>True</td>\n      <td>False</td>\n      <td>0.0</td>\n      <td>83</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "         age  body_mass_index  height    hobby  over 30  overweight  pets  \\\ncharles   26        32.724617     185      NaN    False        True   5.0   \nalice     33        22.985398     172   Biking     True       False   NaN   \nbob       34        25.335002     181  Dancing     True       False   0.0   \n\n         weight  \ncharles     112  \nalice        68  \nbob          83  "
  },
  "execution_count": 91,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Plotting a DataFrame

Just like for Series, pandas makes it easy to draw nice graphs based on a DataFrame.

For example, it is trivial to create a line plot from a DataFrame’s data by calling its plot method:

```{.python .input} people.plot(kind = “line”, x = “body_mass_index”, y = [“height”, “weight”]) plt.show()


```{.json .output n=None}
[
 {
  "data": {
   "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAELCAYAAADX3k30AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4xLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvAOZPmwAAIABJREFUeJzt3XuUVNWZ9/Hv03f6Agg0qDTYrXLV\nIGqLoiEajRN1HC/zBi/xnSRqZBJNMuPEd8Y471JnMheSmDhmuSa+GghxjcF7ovEyMUYNRke0QRSB\nVlBRGxBaFLk0dNPdz/vHOd11qvpW9K2qT/8+a51VVfvsqnqqxWefs/c5e5u7IyIi8ZWT6QBERGRg\nKdGLiMScEr2ISMwp0YuIxJwSvYhIzCnRi4jEnBK9iEjMKdGLiMScEr2ISMzlZToAgHHjxnllZWWm\nwxARGVJWrFjxkbuX91QvKxJ9ZWUlNTU1mQ5DRGRIMbP30qmnrhsRkZhTohcRiTklehGRmFOiFxGJ\nOSV6EZGYU6IXEYk5JXoRkZjLiuvoP97TxCOrNlFSkEdJYR4lhbmUFOZRWhi8Ls7PJSfHMh2miMiQ\nlBWJftOOvfzNvau6rVNckEj+0eclhXmUhK+DslyKCyL7CnPbG5DSwjyKw9e5ajhEZJjIikQ//eCR\nPPzdU9nT2MyexpbgsamZ3Y3NNDS2sLuxub2sbf/uxma27dpHw0fR/S1pf+eI/NykhqA0fF5cmEdp\nQaTRiDQgiTOO8HVhXnujooZDRLJVViT6/FzjiPLSPn9Oa6uzd3+iIdjT2BI2DonXDU3N7Q3D7vB1\n2/6Pdjex5+OGRIPT1Ix7et9dlJ8Tnm10dmYRNioFnTcSJYW54dlGWyOTS16uhk9EpH9kRaLvLzk5\n1n7EPb4fPs89aDh2R8802s82WmjopEFpa0D2NDazo6GJuk8aks5SWtNsOArzcjqccRR3OLOIdmcl\nGpBEo5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rt/fAAxyDCiRC+ZkjrJ0o4D/gD3D4CtZnY6wfS7T/bwlraJ01ojz9te55lZFXAdcIa7zwIeB4o8\nWCRlDsGqWOcSLkrj7t8gOBOZBKwws7Fphh797ha6HyvLIVioZXZkmxHZ/xmCs4JD0/xuGYaU6CVT\nJpvZ3PD5lwkGKyvN7Miw7K+APxJMxVxpZkeE5ZemfM7PCY7yH3D3lj7GNBLYA3xqZhOAs6H9qHqU\nuz9BsHjHMWH5Ee6+3N1vBOrp26pTy4ALzGyEmZUBfwEQHt2/a2bzw+80M2v7/jlhjMcC14UNlUgH\nSvSSKW8C15jZOuAg4FbgcoIuirYpYO9w933AAuDxsEsldS3OR4FSeu626ZG7v0bQZVML/IqgawaC\nFaUeM7PXgT+RWJjmR+HA8RsE/e6v9eG7VxIssvEawZnJK5HdlwFXmtlrhEsahgPVdwFXuPtm4LvA\n4nC+dJEkmqZYhjQzqwZudfd5mY5FJFvpOnoZsszseoI1US/LdCwi2UxH9BIrZvaPwPyU4gfc/V8H\n4bu/CPwgpfhdd79woL9bpDtK9CIiMafBWBGRmFOiFxGJOSV6EZGYU6IXEYk5JXoRkZj7/4PeaFpA\nYojcAAAAAElFTkSuQmCC\n",
   "text/plain": "<matplotlib.figure.Figure at 0x10b89bf28>"
  },
  "metadata": {
   "tags": []
  },
  "output_type": "display_data"
 }
]

You can pass extra arguments supported by matplotlib’s functions. For example, we can create scatterplot and pass it a list of sizes using the s argument of matplotlib’s scatter() function:

```{.python .input} people.plot(kind = “scatter”, x = “height”, y = “weight”, s=[40, 120, 200]) plt.show()


```{.json .output n=None}
[
 {
  "data": {
   "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYgAAAEKCAYAAAAIO8L1AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4xLCBo\ndHRwOi8vbWF0cGxvdGxpYi5vcmcvAOZPmwAAFY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plain": "<matplotlib.figure.Figure at 0x10b89b7f0>"
  },
  "metadata": {
   "tags": []
  },
  "output_type": "display_data"
 }
]

Again, there are way too many options to list here: the best option is to scroll through the Visualization page in pandas’ documentation, find the plot you are interested in and look at the example code.

Operations on DataFrames

Although DataFrames do not try to mimick NumPy arrays, there are a few similarities. Let’s create a DataFrame to demonstrate this:

```{.python .input} grades_array = np.array([[8,8,9],[10,9,9],[4, 8, 2], [9, 10, 10]]) grades = pd.DataFrame(grades_array, columns=[“sep”, “oct”, “nov”], index=[“alice”,”bob”,”charles”,”darwin”]) grades


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>sep</th>\n      <th>oct</th>\n      <th>nov</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>8</td>\n      <td>8</td>\n      <td>9</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>10</td>\n      <td>9</td>\n      <td>9</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>4</td>\n      <td>8</td>\n      <td>2</td>\n    </tr>\n    <tr>\n      <th>darwin</th>\n      <td>9</td>\n      <td>10</td>\n      <td>10</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "         sep  oct  nov\nalice      8    8    9\nbob       10    9    9\ncharles    4    8    2\ndarwin     9   10   10"
  },
  "execution_count": 94,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

You can apply NumPy mathematical functions on a DataFrame: the function is applied to all values:

```{.python .input} np.sqrt(grades)


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>sep</th>\n      <th>oct</th>\n      <th>nov</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>2.828427</td>\n      <td>2.828427</td>\n      <td>3.000000</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>3.162278</td>\n      <td>3.000000</td>\n      <td>3.000000</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>2.000000</td>\n      <td>2.828427</td>\n      <td>1.414214</td>\n    </tr>\n    <tr>\n      <th>darwin</th>\n      <td>3.000000</td>\n      <td>3.162278</td>\n      <td>3.162278</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "              sep       oct       nov\nalice    2.828427  2.828427  3.000000\nbob      3.162278  3.000000  3.000000\ncharles  2.000000  2.828427  1.414214\ndarwin   3.000000  3.162278  3.162278"
  },
  "execution_count": 95,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Similarly, adding a single value to a DataFrame will add that value to all elements in the DataFrame. This is called broadcasting:

```{.python .input} grades + 1


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>sep</th>\n      <th>oct</th>\n      <th>nov</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>9</td>\n      <td>9</td>\n      <td>10</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>11</td>\n      <td>10</td>\n      <td>10</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>5</td>\n      <td>9</td>\n      <td>3</td>\n    </tr>\n    <tr>\n      <th>darwin</th>\n      <td>10</td>\n      <td>11</td>\n      <td>11</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "         sep  oct  nov\nalice      9    9   10\nbob       11   10   10\ncharles    5    9    3\ndarwin    10   11   11"
  },
  "execution_count": 96,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Of course, the same is true for all other binary operations, including arithmetic (*,/,**…) and conditional (>, ==…) operations:

```{.python .input} grades >= 5


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>sep</th>\n      <th>oct</th>\n      <th>nov</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>True</td>\n      <td>True</td>\n      <td>True</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>True</td>\n      <td>True</td>\n      <td>True</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>False</td>\n      <td>True</td>\n      <td>False</td>\n    </tr>\n    <tr>\n      <th>darwin</th>\n      <td>True</td>\n      <td>True</td>\n      <td>True</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "           sep   oct    nov\nalice     True  True   True\nbob       True  True   True\ncharles  False  True  False\ndarwin    True  True   True"
  },
  "execution_count": 97,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Aggregation operations, such as computing the max, the sum or the mean of a DataFrame, apply to each column, and you get back a Series object:

```{.python .input} grades.mean()


```{.json .output n=None}
[
 {
  "data": {
   "text/plain": "sep    7.75\noct    8.75\nnov    7.50\ndtype: float64"
  },
  "execution_count": 98,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

The all method is also an aggregation operation: it checks whether all values are True or not. Let’s see during which months all students got a grade greater than 5:

```{.python .input} (grades > 5).all()


```{.json .output n=None}
[
 {
  "data": {
   "text/plain": "sep    False\noct     True\nnov    False\ndtype: bool"
  },
  "execution_count": 99,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Most of these functions take an optional axis parameter which lets you specify along which axis of the DataFrame you want the operation executed. The default is axis=0, meaning that the operation is executed vertically (on each column). You can set axis=1 to execute the operation horizontally (on each row). For example, let’s find out which students had all grades greater than 5:

```{.python .input} (grades > 5).all(axis = 1)


```{.json .output n=None}
[
 {
  "data": {
   "text/plain": "alice       True\nbob         True\ncharles    False\ndarwin      True\ndtype: bool"
  },
  "execution_count": 100,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

The any method returns True if any value is True. Let’s see who got at least one grade 10:

```{.python .input} (grades == 10).any(axis = 1)


```{.json .output n=None}
[
 {
  "data": {
   "text/plain": "alice      False\nbob         True\ncharles    False\ndarwin      True\ndtype: bool"
  },
  "execution_count": 101,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

If you add a Series object to a DataFrame (or execute any other binary operation), pandas attempts to broadcast the operation to all rows in the DataFrame. This only works if the Series has the same size as the DataFrames rows. For example, let’s substract the mean of the DataFrame (a Series object) from the DataFrame:

```{.python .input} grades - grades.mean() ## equivalent to: grades - [7.75, 8.75, 7.50]


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>sep</th>\n      <th>oct</th>\n      <th>nov</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>0.25</td>\n      <td>-0.75</td>\n      <td>1.5</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>2.25</td>\n      <td>0.25</td>\n      <td>1.5</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>-3.75</td>\n      <td>-0.75</td>\n      <td>-5.5</td>\n    </tr>\n    <tr>\n      <th>darwin</th>\n      <td>1.25</td>\n      <td>1.25</td>\n      <td>2.5</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "          sep   oct  nov\nalice    0.25 -0.75  1.5\nbob      2.25  0.25  1.5\ncharles -3.75 -0.75 -5.5\ndarwin   1.25  1.25  2.5"
  },
  "execution_count": 102,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

We substracted 7.75 from all September grades, 8.75 from October grades and 7.50 from November grades. It is equivalent to substracting this DataFrame:

```{.python .input} pd.DataFrame([[7.75, 8.75, 7.50]]*4, index=grades.index, columns=grades.columns)


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>sep</th>\n      <th>oct</th>\n      <th>nov</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>7.75</td>\n      <td>8.75</td>\n      <td>7.5</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>7.75</td>\n      <td>8.75</td>\n      <td>7.5</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>7.75</td>\n      <td>8.75</td>\n      <td>7.5</td>\n    </tr>\n    <tr>\n      <th>darwin</th>\n      <td>7.75</td>\n      <td>8.75</td>\n      <td>7.5</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "          sep   oct  nov\nalice    7.75  8.75  7.5\nbob      7.75  8.75  7.5\ncharles  7.75  8.75  7.5\ndarwin   7.75  8.75  7.5"
  },
  "execution_count": 103,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

If you want to substract the global mean from every grade, here is one way to do it:

```{.python .input} grades - grades.values.mean() ## substracts the global mean (8.00) from all grades


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>sep</th>\n      <th>oct</th>\n      <th>nov</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>1.0</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>2.0</td>\n      <td>1.0</td>\n      <td>1.0</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>-4.0</td>\n      <td>0.0</td>\n      <td>-6.0</td>\n    </tr>\n    <tr>\n      <th>darwin</th>\n      <td>1.0</td>\n      <td>2.0</td>\n      <td>2.0</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "         sep  oct  nov\nalice    0.0  0.0  1.0\nbob      2.0  1.0  1.0\ncharles -4.0  0.0 -6.0\ndarwin   1.0  2.0  2.0"
  },
  "execution_count": 104,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Automatic alignment

Similar to Series, when operating on multiple DataFrames, pandas automatically aligns them by row index label, but also by column names. Let’s create a DataFrame with bonus points for each person from October to December:

```{.python .input} bonus_array = np.array([[0,np.nan,2],[np.nan,1,0],[0, 1, 0], [3, 3, 0]]) bonus_points = pd.DataFrame(bonus_array, columns=[“oct”, “nov”, “dec”], index=[“bob”,”colin”, “darwin”, “charles”]) bonus_points


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>oct</th>\n      <th>nov</th>\n      <th>dec</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>bob</th>\n      <td>0.0</td>\n      <td>NaN</td>\n      <td>2.0</td>\n    </tr>\n    <tr>\n      <th>colin</th>\n      <td>NaN</td>\n      <td>1.0</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>darwin</th>\n      <td>0.0</td>\n      <td>1.0</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>3.0</td>\n      <td>3.0</td>\n      <td>0.0</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "         oct  nov  dec\nbob      0.0  NaN  2.0\ncolin    NaN  1.0  0.0\ndarwin   0.0  1.0  0.0\ncharles  3.0  3.0  0.0"
  },
  "execution_count": 105,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

```{.python .input} grades + bonus_points


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>dec</th>\n      <th>nov</th>\n      <th>oct</th>\n      <th>sep</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>9.0</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>NaN</td>\n      <td>5.0</td>\n      <td>11.0</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>colin</th>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>darwin</th>\n      <td>NaN</td>\n      <td>11.0</td>\n      <td>10.0</td>\n      <td>NaN</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "         dec   nov   oct  sep\nalice    NaN   NaN   NaN  NaN\nbob      NaN   NaN   9.0  NaN\ncharles  NaN   5.0  11.0  NaN\ncolin    NaN   NaN   NaN  NaN\ndarwin   NaN  11.0  10.0  NaN"
  },
  "execution_count": 106,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Looks like the addition worked in some cases but way too many elements are now empty. That’s because when aligning the DataFrames, some columns and rows were only present on one side, and thus they were considered missing on the other side (NaN). Then adding NaN to a number results in NaN, hence the result.

Handling missing data

Dealing with missing data is a frequent task when working with real life data. Pandas offers a few tools to handle missing data.

Let’s try to fix the problem above. For example, we can decide that missing data should result in a zero, instead of NaN. We can replace all NaN values by a any value using the fillna() method:

```{.python .input} (grades + bonus_points).fillna(0)


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>dec</th>\n      <th>nov</th>\n      <th>oct</th>\n      <th>sep</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>9.0</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>0.0</td>\n      <td>5.0</td>\n      <td>11.0</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>colin</th>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>darwin</th>\n      <td>0.0</td>\n      <td>11.0</td>\n      <td>10.0</td>\n      <td>0.0</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "         dec   nov   oct  sep\nalice    0.0   0.0   0.0  0.0\nbob      0.0   0.0   9.0  0.0\ncharles  0.0   5.0  11.0  0.0\ncolin    0.0   0.0   0.0  0.0\ndarwin   0.0  11.0  10.0  0.0"
  },
  "execution_count": 107,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

It’s a bit unfair that we’re setting grades to zero in September, though. Perhaps we should decide that missing grades are missing grades, but missing bonus points should be replaced by zeros:

```{.python .input} fixed_bonus_points = bonus_points.fillna(0) fixed_bonus_points.insert(0, “sep”, 0) fixed_bonus_points.loc[“alice”] = 0 grades + fixed_bonus_points


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>dec</th>\n      <th>nov</th>\n      <th>oct</th>\n      <th>sep</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>NaN</td>\n      <td>9.0</td>\n      <td>8.0</td>\n      <td>8.0</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>NaN</td>\n      <td>9.0</td>\n      <td>9.0</td>\n      <td>10.0</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>NaN</td>\n      <td>5.0</td>\n      <td>11.0</td>\n      <td>4.0</td>\n    </tr>\n    <tr>\n      <th>colin</th>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>darwin</th>\n      <td>NaN</td>\n      <td>11.0</td>\n      <td>10.0</td>\n      <td>9.0</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "         dec   nov   oct   sep\nalice    NaN   9.0   8.0   8.0\nbob      NaN   9.0   9.0  10.0\ncharles  NaN   5.0  11.0   4.0\ncolin    NaN   NaN   NaN   NaN\ndarwin   NaN  11.0  10.0   9.0"
  },
  "execution_count": 108,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

That’s much better: although we made up some data, we have not been too unfair.

Another way to handle missing data is to interpolate. Let’s look at the bonus_points DataFrame again:

```{.python .input} bonus_points


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>oct</th>\n      <th>nov</th>\n      <th>dec</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>bob</th>\n      <td>0.0</td>\n      <td>NaN</td>\n      <td>2.0</td>\n    </tr>\n    <tr>\n      <th>colin</th>\n      <td>NaN</td>\n      <td>1.0</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>darwin</th>\n      <td>0.0</td>\n      <td>1.0</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>3.0</td>\n      <td>3.0</td>\n      <td>0.0</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "         oct  nov  dec\nbob      0.0  NaN  2.0\ncolin    NaN  1.0  0.0\ndarwin   0.0  1.0  0.0\ncharles  3.0  3.0  0.0"
  },
  "execution_count": 109,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Now let’s call the interpolate method. By default, it interpolates vertically (axis=0), so let’s tell it to interpolate horizontally (axis=1).

```{.python .input} bonus_points.interpolate(axis=1)


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>oct</th>\n      <th>nov</th>\n      <th>dec</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>bob</th>\n      <td>0.0</td>\n      <td>1.0</td>\n      <td>2.0</td>\n    </tr>\n    <tr>\n      <th>colin</th>\n      <td>NaN</td>\n      <td>1.0</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>darwin</th>\n      <td>0.0</td>\n      <td>1.0</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>3.0</td>\n      <td>3.0</td>\n      <td>0.0</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "         oct  nov  dec\nbob      0.0  1.0  2.0\ncolin    NaN  1.0  0.0\ndarwin   0.0  1.0  0.0\ncharles  3.0  3.0  0.0"
  },
  "execution_count": 110,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Bob had 0 bonus points in October, and 2 in December. When we interpolate for November, we get the mean: 1 bonus point. Colin had 1 bonus point in November, but we do not know how many bonus points he had in September, so we cannot interpolate, this is why there is still a missing value in October after interpolation. To fix this, we can set the September bonus points to 0 before interpolation.

```{.python .input} better_bonus_points = bonus_points.copy() better_bonus_points.insert(0, “sep”, 0) better_bonus_points.loc[“alice”] = 0 better_bonus_points = better_bonus_points.interpolate(axis=1) better_bonus_points


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>sep</th>\n      <th>oct</th>\n      <th>nov</th>\n      <th>dec</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>bob</th>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>1.0</td>\n      <td>2.0</td>\n    </tr>\n    <tr>\n      <th>colin</th>\n      <td>0.0</td>\n      <td>0.5</td>\n      <td>1.0</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>darwin</th>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>1.0</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>0.0</td>\n      <td>3.0</td>\n      <td>3.0</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>alice</th>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n      <td>0.0</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "         sep  oct  nov  dec\nbob      0.0  0.0  1.0  2.0\ncolin    0.0  0.5  1.0  0.0\ndarwin   0.0  0.0  1.0  0.0\ncharles  0.0  3.0  3.0  0.0\nalice    0.0  0.0  0.0  0.0"
  },
  "execution_count": 111,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Great, now we have reasonable bonus points everywhere. Let’s find out the final grades:

```{.python .input} grades + better_bonus_points


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>dec</th>\n      <th>nov</th>\n      <th>oct</th>\n      <th>sep</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>NaN</td>\n      <td>9.0</td>\n      <td>8.0</td>\n      <td>8.0</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>NaN</td>\n      <td>10.0</td>\n      <td>9.0</td>\n      <td>10.0</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>NaN</td>\n      <td>5.0</td>\n      <td>11.0</td>\n      <td>4.0</td>\n    </tr>\n    <tr>\n      <th>colin</th>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>darwin</th>\n      <td>NaN</td>\n      <td>11.0</td>\n      <td>10.0</td>\n      <td>9.0</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "         dec   nov   oct   sep\nalice    NaN   9.0   8.0   8.0\nbob      NaN  10.0   9.0  10.0\ncharles  NaN   5.0  11.0   4.0\ncolin    NaN   NaN   NaN   NaN\ndarwin   NaN  11.0  10.0   9.0"
  },
  "execution_count": 112,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

It is slightly annoying that the September column ends up on the right. This is because the DataFrames we are adding do not have the exact same columns (the grades DataFrame is missing the "dec" column), so to make things predictable, pandas orders the final columns alphabetically. To fix this, we can simply add the missing column before adding:

```{.python .input} grades[“dec”] = np.nan final_grades = grades + better_bonus_points final_grades


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>sep</th>\n      <th>oct</th>\n      <th>nov</th>\n      <th>dec</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>8.0</td>\n      <td>8.0</td>\n      <td>9.0</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>10.0</td>\n      <td>9.0</td>\n      <td>10.0</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>4.0</td>\n      <td>11.0</td>\n      <td>5.0</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>colin</th>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>darwin</th>\n      <td>9.0</td>\n      <td>10.0</td>\n      <td>11.0</td>\n      <td>NaN</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "          sep   oct   nov  dec\nalice     8.0   8.0   9.0  NaN\nbob      10.0   9.0  10.0  NaN\ncharles   4.0  11.0   5.0  NaN\ncolin     NaN   NaN   NaN  NaN\ndarwin    9.0  10.0  11.0  NaN"
  },
  "execution_count": 113,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

There’s not much we can do about December and Colin: it’s bad enough that we are making up bonus points, but we can’t reasonably make up grades (well I guess some teachers probably do). So let’s call the dropna() method to get rid of rows that are full of NaNs:

```{.python .input} final_grades_clean = final_grades.dropna(how=”all”) final_grades_clean


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>sep</th>\n      <th>oct</th>\n      <th>nov</th>\n      <th>dec</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>8.0</td>\n      <td>8.0</td>\n      <td>9.0</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>10.0</td>\n      <td>9.0</td>\n      <td>10.0</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>4.0</td>\n      <td>11.0</td>\n      <td>5.0</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>darwin</th>\n      <td>9.0</td>\n      <td>10.0</td>\n      <td>11.0</td>\n      <td>NaN</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "          sep   oct   nov  dec\nalice     8.0   8.0   9.0  NaN\nbob      10.0   9.0  10.0  NaN\ncharles   4.0  11.0   5.0  NaN\ndarwin    9.0  10.0  11.0  NaN"
  },
  "execution_count": 114,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Now let’s remove columns that are full of NaNs by setting the axis argument to 1:

```{.python .input} final_grades_clean = final_grades_clean.dropna(axis=1, how=”all”) final_grades_clean


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>sep</th>\n      <th>oct</th>\n      <th>nov</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>8.0</td>\n      <td>8.0</td>\n      <td>9.0</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>10.0</td>\n      <td>9.0</td>\n      <td>10.0</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>4.0</td>\n      <td>11.0</td>\n      <td>5.0</td>\n    </tr>\n    <tr>\n      <th>darwin</th>\n      <td>9.0</td>\n      <td>10.0</td>\n      <td>11.0</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "          sep   oct   nov\nalice     8.0   8.0   9.0\nbob      10.0   9.0  10.0\ncharles   4.0  11.0   5.0\ndarwin    9.0  10.0  11.0"
  },
  "execution_count": 115,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Aggregating with groupby

Similar to the SQL language, pandas allows grouping your data into groups to run calculations over each group.

First, let’s add some extra data about each person so we can group them, and let’s go back to the final_grades DataFrame so we can see how NaN values are handled:

```{.python .input} final_grades[“hobby”] = [“Biking”, “Dancing”, np.nan, “Dancing”, “Biking”] final_grades


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>sep</th>\n      <th>oct</th>\n      <th>nov</th>\n      <th>dec</th>\n      <th>hobby</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>8.0</td>\n      <td>8.0</td>\n      <td>9.0</td>\n      <td>NaN</td>\n      <td>Biking</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>10.0</td>\n      <td>9.0</td>\n      <td>10.0</td>\n      <td>NaN</td>\n      <td>Dancing</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>4.0</td>\n      <td>11.0</td>\n      <td>5.0</td>\n      <td>NaN</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>colin</th>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>Dancing</td>\n    </tr>\n    <tr>\n      <th>darwin</th>\n      <td>9.0</td>\n      <td>10.0</td>\n      <td>11.0</td>\n      <td>NaN</td>\n      <td>Biking</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "          sep   oct   nov  dec    hobby\nalice     8.0   8.0   9.0  NaN   Biking\nbob      10.0   9.0  10.0  NaN  Dancing\ncharles   4.0  11.0   5.0  NaN      NaN\ncolin     NaN   NaN   NaN  NaN  Dancing\ndarwin    9.0  10.0  11.0  NaN   Biking"
  },
  "execution_count": 116,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Now let’s group data in this DataFrame by hobby:

```{.python .input} grouped_grades = final_grades.groupby(“hobby”) grouped_grades


```{.json .output n=None}
[
 {
  "data": {
   "text/plain": "<pandas.core.groupby.DataFrameGroupBy object at 0x10b680e10>"
  },
  "execution_count": 117,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

We are ready to compute the average grade per hobby:

```{.python .input} grouped_grades.mean()


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>sep</th>\n      <th>oct</th>\n      <th>nov</th>\n      <th>dec</th>\n    </tr>\n    <tr>\n      <th>hobby</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>Biking</th>\n      <td>8.5</td>\n      <td>9.0</td>\n      <td>10.0</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>Dancing</th>\n      <td>10.0</td>\n      <td>9.0</td>\n      <td>10.0</td>\n      <td>NaN</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "          sep  oct   nov  dec\nhobby                        \nBiking    8.5  9.0  10.0  NaN\nDancing  10.0  9.0  10.0  NaN"
  },
  "execution_count": 118,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

That was easy! Note that the NaN values have simply been skipped when computing the means.

Pivot tables

Pandas supports spreadsheet-like pivot tables that allow quick data summarization. To illustrate this, let’s create a simple DataFrame:

```{.python .input} bonus_points


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>oct</th>\n      <th>nov</th>\n      <th>dec</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>bob</th>\n      <td>0.0</td>\n      <td>NaN</td>\n      <td>2.0</td>\n    </tr>\n    <tr>\n      <th>colin</th>\n      <td>NaN</td>\n      <td>1.0</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>darwin</th>\n      <td>0.0</td>\n      <td>1.0</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>3.0</td>\n      <td>3.0</td>\n      <td>0.0</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "         oct  nov  dec\nbob      0.0  NaN  2.0\ncolin    NaN  1.0  0.0\ndarwin   0.0  1.0  0.0\ncharles  3.0  3.0  0.0"
  },
  "execution_count": 119,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

```{.python .input} more_grades = final_grades_clean.stack().reset_index() more_grades.columns = [“name”, “month”, “grade”] more_grades[“bonus”] = [np.nan, np.nan, np.nan, 0, np.nan, 2, 3, 3, 0, 0, 1, 0] more_grades


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>name</th>\n      <th>month</th>\n      <th>grade</th>\n      <th>bonus</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>alice</td>\n      <td>sep</td>\n      <td>8.0</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>alice</td>\n      <td>oct</td>\n      <td>8.0</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>alice</td>\n      <td>nov</td>\n      <td>9.0</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>bob</td>\n      <td>sep</td>\n      <td>10.0</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>bob</td>\n      <td>oct</td>\n      <td>9.0</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>5</th>\n      <td>bob</td>\n      <td>nov</td>\n      <td>10.0</td>\n      <td>2.0</td>\n    </tr>\n    <tr>\n      <th>6</th>\n      <td>charles</td>\n      <td>sep</td>\n      <td>4.0</td>\n      <td>3.0</td>\n    </tr>\n    <tr>\n      <th>7</th>\n      <td>charles</td>\n      <td>oct</td>\n      <td>11.0</td>\n      <td>3.0</td>\n    </tr>\n    <tr>\n      <th>8</th>\n      <td>charles</td>\n      <td>nov</td>\n      <td>5.0</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>9</th>\n      <td>darwin</td>\n      <td>sep</td>\n      <td>9.0</td>\n      <td>0.0</td>\n    </tr>\n    <tr>\n      <th>10</th>\n      <td>darwin</td>\n      <td>oct</td>\n      <td>10.0</td>\n      <td>1.0</td>\n    </tr>\n    <tr>\n      <th>11</th>\n      <td>darwin</td>\n      <td>nov</td>\n      <td>11.0</td>\n      <td>0.0</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "       name month  grade  bonus\n0     alice   sep    8.0    NaN\n1     alice   oct    8.0    NaN\n2     alice   nov    9.0    NaN\n3       bob   sep   10.0    0.0\n4       bob   oct    9.0    NaN\n5       bob   nov   10.0    2.0\n6   charles   sep    4.0    3.0\n7   charles   oct   11.0    3.0\n8   charles   nov    5.0    0.0\n9    darwin   sep    9.0    0.0\n10   darwin   oct   10.0    1.0\n11   darwin   nov   11.0    0.0"
  },
  "execution_count": 120,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Now we can call the pd.pivot_table() function for this DataFrame, asking to group by the name column. By default, pivot_table() computes the mean of each numeric column:

```{.python .input} pd.pivot_table(more_grades, index=”name”)


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>bonus</th>\n      <th>grade</th>\n    </tr>\n    <tr>\n      <th>name</th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>NaN</td>\n      <td>8.333333</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>1.000000</td>\n      <td>9.666667</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>2.000000</td>\n      <td>6.666667</td>\n    </tr>\n    <tr>\n      <th>darwin</th>\n      <td>0.333333</td>\n      <td>10.000000</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "            bonus      grade\nname                        \nalice         NaN   8.333333\nbob      1.000000   9.666667\ncharles  2.000000   6.666667\ndarwin   0.333333  10.000000"
  },
  "execution_count": 121,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

We can change the aggregation function by setting the aggfunc argument, and we can also specify the list of columns whose values will be aggregated:

```{.python .input} pd.pivot_table(more_grades, index=”name”, values=[“grade”,”bonus”], aggfunc=np.max)


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>bonus</th>\n      <th>grade</th>\n    </tr>\n    <tr>\n      <th>name</th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>NaN</td>\n      <td>9.0</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>2.0</td>\n      <td>10.0</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>3.0</td>\n      <td>11.0</td>\n    </tr>\n    <tr>\n      <th>darwin</th>\n      <td>1.0</td>\n      <td>11.0</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "         bonus  grade\nname                 \nalice      NaN    9.0\nbob        2.0   10.0\ncharles    3.0   11.0\ndarwin     1.0   11.0"
  },
  "execution_count": 122,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

We can also specify the columns to aggregate over horizontally, and request the grand totals for each row and column by setting margins=True:

```{.python .input} pd.pivot_table(more_grades, index=”name”, values=”grade”, columns=”month”, margins=True)


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th>month</th>\n      <th>nov</th>\n      <th>oct</th>\n      <th>sep</th>\n      <th>All</th>\n    </tr>\n    <tr>\n      <th>name</th>\n      <th></th>\n      <th></th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>9.00</td>\n      <td>8.0</td>\n      <td>8.00</td>\n      <td>8.333333</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>10.00</td>\n      <td>9.0</td>\n      <td>10.00</td>\n      <td>9.666667</td>\n    </tr>\n    <tr>\n      <th>charles</th>\n      <td>5.00</td>\n      <td>11.0</td>\n      <td>4.00</td>\n      <td>6.666667</td>\n    </tr>\n    <tr>\n      <th>darwin</th>\n      <td>11.00</td>\n      <td>10.0</td>\n      <td>9.00</td>\n      <td>10.000000</td>\n    </tr>\n    <tr>\n      <th>All</th>\n      <td>8.75</td>\n      <td>9.5</td>\n      <td>7.75</td>\n      <td>8.666667</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "month      nov   oct    sep        All\nname                                  \nalice     9.00   8.0   8.00   8.333333\nbob      10.00   9.0  10.00   9.666667\ncharles   5.00  11.0   4.00   6.666667\ndarwin   11.00  10.0   9.00  10.000000\nAll       8.75   9.5   7.75   8.666667"
  },
  "execution_count": 123,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Finally, we can specify multiple index or column names, and pandas will create multi-level indices:

```{.python .input} pd.pivot_table(more_grades, index=(“name”, “month”), margins=True)


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th></th>\n      <th>bonus</th>\n      <th>grade</th>\n    </tr>\n    <tr>\n      <th>name</th>\n      <th>month</th>\n      <th></th>\n      <th></th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th rowspan=\"3\" valign=\"top\">alice</th>\n      <th>nov</th>\n      <td>NaN</td>\n      <td>9.00</td>\n    </tr>\n    <tr>\n      <th>oct</th>\n      <td>NaN</td>\n      <td>8.00</td>\n    </tr>\n    <tr>\n      <th>sep</th>\n      <td>NaN</td>\n      <td>8.00</td>\n    </tr>\n    <tr>\n      <th rowspan=\"3\" valign=\"top\">bob</th>\n      <th>nov</th>\n      <td>2.000</td>\n      <td>10.00</td>\n    </tr>\n    <tr>\n      <th>oct</th>\n      <td>NaN</td>\n      <td>9.00</td>\n    </tr>\n    <tr>\n      <th>sep</th>\n      <td>0.000</td>\n      <td>10.00</td>\n    </tr>\n    <tr>\n      <th rowspan=\"3\" valign=\"top\">charles</th>\n      <th>nov</th>\n      <td>0.000</td>\n      <td>5.00</td>\n    </tr>\n    <tr>\n      <th>oct</th>\n      <td>3.000</td>\n      <td>11.00</td>\n    </tr>\n    <tr>\n      <th>sep</th>\n      <td>3.000</td>\n      <td>4.00</td>\n    </tr>\n    <tr>\n      <th rowspan=\"3\" valign=\"top\">darwin</th>\n      <th>nov</th>\n      <td>0.000</td>\n      <td>11.00</td>\n    </tr>\n    <tr>\n      <th>oct</th>\n      <td>1.000</td>\n      <td>10.00</td>\n    </tr>\n    <tr>\n      <th>sep</th>\n      <td>0.000</td>\n      <td>9.00</td>\n    </tr>\n    <tr>\n      <th>All</th>\n      <th></th>\n      <td>1.125</td>\n      <td>8.75</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "               bonus  grade\nname    month              \nalice   nov      NaN   9.00\n        oct      NaN   8.00\n        sep      NaN   8.00\nbob     nov    2.000  10.00\n        oct      NaN   9.00\n        sep    0.000  10.00\ncharles nov    0.000   5.00\n        oct    3.000  11.00\n        sep    3.000   4.00\ndarwin  nov    0.000  11.00\n        oct    1.000  10.00\n        sep    0.000   9.00\nAll            1.125   8.75"
  },
  "execution_count": 124,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Overview functions

When dealing with large DataFrames, it is useful to get a quick overview of its content. Pandas offers a few functions for this. First, let’s create a large DataFrame with a mix of numeric values, missing values and text values. Notice how Jupyter displays only the corners of the DataFrame:

```{.python .input} much_data = np.fromfunction(lambda x,y: (x+yy)%1711, (10000, 26)) large_df = pd.DataFrame(much_data, columns=list(“ABCDEFGHIJKLMNOPQRSTUVWXYZ”)) large_df[large_df % 16 == 0] = np.nan large_df.insert(3,”some_text”, “Blabla”) large_df


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>A</th>\n      <th>B</th>\n      <th>C</th>\n      <th>some_text</th>\n      <th>D</th>\n      <th>E</th>\n      <th>F</th>\n      <th>G</th>\n      <th>H</th>\n      <th>I</th>\n      <th>...</th>\n      <th>Q</th>\n      <th>R</th>\n      <th>S</th>\n      <th>T</th>\n      <th>U</th>\n      <th>V</th>\n      <th>W</th>\n      <th>X</th>\n      <th>Y</th>\n      <th>Z</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>NaN</td>\n      <td>11.0</td>\n      <td>44.0</td>\n      <td>Blabla</td>\n      <td>99.0</td>\n      <td>NaN</td>\n      <td>88.0</td>\n      <td>22.0</td>\n      <td>165.0</td>\n      <td>143.0</td>\n      <td>...</td>\n      <td>11.0</td>\n      <td>NaN</td>\n      <td>11.0</td>\n      <td>44.0</td>\n      <td>99.0</td>\n      <td>NaN</td>\n      <td>88.0</td>\n      <td>22.0</td>\n      <td>165.0</td>\n      <td>143.0</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>11.0</td>\n      <td>22.0</td>\n      <td>55.0</td>\n      <td>Blabla</td>\n      <td>110.0</td>\n      <td>NaN</td>\n      <td>99.0</td>\n      <td>33.0</td>\n      <td>NaN</td>\n      <td>154.0</td>\n      <td>...</td>\n      <td>22.0</td>\n      <td>11.0</td>\n      <td>22.0</td>\n      <td>55.0</td>\n      <td>110.0</td>\n      <td>NaN</td>\n      <td>99.0</td>\n      <td>33.0</td>\n      <td>NaN</td>\n      <td>154.0</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>22.0</td>\n      <td>33.0</td>\n      <td>66.0</td>\n      <td>Blabla</td>\n      <td>121.0</td>\n      <td>11.0</td>\n      <td>110.0</td>\n      <td>44.0</td>\n      <td>NaN</td>\n      <td>165.0</td>\n      <td>...</td>\n      <td>33.0</td>\n      <td>22.0</td>\n      <td>33.0</td>\n      <td>66.0</td>\n      <td>121.0</td>\n      <td>11.0</td>\n      <td>110.0</td>\n      <td>44.0</td>\n      <td>NaN</td>\n      <td>165.0</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>33.0</td>\n      <td>44.0</td>\n      <td>77.0</td>\n      <td>Blabla</td>\n      <td>132.0</td>\n      <td>22.0</td>\n      <td>121.0</td>\n      <td>55.0</td>\n      <td>11.0</td>\n      <td>NaN</td>\n      <td>...</td>\n      <td>44.0</td>\n      <td>33.0</td>\n      <td>44.0</td>\n      <td>77.0</td>\n      <td>132.0</td>\n      <td>22.0</td>\n      <td>121.0</td>\n      <td>55.0</td>\n      <td>11.0</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>44.0</td>\n      <td>55.0</td>\n      <td>88.0</td>\n      <td>Blabla</td>\n      <td>143.0</td>\n      <td>33.0</td>\n      <td>132.0</td>\n      <td>66.0</td>\n      <td>22.0</td>\n      <td>NaN</td>\n      <td>...</td>\n      <td>55.0</td>\n      <td>44.0</td>\n      <td>55.0</td>\n      <td>88.0</td>\n      <td>143.0</td>\n      <td>33.0</td>\n      <td>132.0</td>\n      <td>66.0</td>\n      <td>22.0</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>5</th>\n      <td>55.0</td>\n      <td>66.0</td>\n      <td>99.0</td>\n      <td>Blabla</td>\n      <td>154.0</td>\n      <td>44.0</td>\n      <td>143.0</td>\n      <td>77.0</td>\n      <td>33.0</td>\n      <td>11.0</td>\n      <td>...</td>\n      <td>66.0</td>\n      <td>55.0</td>\n      <td>66.0</td>\n      <td>99.0</td>\n      <td>154.0</td>\n      <td>44.0</td>\n      <td>143.0</td>\n      <td>77.0</td>\n      <td>33.0</td>\n      <td>11.0</td>\n    </tr>\n    <tr>\n      <th>6</th>\n      <td>66.0</td>\n      <td>77.0</td>\n      <td>110.0</td>\n      <td>Blabla</td>\n      <td>165.0</td>\n      <td>55.0</td>\n      <td>154.0</td>\n      <td>88.0</td>\n      <td>44.0</td>\n      <td>22.0</td>\n      <td>...</td>\n      <td>77.0</td>\n      <td>66.0</td>\n      <td>77.0</td>\n      <td>110.0</td>\n      <td>165.0</td>\n      <td>55.0</td>\n      <td>154.0</td>\n      <td>88.0</td>\n      <td>44.0</td>\n      <td>22.0</td>\n    </tr>\n    <tr>\n      <th>7</th>\n      <td>77.0</td>\n      <td>88.0</td>\n      <td>121.0</td>\n      <td>Blabla</td>\n      <td>NaN</td>\n      <td>66.0</td>\n      <td>165.0</td>\n      <td>99.0</td>\n      <td>55.0</td>\n      <td>33.0</td>\n      <td>...</td>\n      <td>88.0</td>\n      <td>77.0</td>\n      <td>88.0</td>\n      <td>121.0</td>\n      <td>NaN</td>\n      <td>66.0</td>\n      <td>165.0</td>\n      <td>99.0</td>\n      <td>55.0</td>\n      <td>33.0</td>\n    </tr>\n    <tr>\n      <th>8</th>\n      <td>88.0</td>\n      <td>99.0</td>\n      <td>132.0</td>\n      <td>Blabla</td>\n      <td>NaN</td>\n      <td>77.0</td>\n      <td>NaN</td>\n      <td>110.0</td>\n      <td>66.0</td>\n      <td>44.0</td>\n      <td>...</td>\n      <td>99.0</td>\n      <td>88.0</td>\n      <td>99.0</td>\n      <td>132.0</td>\n      <td>NaN</td>\n      <td>77.0</td>\n      <td>NaN</td>\n      <td>110.0</td>\n      <td>66.0</td>\n      <td>44.0</td>\n    </tr>\n    <tr>\n      <th>9</th>\n      <td>99.0</td>\n      <td>110.0</td>\n      <td>143.0</td>\n      <td>Blabla</td>\n      <td>11.0</td>\n      <td>88.0</td>\n      <td>NaN</td>\n      <td>121.0</td>\n      <td>77.0</td>\n      <td>55.0</td>\n      <td>...</td>\n      <td>110.0</td>\n      <td>99.0</td>\n      <td>110.0</td>\n      <td>143.0</td>\n      <td>11.0</td>\n      <td>88.0</td>\n      <td>NaN</td>\n      <td>121.0</td>\n      <td>77.0</td>\n      <td>55.0</td>\n    </tr>\n    <tr>\n      <th>10</th>\n      <td>110.0</td>\n      <td>121.0</td>\n      <td>154.0</td>\n      <td>Blabla</td>\n      <td>22.0</td>\n      <td>99.0</td>\n      <td>11.0</td>\n      <td>132.0</td>\n      <td>88.0</td>\n      <td>66.0</td>\n      <td>...</td>\n      <td>121.0</td>\n      <td>110.0</td>\n      <td>121.0</td>\n      <td>154.0</td>\n      <td>22.0</td>\n      <td>99.0</td>\n      <td>11.0</td>\n      <td>132.0</td>\n      <td>88.0</td>\n      <td>66.0</td>\n    </tr>\n    <tr>\n      <th>11</th>\n      <td>121.0</td>\n      <td>132.0</td>\n      <td>165.0</td>\n      <td>Blabla</td>\n      <td>33.0</td>\n      <td>110.0</td>\n      <td>22.0</td>\n      <td>143.0</td>\n      <td>99.0</td>\n      <td>77.0</td>\n      <td>...</td>\n      <td>132.0</td>\n      <td>121.0</td>\n      <td>132.0</td>\n      <td>165.0</td>\n      <td>33.0</td>\n      <td>110.0</td>\n      <td>22.0</td>\n      <td>143.0</td>\n      <td>99.0</td>\n      <td>77.0</td>\n    </tr>\n    <tr>\n      <th>12</th>\n      <td>132.0</td>\n      <td>143.0</td>\n      <td>NaN</td>\n      <td>Blabla</td>\n      <td>44.0</td>\n      <td>121.0</td>\n      <td>33.0</td>\n      <td>154.0</td>\n      <td>110.0</td>\n      <td>88.0</td>\n      <td>...</td>\n      <td>143.0</td>\n      <td>132.0</td>\n      <td>143.0</td>\n      <td>NaN</td>\n      <td>44.0</td>\n      <td>121.0</td>\n      <td>33.0</td>\n      <td>154.0</td>\n      <td>110.0</td>\n      <td>88.0</td>\n    </tr>\n    <tr>\n      <th>13</th>\n      <td>143.0</td>\n      <td>154.0</td>\n      <td>NaN</td>\n      <td>Blabla</td>\n      <td>55.0</td>\n      <td>132.0</td>\n      <td>44.0</td>\n      <td>165.0</td>\n      <td>121.0</td>\n      <td>99.0</td>\n      <td>...</td>\n      <td>154.0</td>\n      <td>143.0</td>\n      <td>154.0</td>\n      <td>NaN</td>\n      <td>55.0</td>\n      <td>132.0</td>\n      <td>44.0</td>\n      <td>165.0</td>\n      <td>121.0</td>\n      <td>99.0</td>\n    </tr>\n    <tr>\n      <th>14</th>\n      <td>154.0</td>\n      <td>165.0</td>\n      <td>11.0</td>\n      <td>Blabla</td>\n      <td>66.0</td>\n      <td>143.0</td>\n      <td>55.0</td>\n      <td>NaN</td>\n      <td>132.0</td>\n      <td>110.0</td>\n      <td>...</td>\n      <td>165.0</td>\n      <td>154.0</td>\n      <td>165.0</td>\n      <td>11.0</td>\n      <td>66.0</td>\n      <td>143.0</td>\n      <td>55.0</td>\n      <td>NaN</td>\n      <td>132.0</td>\n      <td>110.0</td>\n    </tr>\n    <tr>\n      <th>15</th>\n      <td>165.0</td>\n      <td>NaN</td>\n      <td>22.0</td>\n      <td>Blabla</td>\n      <td>77.0</td>\n      <td>154.0</td>\n      <td>66.0</td>\n      <td>NaN</td>\n      <td>143.0</td>\n      <td>121.0</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>165.0</td>\n      <td>NaN</td>\n      <td>22.0</td>\n      <td>77.0</td>\n      <td>154.0</td>\n      <td>66.0</td>\n      <td>NaN</td>\n      <td>143.0</td>\n      <td>121.0</td>\n    </tr>\n    <tr>\n      <th>16</th>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>33.0</td>\n      <td>Blabla</td>\n      <td>88.0</td>\n      <td>165.0</td>\n      <td>77.0</td>\n      <td>11.0</td>\n      <td>154.0</td>\n      <td>132.0</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>33.0</td>\n      <td>88.0</td>\n      <td>165.0</td>\n      <td>77.0</td>\n      <td>11.0</td>\n      <td>154.0</td>\n      <td>132.0</td>\n    </tr>\n    <tr>\n      <th>17</th>\n      <td>NaN</td>\n      <td>11.0</td>\n      <td>44.0</td>\n      <td>Blabla</td>\n      <td>99.0</td>\n      <td>NaN</td>\n      <td>88.0</td>\n      <td>22.0</td>\n      <td>165.0</td>\n      <td>143.0</td>\n      <td>...</td>\n      <td>11.0</td>\n      <td>NaN</td>\n      <td>11.0</td>\n      <td>44.0</td>\n      <td>99.0</td>\n      <td>NaN</td>\n      <td>88.0</td>\n      <td>22.0</td>\n      <td>165.0</td>\n      <td>143.0</td>\n    </tr>\n    <tr>\n      <th>18</th>\n      <td>11.0</td>\n      <td>22.0</td>\n      <td>55.0</td>\n      <td>Blabla</td>\n      <td>110.0</td>\n      <td>NaN</td>\n      <td>99.0</td>\n      <td>33.0</td>\n      <td>NaN</td>\n      <td>154.0</td>\n      <td>...</td>\n      <td>22.0</td>\n      <td>11.0</td>\n      <td>22.0</td>\n      <td>55.0</td>\n      <td>110.0</td>\n      <td>NaN</td>\n      <td>99.0</td>\n      <td>33.0</td>\n      <td>NaN</td>\n      <td>154.0</td>\n    </tr>\n    <tr>\n      <th>19</th>\n      <td>22.0</td>\n      <td>33.0</td>\n      <td>66.0</td>\n      <td>Blabla</td>\n      <td>121.0</td>\n      <td>11.0</td>\n      <td>110.0</td>\n      <td>44.0</td>\n      <td>NaN</td>\n      <td>165.0</td>\n      <td>...</td>\n      <td>33.0</td>\n      <td>22.0</td>\n      <td>33.0</td>\n      <td>66.0</td>\n      <td>121.0</td>\n      <td>11.0</td>\n      <td>110.0</td>\n      <td>44.0</td>\n      <td>NaN</td>\n      <td>165.0</td>\n    </tr>\n    <tr>\n      <th>20</th>\n      <td>33.0</td>\n      <td>44.0</td>\n      <td>77.0</td>\n      <td>Blabla</td>\n      <td>132.0</td>\n      <td>22.0</td>\n      <td>121.0</td>\n      <td>55.0</td>\n      <td>11.0</td>\n      <td>NaN</td>\n      <td>...</td>\n      <td>44.0</td>\n      <td>33.0</td>\n      <td>44.0</td>\n      <td>77.0</td>\n      <td>132.0</td>\n      <td>22.0</td>\n      <td>121.0</td>\n      <td>55.0</td>\n      <td>11.0</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>21</th>\n      <td>44.0</td>\n      <td>55.0</td>\n      <td>88.0</td>\n      <td>Blabla</td>\n      <td>143.0</td>\n      <td>33.0</td>\n      <td>132.0</td>\n      <td>66.0</td>\n      <td>22.0</td>\n      <td>NaN</td>\n      <td>...</td>\n      <td>55.0</td>\n      <td>44.0</td>\n      <td>55.0</td>\n      <td>88.0</td>\n      <td>143.0</td>\n      <td>33.0</td>\n      <td>132.0</td>\n      <td>66.0</td>\n      <td>22.0</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>22</th>\n      <td>55.0</td>\n      <td>66.0</td>\n      <td>99.0</td>\n      <td>Blabla</td>\n      <td>154.0</td>\n      <td>44.0</td>\n      <td>143.0</td>\n      <td>77.0</td>\n      <td>33.0</td>\n      <td>11.0</td>\n      <td>...</td>\n      <td>66.0</td>\n      <td>55.0</td>\n      <td>66.0</td>\n      <td>99.0</td>\n      <td>154.0</td>\n      <td>44.0</td>\n      <td>143.0</td>\n      <td>77.0</td>\n      <td>33.0</td>\n      <td>11.0</td>\n    </tr>\n    <tr>\n      <th>23</th>\n      <td>66.0</td>\n      <td>77.0</td>\n      <td>110.0</td>\n      <td>Blabla</td>\n      <td>165.0</td>\n      <td>55.0</td>\n      <td>154.0</td>\n      <td>88.0</td>\n      <td>44.0</td>\n      <td>22.0</td>\n      <td>...</td>\n      <td>77.0</td>\n      <td>66.0</td>\n      <td>77.0</td>\n      <td>110.0</td>\n      <td>165.0</td>\n      <td>55.0</td>\n      <td>154.0</td>\n      <td>88.0</td>\n      <td>44.0</td>\n      <td>22.0</td>\n    </tr>\n    <tr>\n      <th>24</th>\n      <td>77.0</td>\n      <td>88.0</td>\n      <td>121.0</td>\n      <td>Blabla</td>\n      <td>NaN</td>\n      <td>66.0</td>\n      <td>165.0</td>\n      <td>99.0</td>\n      <td>55.0</td>\n      <td>33.0</td>\n      <td>...</td>\n      <td>88.0</td>\n      <td>77.0</td>\n      <td>88.0</td>\n      <td>121.0</td>\n      <td>NaN</td>\n      <td>66.0</td>\n      <td>165.0</td>\n      <td>99.0</td>\n      <td>55.0</td>\n      <td>33.0</td>\n    </tr>\n    <tr>\n      <th>25</th>\n      <td>88.0</td>\n      <td>99.0</td>\n      <td>132.0</td>\n      <td>Blabla</td>\n      <td>NaN</td>\n      <td>77.0</td>\n      <td>NaN</td>\n      <td>110.0</td>\n      <td>66.0</td>\n      <td>44.0</td>\n      <td>...</td>\n      <td>99.0</td>\n      <td>88.0</td>\n      <td>99.0</td>\n      <td>132.0</td>\n      <td>NaN</td>\n      <td>77.0</td>\n      <td>NaN</td>\n      <td>110.0</td>\n      <td>66.0</td>\n      <td>44.0</td>\n    </tr>\n    <tr>\n      <th>26</th>\n      <td>99.0</td>\n      <td>110.0</td>\n      <td>143.0</td>\n      <td>Blabla</td>\n      <td>11.0</td>\n      <td>88.0</td>\n      <td>NaN</td>\n      <td>121.0</td>\n      <td>77.0</td>\n      <td>55.0</td>\n      <td>...</td>\n      <td>110.0</td>\n      <td>99.0</td>\n      <td>110.0</td>\n      <td>143.0</td>\n      <td>11.0</td>\n      <td>88.0</td>\n      <td>NaN</td>\n      <td>121.0</td>\n      <td>77.0</td>\n      <td>55.0</td>\n    </tr>\n    <tr>\n      <th>27</th>\n      <td>110.0</td>\n      <td>121.0</td>\n      <td>154.0</td>\n      <td>Blabla</td>\n      <td>22.0</td>\n      <td>99.0</td>\n      <td>11.0</td>\n      <td>132.0</td>\n      <td>88.0</td>\n      <td>66.0</td>\n      <td>...</td>\n      <td>121.0</td>\n      <td>110.0</td>\n      <td>121.0</td>\n      <td>154.0</td>\n      <td>22.0</td>\n      <td>99.0</td>\n      <td>11.0</td>\n      <td>132.0</td>\n      <td>88.0</td>\n      <td>66.0</td>\n    </tr>\n    <tr>\n      <th>28</th>\n      <td>121.0</td>\n      <td>132.0</td>\n      <td>165.0</td>\n      <td>Blabla</td>\n      <td>33.0</td>\n      <td>110.0</td>\n      <td>22.0</td>\n      <td>143.0</td>\n      <td>99.0</td>\n      <td>77.0</td>\n      <td>...</td>\n      <td>132.0</td>\n      <td>121.0</td>\n      <td>132.0</td>\n      <td>165.0</td>\n      <td>33.0</td>\n      <td>110.0</td>\n      <td>22.0</td>\n      <td>143.0</td>\n      <td>99.0</td>\n      <td>77.0</td>\n    </tr>\n    <tr>\n      <th>29</th>\n      <td>132.0</td>\n      <td>143.0</td>\n      <td>NaN</td>\n      <td>Blabla</td>\n      <td>44.0</td>\n      <td>121.0</td>\n      <td>33.0</td>\n      <td>154.0</td>\n      <td>110.0</td>\n      <td>88.0</td>\n      <td>...</td>\n      <td>143.0</td>\n      <td>132.0</td>\n      <td>143.0</td>\n      <td>NaN</td>\n      <td>44.0</td>\n      <td>121.0</td>\n      <td>33.0</td>\n      <td>154.0</td>\n      <td>110.0</td>\n      <td>88.0</td>\n    </tr>\n    <tr>\n      <th>...</th>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n      <td>...</td>\n    </tr>\n    <tr>\n      <th>9970</th>\n      <td>88.0</td>\n      <td>99.0</td>\n      <td>132.0</td>\n      <td>Blabla</td>\n      <td>NaN</td>\n      <td>77.0</td>\n      <td>NaN</td>\n      <td>110.0</td>\n      <td>66.0</td>\n      <td>44.0</td>\n      <td>...</td>\n      <td>99.0</td>\n      <td>88.0</td>\n      <td>99.0</td>\n      <td>132.0</td>\n      <td>NaN</td>\n      <td>77.0</td>\n      <td>NaN</td>\n      <td>110.0</td>\n      <td>66.0</td>\n      <td>44.0</td>\n    </tr>\n    <tr>\n      <th>9971</th>\n      <td>99.0</td>\n      <td>110.0</td>\n      <td>143.0</td>\n      <td>Blabla</td>\n      <td>11.0</td>\n      <td>88.0</td>\n      <td>NaN</td>\n      <td>121.0</td>\n      <td>77.0</td>\n      <td>55.0</td>\n      <td>...</td>\n      <td>110.0</td>\n      <td>99.0</td>\n      <td>110.0</td>\n      <td>143.0</td>\n      <td>11.0</td>\n      <td>88.0</td>\n      <td>NaN</td>\n      <td>121.0</td>\n      <td>77.0</td>\n      <td>55.0</td>\n    </tr>\n    <tr>\n      <th>9972</th>\n      <td>110.0</td>\n      <td>121.0</td>\n      <td>154.0</td>\n      <td>Blabla</td>\n      <td>22.0</td>\n      <td>99.0</td>\n      <td>11.0</td>\n      <td>132.0</td>\n      <td>88.0</td>\n      <td>66.0</td>\n      <td>...</td>\n      <td>121.0</td>\n      <td>110.0</td>\n      <td>121.0</td>\n      <td>154.0</td>\n      <td>22.0</td>\n      <td>99.0</td>\n      <td>11.0</td>\n      <td>132.0</td>\n      <td>88.0</td>\n      <td>66.0</td>\n    </tr>\n    <tr>\n      <th>9973</th>\n      <td>121.0</td>\n      <td>132.0</td>\n      <td>165.0</td>\n      <td>Blabla</td>\n      <td>33.0</td>\n      <td>110.0</td>\n      <td>22.0</td>\n      <td>143.0</td>\n      <td>99.0</td>\n      <td>77.0</td>\n      <td>...</td>\n      <td>132.0</td>\n      <td>121.0</td>\n      <td>132.0</td>\n      <td>165.0</td>\n      <td>33.0</td>\n      <td>110.0</td>\n      <td>22.0</td>\n      <td>143.0</td>\n      <td>99.0</td>\n      <td>77.0</td>\n    </tr>\n    <tr>\n      <th>9974</th>\n      <td>132.0</td>\n      <td>143.0</td>\n      <td>NaN</td>\n      <td>Blabla</td>\n      <td>44.0</td>\n      <td>121.0</td>\n      <td>33.0</td>\n      <td>154.0</td>\n      <td>110.0</td>\n      <td>88.0</td>\n      <td>...</td>\n      <td>143.0</td>\n      <td>132.0</td>\n      <td>143.0</td>\n      <td>NaN</td>\n      <td>44.0</td>\n      <td>121.0</td>\n      <td>33.0</td>\n      <td>154.0</td>\n      <td>110.0</td>\n      <td>88.0</td>\n    </tr>\n    <tr>\n      <th>9975</th>\n      <td>143.0</td>\n      <td>154.0</td>\n      <td>NaN</td>\n      <td>Blabla</td>\n      <td>55.0</td>\n      <td>132.0</td>\n      <td>44.0</td>\n      <td>165.0</td>\n      <td>121.0</td>\n      <td>99.0</td>\n      <td>...</td>\n      <td>154.0</td>\n      <td>143.0</td>\n      <td>154.0</td>\n      <td>NaN</td>\n      <td>55.0</td>\n      <td>132.0</td>\n      <td>44.0</td>\n      <td>165.0</td>\n      <td>121.0</td>\n      <td>99.0</td>\n    </tr>\n    <tr>\n      <th>9976</th>\n      <td>154.0</td>\n      <td>165.0</td>\n      <td>11.0</td>\n      <td>Blabla</td>\n      <td>66.0</td>\n      <td>143.0</td>\n      <td>55.0</td>\n      <td>NaN</td>\n      <td>132.0</td>\n      <td>110.0</td>\n      <td>...</td>\n      <td>165.0</td>\n      <td>154.0</td>\n      <td>165.0</td>\n      <td>11.0</td>\n      <td>66.0</td>\n      <td>143.0</td>\n      <td>55.0</td>\n      <td>NaN</td>\n      <td>132.0</td>\n      <td>110.0</td>\n    </tr>\n    <tr>\n      <th>9977</th>\n      <td>165.0</td>\n      <td>NaN</td>\n      <td>22.0</td>\n      <td>Blabla</td>\n      <td>77.0</td>\n      <td>154.0</td>\n      <td>66.0</td>\n      <td>NaN</td>\n      <td>143.0</td>\n      <td>121.0</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>165.0</td>\n      <td>NaN</td>\n      <td>22.0</td>\n      <td>77.0</td>\n      <td>154.0</td>\n      <td>66.0</td>\n      <td>NaN</td>\n      <td>143.0</td>\n      <td>121.0</td>\n    </tr>\n    <tr>\n      <th>9978</th>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>33.0</td>\n      <td>Blabla</td>\n      <td>88.0</td>\n      <td>165.0</td>\n      <td>77.0</td>\n      <td>11.0</td>\n      <td>154.0</td>\n      <td>132.0</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>33.0</td>\n      <td>88.0</td>\n      <td>165.0</td>\n      <td>77.0</td>\n      <td>11.0</td>\n      <td>154.0</td>\n      <td>132.0</td>\n    </tr>\n    <tr>\n      <th>9979</th>\n      <td>NaN</td>\n      <td>11.0</td>\n      <td>44.0</td>\n      <td>Blabla</td>\n      <td>99.0</td>\n      <td>NaN</td>\n      <td>88.0</td>\n      <td>22.0</td>\n      <td>165.0</td>\n      <td>143.0</td>\n      <td>...</td>\n      <td>11.0</td>\n      <td>NaN</td>\n      <td>11.0</td>\n      <td>44.0</td>\n      <td>99.0</td>\n      <td>NaN</td>\n      <td>88.0</td>\n      <td>22.0</td>\n      <td>165.0</td>\n      <td>143.0</td>\n    </tr>\n    <tr>\n      <th>9980</th>\n      <td>11.0</td>\n      <td>22.0</td>\n      <td>55.0</td>\n      <td>Blabla</td>\n      <td>110.0</td>\n      <td>NaN</td>\n      <td>99.0</td>\n      <td>33.0</td>\n      <td>NaN</td>\n      <td>154.0</td>\n      <td>...</td>\n      <td>22.0</td>\n      <td>11.0</td>\n      <td>22.0</td>\n      <td>55.0</td>\n      <td>110.0</td>\n      <td>NaN</td>\n      <td>99.0</td>\n      <td>33.0</td>\n      <td>NaN</td>\n      <td>154.0</td>\n    </tr>\n    <tr>\n      <th>9981</th>\n      <td>22.0</td>\n      <td>33.0</td>\n      <td>66.0</td>\n      <td>Blabla</td>\n      <td>121.0</td>\n      <td>11.0</td>\n      <td>110.0</td>\n      <td>44.0</td>\n      <td>NaN</td>\n      <td>165.0</td>\n      <td>...</td>\n      <td>33.0</td>\n      <td>22.0</td>\n      <td>33.0</td>\n      <td>66.0</td>\n      <td>121.0</td>\n      <td>11.0</td>\n      <td>110.0</td>\n      <td>44.0</td>\n      <td>NaN</td>\n      <td>165.0</td>\n    </tr>\n    <tr>\n      <th>9982</th>\n      <td>33.0</td>\n      <td>44.0</td>\n      <td>77.0</td>\n      <td>Blabla</td>\n      <td>132.0</td>\n      <td>22.0</td>\n      <td>121.0</td>\n      <td>55.0</td>\n      <td>11.0</td>\n      <td>NaN</td>\n      <td>...</td>\n      <td>44.0</td>\n      <td>33.0</td>\n      <td>44.0</td>\n      <td>77.0</td>\n      <td>132.0</td>\n      <td>22.0</td>\n      <td>121.0</td>\n      <td>55.0</td>\n      <td>11.0</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>9983</th>\n      <td>44.0</td>\n      <td>55.0</td>\n      <td>88.0</td>\n      <td>Blabla</td>\n      <td>143.0</td>\n      <td>33.0</td>\n      <td>132.0</td>\n      <td>66.0</td>\n      <td>22.0</td>\n      <td>NaN</td>\n      <td>...</td>\n      <td>55.0</td>\n      <td>44.0</td>\n      <td>55.0</td>\n      <td>88.0</td>\n      <td>143.0</td>\n      <td>33.0</td>\n      <td>132.0</td>\n      <td>66.0</td>\n      <td>22.0</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>9984</th>\n      <td>55.0</td>\n      <td>66.0</td>\n      <td>99.0</td>\n      <td>Blabla</td>\n      <td>154.0</td>\n      <td>44.0</td>\n      <td>143.0</td>\n      <td>77.0</td>\n      <td>33.0</td>\n      <td>11.0</td>\n      <td>...</td>\n      <td>66.0</td>\n      <td>55.0</td>\n      <td>66.0</td>\n      <td>99.0</td>\n      <td>154.0</td>\n      <td>44.0</td>\n      <td>143.0</td>\n      <td>77.0</td>\n      <td>33.0</td>\n      <td>11.0</td>\n    </tr>\n    <tr>\n      <th>9985</th>\n      <td>66.0</td>\n      <td>77.0</td>\n      <td>110.0</td>\n      <td>Blabla</td>\n      <td>165.0</td>\n      <td>55.0</td>\n      <td>154.0</td>\n      <td>88.0</td>\n      <td>44.0</td>\n      <td>22.0</td>\n      <td>...</td>\n      <td>77.0</td>\n      <td>66.0</td>\n      <td>77.0</td>\n      <td>110.0</td>\n      <td>165.0</td>\n      <td>55.0</td>\n      <td>154.0</td>\n      <td>88.0</td>\n      <td>44.0</td>\n      <td>22.0</td>\n    </tr>\n    <tr>\n      <th>9986</th>\n      <td>77.0</td>\n      <td>88.0</td>\n      <td>121.0</td>\n      <td>Blabla</td>\n      <td>NaN</td>\n      <td>66.0</td>\n      <td>165.0</td>\n      <td>99.0</td>\n      <td>55.0</td>\n      <td>33.0</td>\n      <td>...</td>\n      <td>88.0</td>\n      <td>77.0</td>\n      <td>88.0</td>\n      <td>121.0</td>\n      <td>NaN</td>\n      <td>66.0</td>\n      <td>165.0</td>\n      <td>99.0</td>\n      <td>55.0</td>\n      <td>33.0</td>\n    </tr>\n    <tr>\n      <th>9987</th>\n      <td>88.0</td>\n      <td>99.0</td>\n      <td>132.0</td>\n      <td>Blabla</td>\n      <td>NaN</td>\n      <td>77.0</td>\n      <td>NaN</td>\n      <td>110.0</td>\n      <td>66.0</td>\n      <td>44.0</td>\n      <td>...</td>\n      <td>99.0</td>\n      <td>88.0</td>\n      <td>99.0</td>\n      <td>132.0</td>\n      <td>NaN</td>\n      <td>77.0</td>\n      <td>NaN</td>\n      <td>110.0</td>\n      <td>66.0</td>\n      <td>44.0</td>\n    </tr>\n    <tr>\n      <th>9988</th>\n      <td>99.0</td>\n      <td>110.0</td>\n      <td>143.0</td>\n      <td>Blabla</td>\n      <td>11.0</td>\n      <td>88.0</td>\n      <td>NaN</td>\n      <td>121.0</td>\n      <td>77.0</td>\n      <td>55.0</td>\n      <td>...</td>\n      <td>110.0</td>\n      <td>99.0</td>\n      <td>110.0</td>\n      <td>143.0</td>\n      <td>11.0</td>\n      <td>88.0</td>\n      <td>NaN</td>\n      <td>121.0</td>\n      <td>77.0</td>\n      <td>55.0</td>\n    </tr>\n    <tr>\n      <th>9989</th>\n      <td>110.0</td>\n      <td>121.0</td>\n      <td>154.0</td>\n      <td>Blabla</td>\n      <td>22.0</td>\n      <td>99.0</td>\n      <td>11.0</td>\n      <td>132.0</td>\n      <td>88.0</td>\n      <td>66.0</td>\n      <td>...</td>\n      <td>121.0</td>\n      <td>110.0</td>\n      <td>121.0</td>\n      <td>154.0</td>\n      <td>22.0</td>\n      <td>99.0</td>\n      <td>11.0</td>\n      <td>132.0</td>\n      <td>88.0</td>\n      <td>66.0</td>\n    </tr>\n    <tr>\n      <th>9990</th>\n      <td>121.0</td>\n      <td>132.0</td>\n      <td>165.0</td>\n      <td>Blabla</td>\n      <td>33.0</td>\n      <td>110.0</td>\n      <td>22.0</td>\n      <td>143.0</td>\n      <td>99.0</td>\n      <td>77.0</td>\n      <td>...</td>\n      <td>132.0</td>\n      <td>121.0</td>\n      <td>132.0</td>\n      <td>165.0</td>\n      <td>33.0</td>\n      <td>110.0</td>\n      <td>22.0</td>\n      <td>143.0</td>\n      <td>99.0</td>\n      <td>77.0</td>\n    </tr>\n    <tr>\n      <th>9991</th>\n      <td>132.0</td>\n      <td>143.0</td>\n      <td>NaN</td>\n      <td>Blabla</td>\n      <td>44.0</td>\n      <td>121.0</td>\n      <td>33.0</td>\n      <td>154.0</td>\n      <td>110.0</td>\n      <td>88.0</td>\n      <td>...</td>\n      <td>143.0</td>\n      <td>132.0</td>\n      <td>143.0</td>\n      <td>NaN</td>\n      <td>44.0</td>\n      <td>121.0</td>\n      <td>33.0</td>\n      <td>154.0</td>\n      <td>110.0</td>\n      <td>88.0</td>\n    </tr>\n    <tr>\n      <th>9992</th>\n      <td>143.0</td>\n      <td>154.0</td>\n      <td>NaN</td>\n      <td>Blabla</td>\n      <td>55.0</td>\n      <td>132.0</td>\n      <td>44.0</td>\n      <td>165.0</td>\n      <td>121.0</td>\n      <td>99.0</td>\n      <td>...</td>\n      <td>154.0</td>\n      <td>143.0</td>\n      <td>154.0</td>\n      <td>NaN</td>\n      <td>55.0</td>\n      <td>132.0</td>\n      <td>44.0</td>\n      <td>165.0</td>\n      <td>121.0</td>\n      <td>99.0</td>\n    </tr>\n    <tr>\n      <th>9993</th>\n      <td>154.0</td>\n      <td>165.0</td>\n      <td>11.0</td>\n      <td>Blabla</td>\n      <td>66.0</td>\n      <td>143.0</td>\n      <td>55.0</td>\n      <td>NaN</td>\n      <td>132.0</td>\n      <td>110.0</td>\n      <td>...</td>\n      <td>165.0</td>\n      <td>154.0</td>\n      <td>165.0</td>\n      <td>11.0</td>\n      <td>66.0</td>\n      <td>143.0</td>\n      <td>55.0</td>\n      <td>NaN</td>\n      <td>132.0</td>\n      <td>110.0</td>\n    </tr>\n    <tr>\n      <th>9994</th>\n      <td>165.0</td>\n      <td>NaN</td>\n      <td>22.0</td>\n      <td>Blabla</td>\n      <td>77.0</td>\n      <td>154.0</td>\n      <td>66.0</td>\n      <td>NaN</td>\n      <td>143.0</td>\n      <td>121.0</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>165.0</td>\n      <td>NaN</td>\n      <td>22.0</td>\n      <td>77.0</td>\n      <td>154.0</td>\n      <td>66.0</td>\n      <td>NaN</td>\n      <td>143.0</td>\n      <td>121.0</td>\n    </tr>\n    <tr>\n      <th>9995</th>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>33.0</td>\n      <td>Blabla</td>\n      <td>88.0</td>\n      <td>165.0</td>\n      <td>77.0</td>\n      <td>11.0</td>\n      <td>154.0</td>\n      <td>132.0</td>\n      <td>...</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>NaN</td>\n      <td>33.0</td>\n      <td>88.0</td>\n      <td>165.0</td>\n      <td>77.0</td>\n      <td>11.0</td>\n      <td>154.0</td>\n      <td>132.0</td>\n    </tr>\n    <tr>\n      <th>9996</th>\n      <td>NaN</td>\n      <td>11.0</td>\n      <td>44.0</td>\n      <td>Blabla</td>\n      <td>99.0</td>\n      <td>NaN</td>\n      <td>88.0</td>\n      <td>22.0</td>\n      <td>165.0</td>\n      <td>143.0</td>\n      <td>...</td>\n      <td>11.0</td>\n      <td>NaN</td>\n      <td>11.0</td>\n      <td>44.0</td>\n      <td>99.0</td>\n      <td>NaN</td>\n      <td>88.0</td>\n      <td>22.0</td>\n      <td>165.0</td>\n      <td>143.0</td>\n    </tr>\n    <tr>\n      <th>9997</th>\n      <td>11.0</td>\n      <td>22.0</td>\n      <td>55.0</td>\n      <td>Blabla</td>\n      <td>110.0</td>\n      <td>NaN</td>\n      <td>99.0</td>\n      <td>33.0</td>\n      <td>NaN</td>\n      <td>154.0</td>\n      <td>...</td>\n      <td>22.0</td>\n      <td>11.0</td>\n      <td>22.0</td>\n      <td>55.0</td>\n      <td>110.0</td>\n      <td>NaN</td>\n      <td>99.0</td>\n      <td>33.0</td>\n      <td>NaN</td>\n      <td>154.0</td>\n    </tr>\n    <tr>\n      <th>9998</th>\n      <td>22.0</td>\n      <td>33.0</td>\n      <td>66.0</td>\n      <td>Blabla</td>\n      <td>121.0</td>\n      <td>11.0</td>\n      <td>110.0</td>\n      <td>44.0</td>\n      <td>NaN</td>\n      <td>165.0</td>\n      <td>...</td>\n      <td>33.0</td>\n      <td>22.0</td>\n      <td>33.0</td>\n      <td>66.0</td>\n      <td>121.0</td>\n      <td>11.0</td>\n      <td>110.0</td>\n      <td>44.0</td>\n      <td>NaN</td>\n      <td>165.0</td>\n    </tr>\n    <tr>\n      <th>9999</th>\n      <td>33.0</td>\n      <td>44.0</td>\n      <td>77.0</td>\n      <td>Blabla</td>\n      <td>132.0</td>\n      <td>22.0</td>\n      <td>121.0</td>\n      <td>55.0</td>\n      <td>11.0</td>\n      <td>NaN</td>\n      <td>...</td>\n      <td>44.0</td>\n      <td>33.0</td>\n      <td>44.0</td>\n      <td>77.0</td>\n      <td>132.0</td>\n      <td>22.0</td>\n      <td>121.0</td>\n      <td>55.0</td>\n      <td>11.0</td>\n      <td>NaN</td>\n    </tr>\n  </tbody>\n</table>\n<p>10000 rows \u00d7 27 columns</p>\n</div>",
   "text/plain": "          A      B      C some_text      D      E      F      G      H      I  \\\n0       NaN   11.0   44.0    Blabla   99.0    NaN   88.0   22.0  165.0  143.0   \n1      11.0   22.0   55.0    Blabla  110.0    NaN   99.0   33.0    NaN  154.0   \n2      22.0   33.0   66.0    Blabla  121.0   11.0  110.0   44.0    NaN  165.0   \n3      33.0   44.0   77.0    Blabla  132.0   22.0  121.0   55.0   11.0    NaN   \n4      44.0   55.0   88.0    Blabla  143.0   33.0  132.0   66.0   22.0    NaN   \n5      55.0   66.0   99.0    Blabla  154.0   44.0  143.0   77.0   33.0   11.0   \n6      66.0   77.0  110.0    Blabla  165.0   55.0  154.0   88.0   44.0   22.0   \n7      77.0   88.0  121.0    Blabla    NaN   66.0  165.0   99.0   55.0   33.0   \n8      88.0   99.0  132.0    Blabla    NaN   77.0    NaN  110.0   66.0   44.0   \n9      99.0  110.0  143.0    Blabla   11.0   88.0    NaN  121.0   77.0   55.0   \n10    110.0  121.0  154.0    Blabla   22.0   99.0   11.0  132.0   88.0   66.0   \n11    121.0  132.0  165.0    Blabla   33.0  110.0   22.0  143.0   99.0   77.0   \n12    132.0  143.0    NaN    Blabla   44.0  121.0   33.0  154.0  110.0   88.0   \n13    143.0  154.0    NaN    Blabla   55.0  132.0   44.0  165.0  121.0   99.0   \n14    154.0  165.0   11.0    Blabla   66.0  143.0   55.0    NaN  132.0  110.0   \n15    165.0    NaN   22.0    Blabla   77.0  154.0   66.0    NaN  143.0  121.0   \n16      NaN    NaN   33.0    Blabla   88.0  165.0   77.0   11.0  154.0  132.0   \n17      NaN   11.0   44.0    Blabla   99.0    NaN   88.0   22.0  165.0  143.0   \n18     11.0   22.0   55.0    Blabla  110.0    NaN   99.0   33.0    NaN  154.0   \n19     22.0   33.0   66.0    Blabla  121.0   11.0  110.0   44.0    NaN  165.0   \n20     33.0   44.0   77.0    Blabla  132.0   22.0  121.0   55.0   11.0    NaN   \n21     44.0   55.0   88.0    Blabla  143.0   33.0  132.0   66.0   22.0    NaN   \n22     55.0   66.0   99.0    Blabla  154.0   44.0  143.0   77.0   33.0   11.0   \n23     66.0   77.0  110.0    Blabla  165.0   55.0  154.0   88.0   44.0   22.0   \n24     77.0   88.0  121.0    Blabla    NaN   66.0  165.0   99.0   55.0   33.0   \n25     88.0   99.0  132.0    Blabla    NaN   77.0    NaN  110.0   66.0   44.0   \n26     99.0  110.0  143.0    Blabla   11.0   88.0    NaN  121.0   77.0   55.0   \n27    110.0  121.0  154.0    Blabla   22.0   99.0   11.0  132.0   88.0   66.0   \n28    121.0  132.0  165.0    Blabla   33.0  110.0   22.0  143.0   99.0   77.0   \n29    132.0  143.0    NaN    Blabla   44.0  121.0   33.0  154.0  110.0   88.0   \n...     ...    ...    ...       ...    ...    ...    ...    ...    ...    ...   \n9970   88.0   99.0  132.0    Blabla    NaN   77.0    NaN  110.0   66.0   44.0   \n9971   99.0  110.0  143.0    Blabla   11.0   88.0    NaN  121.0   77.0   55.0   \n9972  110.0  121.0  154.0    Blabla   22.0   99.0   11.0  132.0   88.0   66.0   \n9973  121.0  132.0  165.0    Blabla   33.0  110.0   22.0  143.0   99.0   77.0   \n9974  132.0  143.0    NaN    Blabla   44.0  121.0   33.0  154.0  110.0   88.0   \n9975  143.0  154.0    NaN    Blabla   55.0  132.0   44.0  165.0  121.0   99.0   \n9976  154.0  165.0   11.0    Blabla   66.0  143.0   55.0    NaN  132.0  110.0   \n9977  165.0    NaN   22.0    Blabla   77.0  154.0   66.0    NaN  143.0  121.0   \n9978    NaN    NaN   33.0    Blabla   88.0  165.0   77.0   11.0  154.0  132.0   \n9979    NaN   11.0   44.0    Blabla   99.0    NaN   88.0   22.0  165.0  143.0   \n9980   11.0   22.0   55.0    Blabla  110.0    NaN   99.0   33.0    NaN  154.0   \n9981   22.0   33.0   66.0    Blabla  121.0   11.0  110.0   44.0    NaN  165.0   \n9982   33.0   44.0   77.0    Blabla  132.0   22.0  121.0   55.0   11.0    NaN   \n9983   44.0   55.0   88.0    Blabla  143.0   33.0  132.0   66.0   22.0    NaN   \n9984   55.0   66.0   99.0    Blabla  154.0   44.0  143.0   77.0   33.0   11.0   \n9985   66.0   77.0  110.0    Blabla  165.0   55.0  154.0   88.0   44.0   22.0   \n9986   77.0   88.0  121.0    Blabla    NaN   66.0  165.0   99.0   55.0   33.0   \n9987   88.0   99.0  132.0    Blabla    NaN   77.0    NaN  110.0   66.0   44.0   \n9988   99.0  110.0  143.0    Blabla   11.0   88.0    NaN  121.0   77.0   55.0   \n9989  110.0  121.0  154.0    Blabla   22.0   99.0   11.0  132.0   88.0   66.0   \n9990  121.0  132.0  165.0    Blabla   33.0  110.0   22.0  143.0   99.0   77.0   \n9991  132.0  143.0    NaN    Blabla   44.0  121.0   33.0  154.0  110.0   88.0   \n9992  143.0  154.0    NaN    Blabla   55.0  132.0   44.0  165.0  121.0   99.0   \n9993  154.0  165.0   11.0    Blabla   66.0  143.0   55.0    NaN  132.0  110.0   \n9994  165.0    NaN   22.0    Blabla   77.0  154.0   66.0    NaN  143.0  121.0   \n9995    NaN    NaN   33.0    Blabla   88.0  165.0   77.0   11.0  154.0  132.0   \n9996    NaN   11.0   44.0    Blabla   99.0    NaN   88.0   22.0  165.0  143.0   \n9997   11.0   22.0   55.0    Blabla  110.0    NaN   99.0   33.0    NaN  154.0   \n9998   22.0   33.0   66.0    Blabla  121.0   11.0  110.0   44.0    NaN  165.0   \n9999   33.0   44.0   77.0    Blabla  132.0   22.0  121.0   55.0   11.0    NaN   \n\n      ...        Q      R      S      T      U      V      W      X      Y  \\\n0     ...     11.0    NaN   11.0   44.0   99.0    NaN   88.0   22.0  165.0   \n1     ...     22.0   11.0   22.0   55.0  110.0    NaN   99.0   33.0    NaN   \n2     ...     33.0   22.0   33.0   66.0  121.0   11.0  110.0   44.0    NaN   \n3     ...     44.0   33.0   44.0   77.0  132.0   22.0  121.0   55.0   11.0   \n4     ...     55.0   44.0   55.0   88.0  143.0   33.0  132.0   66.0   22.0   \n5     ...     66.0   55.0   66.0   99.0  154.0   44.0  143.0   77.0   33.0   \n6     ...     77.0   66.0   77.0  110.0  165.0   55.0  154.0   88.0   44.0   \n7     ...     88.0   77.0   88.0  121.0    NaN   66.0  165.0   99.0   55.0   \n8     ...     99.0   88.0   99.0  132.0    NaN   77.0    NaN  110.0   66.0   \n9     ...    110.0   99.0  110.0  143.0   11.0   88.0    NaN  121.0   77.0   \n10    ...    121.0  110.0  121.0  154.0   22.0   99.0   11.0  132.0   88.0   \n11    ...    132.0  121.0  132.0  165.0   33.0  110.0   22.0  143.0   99.0   \n12    ...    143.0  132.0  143.0    NaN   44.0  121.0   33.0  154.0  110.0   \n13    ...    154.0  143.0  154.0    NaN   55.0  132.0   44.0  165.0  121.0   \n14    ...    165.0  154.0  165.0   11.0   66.0  143.0   55.0    NaN  132.0   \n15    ...      NaN  165.0    NaN   22.0   77.0  154.0   66.0    NaN  143.0   \n16    ...      NaN    NaN    NaN   33.0   88.0  165.0   77.0   11.0  154.0   \n17    ...     11.0    NaN   11.0   44.0   99.0    NaN   88.0   22.0  165.0   \n18    ...     22.0   11.0   22.0   55.0  110.0    NaN   99.0   33.0    NaN   \n19    ...     33.0   22.0   33.0   66.0  121.0   11.0  110.0   44.0    NaN   \n20    ...     44.0   33.0   44.0   77.0  132.0   22.0  121.0   55.0   11.0   \n21    ...     55.0   44.0   55.0   88.0  143.0   33.0  132.0   66.0   22.0   \n22    ...     66.0   55.0   66.0   99.0  154.0   44.0  143.0   77.0   33.0   \n23    ...     77.0   66.0   77.0  110.0  165.0   55.0  154.0   88.0   44.0   \n24    ...     88.0   77.0   88.0  121.0    NaN   66.0  165.0   99.0   55.0   \n25    ...     99.0   88.0   99.0  132.0    NaN   77.0    NaN  110.0   66.0   \n26    ...    110.0   99.0  110.0  143.0   11.0   88.0    NaN  121.0   77.0   \n27    ...    121.0  110.0  121.0  154.0   22.0   99.0   11.0  132.0   88.0   \n28    ...    132.0  121.0  132.0  165.0   33.0  110.0   22.0  143.0   99.0   \n29    ...    143.0  132.0  143.0    NaN   44.0  121.0   33.0  154.0  110.0   \n...   ...      ...    ...    ...    ...    ...    ...    ...    ...    ...   \n9970  ...     99.0   88.0   99.0  132.0    NaN   77.0    NaN  110.0   66.0   \n9971  ...    110.0   99.0  110.0  143.0   11.0   88.0    NaN  121.0   77.0   \n9972  ...    121.0  110.0  121.0  154.0   22.0   99.0   11.0  132.0   88.0   \n9973  ...    132.0  121.0  132.0  165.0   33.0  110.0   22.0  143.0   99.0   \n9974  ...    143.0  132.0  143.0    NaN   44.0  121.0   33.0  154.0  110.0   \n9975  ...    154.0  143.0  154.0    NaN   55.0  132.0   44.0  165.0  121.0   \n9976  ...    165.0  154.0  165.0   11.0   66.0  143.0   55.0    NaN  132.0   \n9977  ...      NaN  165.0    NaN   22.0   77.0  154.0   66.0    NaN  143.0   \n9978  ...      NaN    NaN    NaN   33.0   88.0  165.0   77.0   11.0  154.0   \n9979  ...     11.0    NaN   11.0   44.0   99.0    NaN   88.0   22.0  165.0   \n9980  ...     22.0   11.0   22.0   55.0  110.0    NaN   99.0   33.0    NaN   \n9981  ...     33.0   22.0   33.0   66.0  121.0   11.0  110.0   44.0    NaN   \n9982  ...     44.0   33.0   44.0   77.0  132.0   22.0  121.0   55.0   11.0   \n9983  ...     55.0   44.0   55.0   88.0  143.0   33.0  132.0   66.0   22.0   \n9984  ...     66.0   55.0   66.0   99.0  154.0   44.0  143.0   77.0   33.0   \n9985  ...     77.0   66.0   77.0  110.0  165.0   55.0  154.0   88.0   44.0   \n9986  ...     88.0   77.0   88.0  121.0    NaN   66.0  165.0   99.0   55.0   \n9987  ...     99.0   88.0   99.0  132.0    NaN   77.0    NaN  110.0   66.0   \n9988  ...    110.0   99.0  110.0  143.0   11.0   88.0    NaN  121.0   77.0   \n9989  ...    121.0  110.0  121.0  154.0   22.0   99.0   11.0  132.0   88.0   \n9990  ...    132.0  121.0  132.0  165.0   33.0  110.0   22.0  143.0   99.0   \n9991  ...    143.0  132.0  143.0    NaN   44.0  121.0   33.0  154.0  110.0   \n9992  ...    154.0  143.0  154.0    NaN   55.0  132.0   44.0  165.0  121.0   \n9993  ...    165.0  154.0  165.0   11.0   66.0  143.0   55.0    NaN  132.0   \n9994  ...      NaN  165.0    NaN   22.0   77.0  154.0   66.0    NaN  143.0   \n9995  ...      NaN    NaN    NaN   33.0   88.0  165.0   77.0   11.0  154.0   \n9996  ...     11.0    NaN   11.0   44.0   99.0    NaN   88.0   22.0  165.0   \n9997  ...     22.0   11.0   22.0   55.0  110.0    NaN   99.0   33.0    NaN   \n9998  ...     33.0   22.0   33.0   66.0  121.0   11.0  110.0   44.0    NaN   \n9999  ...     44.0   33.0   44.0   77.0  132.0   22.0  121.0   55.0   11.0   \n\n          Z  \n0     143.0  \n1     154.0  \n2     165.0  \n3       NaN  \n4       NaN  \n5      11.0  \n6      22.0  \n7      33.0  \n8      44.0  \n9      55.0  \n10     66.0  \n11     77.0  \n12     88.0  \n13     99.0  \n14    110.0  \n15    121.0  \n16    132.0  \n17    143.0  \n18    154.0  \n19    165.0  \n20      NaN  \n21      NaN  \n22     11.0  \n23     22.0  \n24     33.0  \n25     44.0  \n26     55.0  \n27     66.0  \n28     77.0  \n29     88.0  \n...     ...  \n9970   44.0  \n9971   55.0  \n9972   66.0  \n9973   77.0  \n9974   88.0  \n9975   99.0  \n9976  110.0  \n9977  121.0  \n9978  132.0  \n9979  143.0  \n9980  154.0  \n9981  165.0  \n9982    NaN  \n9983    NaN  \n9984   11.0  \n9985   22.0  \n9986   33.0  \n9987   44.0  \n9988   55.0  \n9989   66.0  \n9990   77.0  \n9991   88.0  \n9992   99.0  \n9993  110.0  \n9994  121.0  \n9995  132.0  \n9996  143.0  \n9997  154.0  \n9998  165.0  \n9999    NaN  \n\n[10000 rows x 27 columns]"
  },
  "execution_count": 125,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

The head() method returns the top 5 rows:

```{.python .input} large_df.head()


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>A</th>\n      <th>B</th>\n      <th>C</th>\n      <th>some_text</th>\n      <th>D</th>\n      <th>E</th>\n      <th>F</th>\n      <th>G</th>\n      <th>H</th>\n      <th>I</th>\n      <th>...</th>\n      <th>Q</th>\n      <th>R</th>\n      <th>S</th>\n      <th>T</th>\n      <th>U</th>\n      <th>V</th>\n      <th>W</th>\n      <th>X</th>\n      <th>Y</th>\n      <th>Z</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>0</th>\n      <td>NaN</td>\n      <td>11.0</td>\n      <td>44.0</td>\n      <td>Blabla</td>\n      <td>99.0</td>\n      <td>NaN</td>\n      <td>88.0</td>\n      <td>22.0</td>\n      <td>165.0</td>\n      <td>143.0</td>\n      <td>...</td>\n      <td>11.0</td>\n      <td>NaN</td>\n      <td>11.0</td>\n      <td>44.0</td>\n      <td>99.0</td>\n      <td>NaN</td>\n      <td>88.0</td>\n      <td>22.0</td>\n      <td>165.0</td>\n      <td>143.0</td>\n    </tr>\n    <tr>\n      <th>1</th>\n      <td>11.0</td>\n      <td>22.0</td>\n      <td>55.0</td>\n      <td>Blabla</td>\n      <td>110.0</td>\n      <td>NaN</td>\n      <td>99.0</td>\n      <td>33.0</td>\n      <td>NaN</td>\n      <td>154.0</td>\n      <td>...</td>\n      <td>22.0</td>\n      <td>11.0</td>\n      <td>22.0</td>\n      <td>55.0</td>\n      <td>110.0</td>\n      <td>NaN</td>\n      <td>99.0</td>\n      <td>33.0</td>\n      <td>NaN</td>\n      <td>154.0</td>\n    </tr>\n    <tr>\n      <th>2</th>\n      <td>22.0</td>\n      <td>33.0</td>\n      <td>66.0</td>\n      <td>Blabla</td>\n      <td>121.0</td>\n      <td>11.0</td>\n      <td>110.0</td>\n      <td>44.0</td>\n      <td>NaN</td>\n      <td>165.0</td>\n      <td>...</td>\n      <td>33.0</td>\n      <td>22.0</td>\n      <td>33.0</td>\n      <td>66.0</td>\n      <td>121.0</td>\n      <td>11.0</td>\n      <td>110.0</td>\n      <td>44.0</td>\n      <td>NaN</td>\n      <td>165.0</td>\n    </tr>\n    <tr>\n      <th>3</th>\n      <td>33.0</td>\n      <td>44.0</td>\n      <td>77.0</td>\n      <td>Blabla</td>\n      <td>132.0</td>\n      <td>22.0</td>\n      <td>121.0</td>\n      <td>55.0</td>\n      <td>11.0</td>\n      <td>NaN</td>\n      <td>...</td>\n      <td>44.0</td>\n      <td>33.0</td>\n      <td>44.0</td>\n      <td>77.0</td>\n      <td>132.0</td>\n      <td>22.0</td>\n      <td>121.0</td>\n      <td>55.0</td>\n      <td>11.0</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>4</th>\n      <td>44.0</td>\n      <td>55.0</td>\n      <td>88.0</td>\n      <td>Blabla</td>\n      <td>143.0</td>\n      <td>33.0</td>\n      <td>132.0</td>\n      <td>66.0</td>\n      <td>22.0</td>\n      <td>NaN</td>\n      <td>...</td>\n      <td>55.0</td>\n      <td>44.0</td>\n      <td>55.0</td>\n      <td>88.0</td>\n      <td>143.0</td>\n      <td>33.0</td>\n      <td>132.0</td>\n      <td>66.0</td>\n      <td>22.0</td>\n      <td>NaN</td>\n    </tr>\n  </tbody>\n</table>\n<p>5 rows \u00d7 27 columns</p>\n</div>",
   "text/plain": "      A     B     C some_text      D     E      F     G      H      I  ...    \\\n0   NaN  11.0  44.0    Blabla   99.0   NaN   88.0  22.0  165.0  143.0  ...     \n1  11.0  22.0  55.0    Blabla  110.0   NaN   99.0  33.0    NaN  154.0  ...     \n2  22.0  33.0  66.0    Blabla  121.0  11.0  110.0  44.0    NaN  165.0  ...     \n3  33.0  44.0  77.0    Blabla  132.0  22.0  121.0  55.0   11.0    NaN  ...     \n4  44.0  55.0  88.0    Blabla  143.0  33.0  132.0  66.0   22.0    NaN  ...     \n\n      Q     R     S     T      U     V      W     X      Y      Z  \n0  11.0   NaN  11.0  44.0   99.0   NaN   88.0  22.0  165.0  143.0  \n1  22.0  11.0  22.0  55.0  110.0   NaN   99.0  33.0    NaN  154.0  \n2  33.0  22.0  33.0  66.0  121.0  11.0  110.0  44.0    NaN  165.0  \n3  44.0  33.0  44.0  77.0  132.0  22.0  121.0  55.0   11.0    NaN  \n4  55.0  44.0  55.0  88.0  143.0  33.0  132.0  66.0   22.0    NaN  \n\n[5 rows x 27 columns]"
  },
  "execution_count": 126,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Of course there’s also a tail() function to view the bottom 5 rows. You can pass the number of rows you want:

```{.python .input} large_df.tail(n=2)


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>A</th>\n      <th>B</th>\n      <th>C</th>\n      <th>some_text</th>\n      <th>D</th>\n      <th>E</th>\n      <th>F</th>\n      <th>G</th>\n      <th>H</th>\n      <th>I</th>\n      <th>...</th>\n      <th>Q</th>\n      <th>R</th>\n      <th>S</th>\n      <th>T</th>\n      <th>U</th>\n      <th>V</th>\n      <th>W</th>\n      <th>X</th>\n      <th>Y</th>\n      <th>Z</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>9998</th>\n      <td>22.0</td>\n      <td>33.0</td>\n      <td>66.0</td>\n      <td>Blabla</td>\n      <td>121.0</td>\n      <td>11.0</td>\n      <td>110.0</td>\n      <td>44.0</td>\n      <td>NaN</td>\n      <td>165.0</td>\n      <td>...</td>\n      <td>33.0</td>\n      <td>22.0</td>\n      <td>33.0</td>\n      <td>66.0</td>\n      <td>121.0</td>\n      <td>11.0</td>\n      <td>110.0</td>\n      <td>44.0</td>\n      <td>NaN</td>\n      <td>165.0</td>\n    </tr>\n    <tr>\n      <th>9999</th>\n      <td>33.0</td>\n      <td>44.0</td>\n      <td>77.0</td>\n      <td>Blabla</td>\n      <td>132.0</td>\n      <td>22.0</td>\n      <td>121.0</td>\n      <td>55.0</td>\n      <td>11.0</td>\n      <td>NaN</td>\n      <td>...</td>\n      <td>44.0</td>\n      <td>33.0</td>\n      <td>44.0</td>\n      <td>77.0</td>\n      <td>132.0</td>\n      <td>22.0</td>\n      <td>121.0</td>\n      <td>55.0</td>\n      <td>11.0</td>\n      <td>NaN</td>\n    </tr>\n  </tbody>\n</table>\n<p>2 rows \u00d7 27 columns</p>\n</div>",
   "text/plain": "         A     B     C some_text      D     E      F     G     H      I  \\\n9998  22.0  33.0  66.0    Blabla  121.0  11.0  110.0  44.0   NaN  165.0   \n9999  33.0  44.0  77.0    Blabla  132.0  22.0  121.0  55.0  11.0    NaN   \n\n      ...       Q     R     S     T      U     V      W     X     Y      Z  \n9998  ...    33.0  22.0  33.0  66.0  121.0  11.0  110.0  44.0   NaN  165.0  \n9999  ...    44.0  33.0  44.0  77.0  132.0  22.0  121.0  55.0  11.0    NaN  \n\n[2 rows x 27 columns]"
  },
  "execution_count": 127,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

The info() method prints out a summary of each columns contents:

```{.python .input} large_df.info()


```{.json .output n=None}
[
 {
  "name": "stdout",
  "output_type": "stream",
  "text": "<class 'pandas.core.frame.DataFrame'>\nRangeIndex: 10000 entries, 0 to 9999\nData columns (total 27 columns):\nA            8823 non-null float64\nB            8824 non-null float64\nC            8824 non-null float64\nsome_text    10000 non-null object\nD            8824 non-null float64\nE            8822 non-null float64\nF            8824 non-null float64\nG            8824 non-null float64\nH            8822 non-null float64\nI            8823 non-null float64\nJ            8823 non-null float64\nK            8822 non-null float64\nL            8824 non-null float64\nM            8824 non-null float64\nN            8822 non-null float64\nO            8824 non-null float64\nP            8824 non-null float64\nQ            8824 non-null float64\nR            8823 non-null float64\nS            8824 non-null float64\nT            8824 non-null float64\nU            8824 non-null float64\nV            8822 non-null float64\nW            8824 non-null float64\nX            8824 non-null float64\nY            8822 non-null float64\nZ            8823 non-null float64\ndtypes: float64(26), object(1)\nmemory usage: 2.1+ MB\n"
 }
]

Finally, the describe() method gives a nice overview of the main aggregated values over each column:

  • count: number of non-null (not NaN) values
  • mean: mean of non-null values
  • std: standard deviation of non-null values
  • min: minimum of non-null values
  • 25%, 50%, 75%: 25th, 50th and 75th percentile of non-null values
  • max: maximum of non-null values

```{.python .input} large_df.describe()


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>A</th>\n      <th>B</th>\n      <th>C</th>\n      <th>D</th>\n      <th>E</th>\n      <th>F</th>\n      <th>G</th>\n      <th>H</th>\n      <th>I</th>\n      <th>J</th>\n      <th>...</th>\n      <th>Q</th>\n      <th>R</th>\n      <th>S</th>\n      <th>T</th>\n      <th>U</th>\n      <th>V</th>\n      <th>W</th>\n      <th>X</th>\n      <th>Y</th>\n      <th>Z</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>count</th>\n      <td>8823.000000</td>\n      <td>8824.000000</td>\n      <td>8824.000000</td>\n      <td>8824.000000</td>\n      <td>8822.000000</td>\n      <td>8824.000000</td>\n      <td>8824.000000</td>\n      <td>8822.000000</td>\n      <td>8823.000000</td>\n      <td>8823.000000</td>\n      <td>...</td>\n      <td>8824.000000</td>\n      <td>8823.000000</td>\n      <td>8824.000000</td>\n      <td>8824.000000</td>\n      <td>8824.000000</td>\n      <td>8822.000000</td>\n      <td>8824.000000</td>\n      <td>8824.000000</td>\n      <td>8822.000000</td>\n      <td>8823.000000</td>\n    </tr>\n    <tr>\n      <th>mean</th>\n      <td>87.977559</td>\n      <td>87.972575</td>\n      <td>87.987534</td>\n      <td>88.012466</td>\n      <td>87.983791</td>\n      <td>88.007480</td>\n      <td>87.977561</td>\n      <td>88.000000</td>\n      <td>88.022441</td>\n      <td>88.022441</td>\n      <td>...</td>\n      <td>87.972575</td>\n      <td>87.977559</td>\n      <td>87.972575</td>\n      <td>87.987534</td>\n      <td>88.012466</td>\n      <td>87.983791</td>\n      <td>88.007480</td>\n      <td>87.977561</td>\n      <td>88.000000</td>\n      <td>88.022441</td>\n    </tr>\n    <tr>\n      <th>std</th>\n      <td>47.535911</td>\n      <td>47.535523</td>\n      <td>47.521679</td>\n      <td>47.521679</td>\n      <td>47.535001</td>\n      <td>47.519371</td>\n      <td>47.529755</td>\n      <td>47.536879</td>\n      <td>47.535911</td>\n      <td>47.535911</td>\n      <td>...</td>\n      <td>47.535523</td>\n      <td>47.535911</td>\n      <td>47.535523</td>\n      <td>47.521679</td>\n      <td>47.521679</td>\n      <td>47.535001</td>\n      <td>47.519371</td>\n      <td>47.529755</td>\n      <td>47.536879</td>\n      <td>47.535911</td>\n    </tr>\n    <tr>\n      <th>min</th>\n      <td>11.000000</td>\n      <td>11.000000</td>\n      <td>11.000000</td>\n      <td>11.000000</td>\n      <td>11.000000</td>\n      <td>11.000000</td>\n      <td>11.000000</td>\n      <td>11.000000</td>\n      <td>11.000000</td>\n      <td>11.000000</td>\n      <td>...</td>\n      <td>11.000000</td>\n      <td>11.000000</td>\n      <td>11.000000</td>\n      <td>11.000000</td>\n      <td>11.000000</td>\n      <td>11.000000</td>\n      <td>11.000000</td>\n      <td>11.000000</td>\n      <td>11.000000</td>\n      <td>11.000000</td>\n    </tr>\n    <tr>\n      <th>25%</th>\n      <td>44.000000</td>\n      <td>44.000000</td>\n      <td>44.000000</td>\n      <td>44.000000</td>\n      <td>44.000000</td>\n      <td>44.000000</td>\n      <td>44.000000</td>\n      <td>44.000000</td>\n      <td>44.000000</td>\n      <td>44.000000</td>\n      <td>...</td>\n      <td>44.000000</td>\n      <td>44.000000</td>\n      <td>44.000000</td>\n      <td>44.000000</td>\n      <td>44.000000</td>\n      <td>44.000000</td>\n      <td>44.000000</td>\n      <td>44.000000</td>\n      <td>44.000000</td>\n      <td>44.000000</td>\n    </tr>\n    <tr>\n      <th>50%</th>\n      <td>88.000000</td>\n      <td>88.000000</td>\n      <td>88.000000</td>\n      <td>88.000000</td>\n      <td>88.000000</td>\n      <td>88.000000</td>\n      <td>88.000000</td>\n      <td>88.000000</td>\n      <td>88.000000</td>\n      <td>88.000000</td>\n      <td>...</td>\n      <td>88.000000</td>\n      <td>88.000000</td>\n      <td>88.000000</td>\n      <td>88.000000</td>\n      <td>88.000000</td>\n      <td>88.000000</td>\n      <td>88.000000</td>\n      <td>88.000000</td>\n      <td>88.000000</td>\n      <td>88.000000</td>\n    </tr>\n    <tr>\n      <th>75%</th>\n      <td>132.000000</td>\n      <td>132.000000</td>\n      <td>132.000000</td>\n      <td>132.000000</td>\n      <td>132.000000</td>\n      <td>132.000000</td>\n      <td>132.000000</td>\n      <td>132.000000</td>\n      <td>132.000000</td>\n      <td>132.000000</td>\n      <td>...</td>\n      <td>132.000000</td>\n      <td>132.000000</td>\n      <td>132.000000</td>\n      <td>132.000000</td>\n      <td>132.000000</td>\n      <td>132.000000</td>\n      <td>132.000000</td>\n      <td>132.000000</td>\n      <td>132.000000</td>\n      <td>132.000000</td>\n    </tr>\n    <tr>\n      <th>max</th>\n      <td>165.000000</td>\n      <td>165.000000</td>\n      <td>165.000000</td>\n      <td>165.000000</td>\n      <td>165.000000</td>\n      <td>165.000000</td>\n      <td>165.000000</td>\n      <td>165.000000</td>\n      <td>165.000000</td>\n      <td>165.000000</td>\n      <td>...</td>\n      <td>165.000000</td>\n      <td>165.000000</td>\n      <td>165.000000</td>\n      <td>165.000000</td>\n      <td>165.000000</td>\n      <td>165.000000</td>\n      <td>165.000000</td>\n      <td>165.000000</td>\n      <td>165.000000</td>\n      <td>165.000000</td>\n    </tr>\n  </tbody>\n</table>\n<p>8 rows \u00d7 26 columns</p>\n</div>",
   "text/plain": "                 A            B            C            D            E  \\\ncount  8823.000000  8824.000000  8824.000000  8824.000000  8822.000000   \nmean     87.977559    87.972575    87.987534    88.012466    87.983791   \nstd      47.535911    47.535523    47.521679    47.521679    47.535001   \nmin      11.000000    11.000000    11.000000    11.000000    11.000000   \n25%      44.000000    44.000000    44.000000    44.000000    44.000000   \n50%      88.000000    88.000000    88.000000    88.000000    88.000000   \n75%     132.000000   132.000000   132.000000   132.000000   132.000000   \nmax     165.000000   165.000000   165.000000   165.000000   165.000000   \n\n                 F            G            H            I            J  \\\ncount  8824.000000  8824.000000  8822.000000  8823.000000  8823.000000   \nmean     88.007480    87.977561    88.000000    88.022441    88.022441   \nstd      47.519371    47.529755    47.536879    47.535911    47.535911   \nmin      11.000000    11.000000    11.000000    11.000000    11.000000   \n25%      44.000000    44.000000    44.000000    44.000000    44.000000   \n50%      88.000000    88.000000    88.000000    88.000000    88.000000   \n75%     132.000000   132.000000   132.000000   132.000000   132.000000   \nmax     165.000000   165.000000   165.000000   165.000000   165.000000   \n\n          ...                 Q            R            S            T  \\\ncount     ...       8824.000000  8823.000000  8824.000000  8824.000000   \nmean      ...         87.972575    87.977559    87.972575    87.987534   \nstd       ...         47.535523    47.535911    47.535523    47.521679   \nmin       ...         11.000000    11.000000    11.000000    11.000000   \n25%       ...         44.000000    44.000000    44.000000    44.000000   \n50%       ...         88.000000    88.000000    88.000000    88.000000   \n75%       ...        132.000000   132.000000   132.000000   132.000000   \nmax       ...        165.000000   165.000000   165.000000   165.000000   \n\n                 U            V            W            X            Y  \\\ncount  8824.000000  8822.000000  8824.000000  8824.000000  8822.000000   \nmean     88.012466    87.983791    88.007480    87.977561    88.000000   \nstd      47.521679    47.535001    47.519371    47.529755    47.536879   \nmin      11.000000    11.000000    11.000000    11.000000    11.000000   \n25%      44.000000    44.000000    44.000000    44.000000    44.000000   \n50%      88.000000    88.000000    88.000000    88.000000    88.000000   \n75%     132.000000   132.000000   132.000000   132.000000   132.000000   \nmax     165.000000   165.000000   165.000000   165.000000   165.000000   \n\n                 Z  \ncount  8823.000000  \nmean     88.022441  \nstd      47.535911  \nmin      11.000000  \n25%      44.000000  \n50%      88.000000  \n75%     132.000000  \nmax     165.000000  \n\n[8 rows x 26 columns]"
  },
  "execution_count": 129,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Saving & loading

Pandas can save DataFrames to various backends, including file formats such as CSV, Excel, JSON, HTML and HDF5, or to a SQL database. Let’s create a DataFrame to demonstrate this:

```{.python .input} my_df = pd.DataFrame( [[“Biking”, 68.5, 1985, np.nan], [“Dancing”, 83.1, 1984, 3]], columns=[“hobby”,”weight”,”birthyear”,”children”], index=[“alice”, “bob”] ) my_df


```{.json .output n=None}
[
 {
  "data": {
   "text/html": "<div>\n<style>\n    .dataframe thead tr:only-child th {\n        text-align: right;\n    }\n\n    .dataframe thead th {\n        text-align: left;\n    }\n\n    .dataframe tbody tr th {\n        vertical-align: top;\n    }\n</style>\n<table border=\"1\" class=\"dataframe\">\n  <thead>\n    <tr style=\"text-align: right;\">\n      <th></th>\n      <th>hobby</th>\n      <th>weight</th>\n      <th>birthyear</th>\n      <th>children</th>\n    </tr>\n  </thead>\n  <tbody>\n    <tr>\n      <th>alice</th>\n      <td>Biking</td>\n      <td>68.5</td>\n      <td>1985</td>\n      <td>NaN</td>\n    </tr>\n    <tr>\n      <th>bob</th>\n      <td>Dancing</td>\n      <td>83.1</td>\n      <td>1984</td>\n      <td>3.0</td>\n    </tr>\n  </tbody>\n</table>\n</div>",
   "text/plain": "         hobby  weight  birthyear  children\nalice   Biking    68.5       1985       NaN\nbob    Dancing    83.1       1984       3.0"
  },
  "execution_count": 130,
  "metadata": {
   "tags": []
  },
  "output_type": "execute_result"
 }
]

Saving

Let’s save it to CSV, HTML and JSON:

```{.python .input} my_df.to_csv(“my_df.csv”) my_df.to_html(“my_df.html”) my_df.to_json(“my_df.json”)


Done! Let's take a peek at what was saved:

```{.python .input}
for filename in ("my_df.csv", "my_df.html", "my_df.json"):
    print("##", filename)
    with open(filename, "rt") as f:
        print(f.read())
        print()

```{.json .output n=None} [ { “name”: “stdout”, “output_type”: “stream”, “text”: “## my_df.csv\n,hobby,weight,birthyear,children\nalice,Biking,68.5,1985,\nbob,Dancing,83.1,1984,3.0\n\n\n## my_df.html\n<table border="1" class="dataframe">\n <thead>\n <tr style="text-align: right;">\n <th></th>\n <th>hobby</th>\n <th>weight</th>\n <th>birthyear</th>\n <th>children</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>alice</th>\n <td>Biking</td>\n <td>68.5</td>\n <td>1985</td>\n <td>NaN</td>\n </tr>\n <tr>\n <th>bob</th>\n <td>Dancing</td>\n <td>83.1</td>\n <td>1984</td>\n <td>3.0</td>\n </tr>\n </tbody>\n</table>\n\n## my_df.json\n{"hobby":{"alice":"Biking","bob":"Dancing"},"weight":{"alice":68.5,"bob":83.1},"birthyear":{"alice":1985,"bob":1984},"children":{"alice":null,"bob":3.0}}\n\n” } ]


Note that the index is saved as the first column (with no name) in a CSV file,
as `<th>` tags in HTML and as keys in JSON.

Saving to other formats works very similarly, but some formats require extra
libraries to be installed. For example, saving to Excel requires the openpyxl
library:

```{.python .input}
try:
    my_df.to_excel("my_df.xlsx", sheet_name='People')
except ImportError as e:
    print(e)

```{.json .output n=None} [ { “name”: “stdout”, “output_type”: “stream”, “text”: “No module named ‘openpyxl’\n” } ]


#### Loading
Now let's load our CSV file back into a `DataFrame`:

```{.python .input}
my_df_loaded = pd.read_csv("my_df.csv", index_col=0)
my_df_loaded

```{.json .output n=None} [ { “data”: { “text/html”: “<div>\n\n<table border="1" class="dataframe">\n <thead>\n <tr style="text-align: right;">\n <th></th>\n <th>hobby</th>\n <th>weight</th>\n <th>birthyear</th>\n <th>children</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>alice</th>\n <td>Biking</td>\n <td>68.5</td>\n <td>1985</td>\n <td>NaN</td>\n </tr>\n <tr>\n <th>bob</th>\n <td>Dancing</td>\n <td>83.1</td>\n <td>1984</td>\n <td>3.0</td>\n </tr>\n </tbody>\n</table>\n</div>”, “text/plain”: “ hobby weight birthyear children\nalice Biking 68.5 1985 NaN\nbob Dancing 83.1 1984 3.0” }, “execution_count”: 134, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


As you might guess, there are similar `read_json`, `read_html`, `read_excel`
functions as well.  We can also read data straight from the Internet. For
example, let's load all U.S. cities from
[simplemaps.com](http://simplemaps.com/):

```{.python .input}
us_cities = None
try:
    csv_url = "http://simplemaps.com/files/cities.csv"
    us_cities = pd.read_csv(csv_url, index_col=0)
    us_cities = us_cities.head()
except IOError as e:
    print(e)
us_cities

```{.json .output n=None} [ { “name”: “stdout”, “output_type”: “stream”, “text”: “<urlopen error [Errno 8] nodename nor servname provided, or not known>\n” } ]


There are more options available, in particular regarding datetime format. Check
out the [documentation](http://pandas.pydata.org/pandas-docs/stable/io.html) for
more details.

## Combining `DataFrame`s

#### SQL-like joins
One powerful feature of pandas is it's ability to perform SQL-like joins on
`DataFrame`s. Various types of joins are supported: inner joins, left/right
outer joins and full joins. To illustrate this, let's start by creating a couple
simple `DataFrame`s:

```{.python .input}
city_loc = pd.DataFrame(
    [
        ["CA", "San Francisco", 37.781334, -122.416728],
        ["NY", "New York", 40.705649, -74.008344],
        ["FL", "Miami", 25.791100, -80.320733],
        ["OH", "Cleveland", 41.473508, -81.739791],
        ["UT", "Salt Lake City", 40.755851, -111.896657]
    ], columns=["state", "city", "lat", "lng"])
city_loc

```{.json .output n=None} [ { “data”: { “text/html”: “<div>\n\n<table border="1" class="dataframe">\n <thead>\n <tr style="text-align: right;">\n <th></th>\n <th>state</th>\n <th>city</th>\n <th>lat</th>\n <th>lng</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>CA</td>\n <td>San Francisco</td>\n <td>37.781334</td>\n <td>-122.416728</td>\n </tr>\n <tr>\n <th>1</th>\n <td>NY</td>\n <td>New York</td>\n <td>40.705649</td>\n <td>-74.008344</td>\n </tr>\n <tr>\n <th>2</th>\n <td>FL</td>\n <td>Miami</td>\n <td>25.791100</td>\n <td>-80.320733</td>\n </tr>\n <tr>\n <th>3</th>\n <td>OH</td>\n <td>Cleveland</td>\n <td>41.473508</td>\n <td>-81.739791</td>\n </tr>\n <tr>\n <th>4</th>\n <td>UT</td>\n <td>Salt Lake City</td>\n <td>40.755851</td>\n <td>-111.896657</td>\n </tr>\n </tbody>\n</table>\n</div>”, “text/plain”: “ state city lat lng\n0 CA San Francisco 37.781334 -122.416728\n1 NY New York 40.705649 -74.008344\n2 FL Miami 25.791100 -80.320733\n3 OH Cleveland 41.473508 -81.739791\n4 UT Salt Lake City 40.755851 -111.896657” }, “execution_count”: 136, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


```{.python .input}
city_pop = pd.DataFrame(
    [
        [808976, "San Francisco", "California"],
        [8363710, "New York", "New-York"],
        [413201, "Miami", "Florida"],
        [2242193, "Houston", "Texas"]
    ], index=[3,4,5,6], columns=["population", "city", "state"])
city_pop

```{.json .output n=None} [ { “data”: { “text/html”: “<div>\n\n<table border="1" class="dataframe">\n <thead>\n <tr style="text-align: right;">\n <th></th>\n <th>population</th>\n <th>city</th>\n <th>state</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>3</th>\n <td>808976</td>\n <td>San Francisco</td>\n <td>California</td>\n </tr>\n <tr>\n <th>4</th>\n <td>8363710</td>\n <td>New York</td>\n <td>New-York</td>\n </tr>\n <tr>\n <th>5</th>\n <td>413201</td>\n <td>Miami</td>\n <td>Florida</td>\n </tr>\n <tr>\n <th>6</th>\n <td>2242193</td>\n <td>Houston</td>\n <td>Texas</td>\n </tr>\n </tbody>\n</table>\n</div>”, “text/plain”: “ population city state\n3 808976 San Francisco California\n4 8363710 New York New-York\n5 413201 Miami Florida\n6 2242193 Houston Texas” }, “execution_count”: 137, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


Now let's join these `DataFrame`s using the `merge()` function:

```{.python .input}
pd.merge(left=city_loc, right=city_pop, on="city")

```{.json .output n=None} [ { “data”: { “text/html”: “<div>\n\n<table border="1" class="dataframe">\n <thead>\n <tr style="text-align: right;">\n <th></th>\n <th>state_x</th>\n <th>city</th>\n <th>lat</th>\n <th>lng</th>\n <th>population</th>\n <th>state_y</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>CA</td>\n <td>San Francisco</td>\n <td>37.781334</td>\n <td>-122.416728</td>\n <td>808976</td>\n <td>California</td>\n </tr>\n <tr>\n <th>1</th>\n <td>NY</td>\n <td>New York</td>\n <td>40.705649</td>\n <td>-74.008344</td>\n <td>8363710</td>\n <td>New-York</td>\n </tr>\n <tr>\n <th>2</th>\n <td>FL</td>\n <td>Miami</td>\n <td>25.791100</td>\n <td>-80.320733</td>\n <td>413201</td>\n <td>Florida</td>\n </tr>\n </tbody>\n</table>\n</div>”, “text/plain”: “ state_x city lat lng population state_y\n0 CA San Francisco 37.781334 -122.416728 808976 California\n1 NY New York 40.705649 -74.008344 8363710 New-York\n2 FL Miami 25.791100 -80.320733 413201 Florida” }, “execution_count”: 138, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


Note that both `DataFrame`s have a column named `state`, so in the result they
got renamed to `state_x` and `state_y`.

Also, note that Cleveland, Salt Lake City and Houston were dropped because they
don't exist in *both* `DataFrame`s. This is the equivalent of a SQL `INNER
JOIN`. If you want a `FULL OUTER JOIN`, where no city gets dropped and `NaN`
values are added, you must specify `how="outer"`:

```{.python .input}
all_cities = pd.merge(left=city_loc, right=city_pop, on="city", how="outer")
all_cities

```{.json .output n=None} [ { “data”: { “text/html”: “<div>\n\n<table border="1" class="dataframe">\n <thead>\n <tr style="text-align: right;">\n <th></th>\n <th>state_x</th>\n <th>city</th>\n <th>lat</th>\n <th>lng</th>\n <th>population</th>\n <th>state_y</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>CA</td>\n <td>San Francisco</td>\n <td>37.781334</td>\n <td>-122.416728</td>\n <td>808976.0</td>\n <td>California</td>\n </tr>\n <tr>\n <th>1</th>\n <td>NY</td>\n <td>New York</td>\n <td>40.705649</td>\n <td>-74.008344</td>\n <td>8363710.0</td>\n <td>New-York</td>\n </tr>\n <tr>\n <th>2</th>\n <td>FL</td>\n <td>Miami</td>\n <td>25.791100</td>\n <td>-80.320733</td>\n <td>413201.0</td>\n <td>Florida</td>\n </tr>\n <tr>\n <th>3</th>\n <td>OH</td>\n <td>Cleveland</td>\n <td>41.473508</td>\n <td>-81.739791</td>\n <td>NaN</td>\n <td>NaN</td>\n </tr>\n <tr>\n <th>4</th>\n <td>UT</td>\n <td>Salt Lake City</td>\n <td>40.755851</td>\n <td>-111.896657</td>\n <td>NaN</td>\n <td>NaN</td>\n </tr>\n <tr>\n <th>5</th>\n <td>NaN</td>\n <td>Houston</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>2242193.0</td>\n <td>Texas</td>\n </tr>\n </tbody>\n</table>\n</div>”, “text/plain”: “ state_x city lat lng population state_y\n0 CA San Francisco 37.781334 -122.416728 808976.0 California\n1 NY New York 40.705649 -74.008344 8363710.0 New-York\n2 FL Miami 25.791100 -80.320733 413201.0 Florida\n3 OH Cleveland 41.473508 -81.739791 NaN NaN\n4 UT Salt Lake City 40.755851 -111.896657 NaN NaN\n5 NaN Houston NaN NaN 2242193.0 Texas” }, “execution_count”: 139, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


Of course `LEFT OUTER JOIN` is also available by setting `how="left"`: only the
cities present in the left `DataFrame` end up in the result. Similarly, with
`how="right"` only cities in the right `DataFrame` appear in the result. For
example:

```{.python .input}
pd.merge(left=city_loc, right=city_pop, on="city", how="right")

```{.json .output n=None} [ { “data”: { “text/html”: “<div>\n\n<table border="1" class="dataframe">\n <thead>\n <tr style="text-align: right;">\n <th></th>\n <th>state_x</th>\n <th>city</th>\n <th>lat</th>\n <th>lng</th>\n <th>population</th>\n <th>state_y</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>CA</td>\n <td>San Francisco</td>\n <td>37.781334</td>\n <td>-122.416728</td>\n <td>808976</td>\n <td>California</td>\n </tr>\n <tr>\n <th>1</th>\n <td>NY</td>\n <td>New York</td>\n <td>40.705649</td>\n <td>-74.008344</td>\n <td>8363710</td>\n <td>New-York</td>\n </tr>\n <tr>\n <th>2</th>\n <td>FL</td>\n <td>Miami</td>\n <td>25.791100</td>\n <td>-80.320733</td>\n <td>413201</td>\n <td>Florida</td>\n </tr>\n <tr>\n <th>3</th>\n <td>NaN</td>\n <td>Houston</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>2242193</td>\n <td>Texas</td>\n </tr>\n </tbody>\n</table>\n</div>”, “text/plain”: “ state_x city lat lng population state_y\n0 CA San Francisco 37.781334 -122.416728 808976 California\n1 NY New York 40.705649 -74.008344 8363710 New-York\n2 FL Miami 25.791100 -80.320733 413201 Florida\n3 NaN Houston NaN NaN 2242193 Texas” }, “execution_count”: 140, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


If the key to join on is actually in one (or both) `DataFrame`'s index, you must
use `left_index=True` and/or `right_index=True`. If the key column names differ,
you must use `left_on` and `right_on`. For example:

```{.python .input}
city_pop2 = city_pop.copy()
city_pop2.columns = ["population", "name", "state"]
pd.merge(left=city_loc, right=city_pop2, left_on="city", right_on="name")

```{.json .output n=None} [ { “data”: { “text/html”: “<div>\n\n<table border="1" class="dataframe">\n <thead>\n <tr style="text-align: right;">\n <th></th>\n <th>state_x</th>\n <th>city</th>\n <th>lat</th>\n <th>lng</th>\n <th>population</th>\n <th>name</th>\n <th>state_y</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>CA</td>\n <td>San Francisco</td>\n <td>37.781334</td>\n <td>-122.416728</td>\n <td>808976</td>\n <td>San Francisco</td>\n <td>California</td>\n </tr>\n <tr>\n <th>1</th>\n <td>NY</td>\n <td>New York</td>\n <td>40.705649</td>\n <td>-74.008344</td>\n <td>8363710</td>\n <td>New York</td>\n <td>New-York</td>\n </tr>\n <tr>\n <th>2</th>\n <td>FL</td>\n <td>Miami</td>\n <td>25.791100</td>\n <td>-80.320733</td>\n <td>413201</td>\n <td>Miami</td>\n <td>Florida</td>\n </tr>\n </tbody>\n</table>\n</div>”, “text/plain”: “ state_x city lat lng population name \\n0 CA San Francisco 37.781334 -122.416728 808976 San Francisco \n1 NY New York 40.705649 -74.008344 8363710 New York \n2 FL Miami 25.791100 -80.320733 413201 Miami \n\n state_y \n0 California \n1 New-York \n2 Florida “ }, “execution_count”: 141, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


#### Concatenation
Rather than joining `DataFrame`s, we may just want to concatenate them. That's
what `concat()` is for:

```{.python .input}
result_concat = pd.concat([city_loc, city_pop])
result_concat

```{.json .output n=None} [ { “data”: { “text/html”: “<div>\n\n<table border="1" class="dataframe">\n <thead>\n <tr style="text-align: right;">\n <th></th>\n <th>city</th>\n <th>lat</th>\n <th>lng</th>\n <th>population</th>\n <th>state</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>San Francisco</td>\n <td>37.781334</td>\n <td>-122.416728</td>\n <td>NaN</td>\n <td>CA</td>\n </tr>\n <tr>\n <th>1</th>\n <td>New York</td>\n <td>40.705649</td>\n <td>-74.008344</td>\n <td>NaN</td>\n <td>NY</td>\n </tr>\n <tr>\n <th>2</th>\n <td>Miami</td>\n <td>25.791100</td>\n <td>-80.320733</td>\n <td>NaN</td>\n <td>FL</td>\n </tr>\n <tr>\n <th>3</th>\n <td>Cleveland</td>\n <td>41.473508</td>\n <td>-81.739791</td>\n <td>NaN</td>\n <td>OH</td>\n </tr>\n <tr>\n <th>4</th>\n <td>Salt Lake City</td>\n <td>40.755851</td>\n <td>-111.896657</td>\n <td>NaN</td>\n <td>UT</td>\n </tr>\n <tr>\n <th>3</th>\n <td>San Francisco</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>808976.0</td>\n <td>California</td>\n </tr>\n <tr>\n <th>4</th>\n <td>New York</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>8363710.0</td>\n <td>New-York</td>\n </tr>\n <tr>\n <th>5</th>\n <td>Miami</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>413201.0</td>\n <td>Florida</td>\n </tr>\n <tr>\n <th>6</th>\n <td>Houston</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>2242193.0</td>\n <td>Texas</td>\n </tr>\n </tbody>\n</table>\n</div>”, “text/plain”: “ city lat lng population state\n0 San Francisco 37.781334 -122.416728 NaN CA\n1 New York 40.705649 -74.008344 NaN NY\n2 Miami 25.791100 -80.320733 NaN FL\n3 Cleveland 41.473508 -81.739791 NaN OH\n4 Salt Lake City 40.755851 -111.896657 NaN UT\n3 San Francisco NaN NaN 808976.0 California\n4 New York NaN NaN 8363710.0 New-York\n5 Miami NaN NaN 413201.0 Florida\n6 Houston NaN NaN 2242193.0 Texas” }, “execution_count”: 142, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


Note that this operation aligned the data horizontally (by columns) but not
vertically (by rows). In this example, we end up with multiple rows having the
same index (eg. 3). Pandas handles this rather gracefully:

```{.python .input}
result_concat.loc[3]

```{.json .output n=None} [ { “data”: { “text/html”: “<div>\n\n<table border="1" class="dataframe">\n <thead>\n <tr style="text-align: right;">\n <th></th>\n <th>city</th>\n <th>lat</th>\n <th>lng</th>\n <th>population</th>\n <th>state</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>3</th>\n <td>Cleveland</td>\n <td>41.473508</td>\n <td>-81.739791</td>\n <td>NaN</td>\n <td>OH</td>\n </tr>\n <tr>\n <th>3</th>\n <td>San Francisco</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>808976.0</td>\n <td>California</td>\n </tr>\n </tbody>\n</table>\n</div>”, “text/plain”: “ city lat lng population state\n3 Cleveland 41.473508 -81.739791 NaN OH\n3 San Francisco NaN NaN 808976.0 California” }, “execution_count”: 143, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


Or you can tell pandas to just ignore the index:

```{.python .input}
pd.concat([city_loc, city_pop], ignore_index=True)

```{.json .output n=None} [ { “data”: { “text/html”: “<div>\n\n<table border="1" class="dataframe">\n <thead>\n <tr style="text-align: right;">\n <th></th>\n <th>city</th>\n <th>lat</th>\n <th>lng</th>\n <th>population</th>\n <th>state</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>San Francisco</td>\n <td>37.781334</td>\n <td>-122.416728</td>\n <td>NaN</td>\n <td>CA</td>\n </tr>\n <tr>\n <th>1</th>\n <td>New York</td>\n <td>40.705649</td>\n <td>-74.008344</td>\n <td>NaN</td>\n <td>NY</td>\n </tr>\n <tr>\n <th>2</th>\n <td>Miami</td>\n <td>25.791100</td>\n <td>-80.320733</td>\n <td>NaN</td>\n <td>FL</td>\n </tr>\n <tr>\n <th>3</th>\n <td>Cleveland</td>\n <td>41.473508</td>\n <td>-81.739791</td>\n <td>NaN</td>\n <td>OH</td>\n </tr>\n <tr>\n <th>4</th>\n <td>Salt Lake City</td>\n <td>40.755851</td>\n <td>-111.896657</td>\n <td>NaN</td>\n <td>UT</td>\n </tr>\n <tr>\n <th>5</th>\n <td>San Francisco</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>808976.0</td>\n <td>California</td>\n </tr>\n <tr>\n <th>6</th>\n <td>New York</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>8363710.0</td>\n <td>New-York</td>\n </tr>\n <tr>\n <th>7</th>\n <td>Miami</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>413201.0</td>\n <td>Florida</td>\n </tr>\n <tr>\n <th>8</th>\n <td>Houston</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>2242193.0</td>\n <td>Texas</td>\n </tr>\n </tbody>\n</table>\n</div>”, “text/plain”: “ city lat lng population state\n0 San Francisco 37.781334 -122.416728 NaN CA\n1 New York 40.705649 -74.008344 NaN NY\n2 Miami 25.791100 -80.320733 NaN FL\n3 Cleveland 41.473508 -81.739791 NaN OH\n4 Salt Lake City 40.755851 -111.896657 NaN UT\n5 San Francisco NaN NaN 808976.0 California\n6 New York NaN NaN 8363710.0 New-York\n7 Miami NaN NaN 413201.0 Florida\n8 Houston NaN NaN 2242193.0 Texas” }, “execution_count”: 144, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


Notice that when a column does not exist in a `DataFrame`, it acts as if it was
filled with `NaN` values. If we set `join="inner"`, then only columns that exist
in *both* `DataFrame`s are returned:

```{.python .input}
pd.concat([city_loc, city_pop], join="inner")

```{.json .output n=None} [ { “data”: { “text/html”: “<div>\n\n<table border="1" class="dataframe">\n <thead>\n <tr style="text-align: right;">\n <th></th>\n <th>state</th>\n <th>city</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>CA</td>\n <td>San Francisco</td>\n </tr>\n <tr>\n <th>1</th>\n <td>NY</td>\n <td>New York</td>\n </tr>\n <tr>\n <th>2</th>\n <td>FL</td>\n <td>Miami</td>\n </tr>\n <tr>\n <th>3</th>\n <td>OH</td>\n <td>Cleveland</td>\n </tr>\n <tr>\n <th>4</th>\n <td>UT</td>\n <td>Salt Lake City</td>\n </tr>\n <tr>\n <th>3</th>\n <td>California</td>\n <td>San Francisco</td>\n </tr>\n <tr>\n <th>4</th>\n <td>New-York</td>\n <td>New York</td>\n </tr>\n <tr>\n <th>5</th>\n <td>Florida</td>\n <td>Miami</td>\n </tr>\n <tr>\n <th>6</th>\n <td>Texas</td>\n <td>Houston</td>\n </tr>\n </tbody>\n</table>\n</div>”, “text/plain”: “ state city\n0 CA San Francisco\n1 NY New York\n2 FL Miami\n3 OH Cleveland\n4 UT Salt Lake City\n3 California San Francisco\n4 New-York New York\n5 Florida Miami\n6 Texas Houston” }, “execution_count”: 145, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


You can concatenate `DataFrame`s horizontally instead of vertically by setting
`axis=1`:

```{.python .input}
pd.concat([city_loc, city_pop], axis=1)

```{.json .output n=None} [ { “data”: { “text/html”: “<div>\n\n<table border="1" class="dataframe">\n <thead>\n <tr style="text-align: right;">\n <th></th>\n <th>state</th>\n <th>city</th>\n <th>lat</th>\n <th>lng</th>\n <th>population</th>\n <th>city</th>\n <th>state</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>CA</td>\n <td>San Francisco</td>\n <td>37.781334</td>\n <td>-122.416728</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n </tr>\n <tr>\n <th>1</th>\n <td>NY</td>\n <td>New York</td>\n <td>40.705649</td>\n <td>-74.008344</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n </tr>\n <tr>\n <th>2</th>\n <td>FL</td>\n <td>Miami</td>\n <td>25.791100</td>\n <td>-80.320733</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n </tr>\n <tr>\n <th>3</th>\n <td>OH</td>\n <td>Cleveland</td>\n <td>41.473508</td>\n <td>-81.739791</td>\n <td>808976.0</td>\n <td>San Francisco</td>\n <td>California</td>\n </tr>\n <tr>\n <th>4</th>\n <td>UT</td>\n <td>Salt Lake City</td>\n <td>40.755851</td>\n <td>-111.896657</td>\n <td>8363710.0</td>\n <td>New York</td>\n <td>New-York</td>\n </tr>\n <tr>\n <th>5</th>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>413201.0</td>\n <td>Miami</td>\n <td>Florida</td>\n </tr>\n <tr>\n <th>6</th>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>2242193.0</td>\n <td>Houston</td>\n <td>Texas</td>\n </tr>\n </tbody>\n</table>\n</div>”, “text/plain”: “ state city lat lng population city \\n0 CA San Francisco 37.781334 -122.416728 NaN NaN \n1 NY New York 40.705649 -74.008344 NaN NaN \n2 FL Miami 25.791100 -80.320733 NaN NaN \n3 OH Cleveland 41.473508 -81.739791 808976.0 San Francisco \n4 UT Salt Lake City 40.755851 -111.896657 8363710.0 New York \n5 NaN NaN NaN NaN 413201.0 Miami \n6 NaN NaN NaN NaN 2242193.0 Houston \n\n state \n0 NaN \n1 NaN \n2 NaN \n3 California \n4 New-York \n5 Florida \n6 Texas “ }, “execution_count”: 146, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


In this case it really does not make much sense because the indices do not align
well (eg. Cleveland and San Francisco end up on the same row, because they
shared the index label `3`). So let's reindex the `DataFrame`s by city name
before concatenating:

```{.python .input}
pd.concat([city_loc.set_index("city"), city_pop.set_index("city")], axis=1)

```{.json .output n=None} [ { “data”: { “text/html”: “<div>\n\n<table border="1" class="dataframe">\n <thead>\n <tr style="text-align: right;">\n <th></th>\n <th>state</th>\n <th>lat</th>\n <th>lng</th>\n <th>population</th>\n <th>state</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>Cleveland</th>\n <td>OH</td>\n <td>41.473508</td>\n <td>-81.739791</td>\n <td>NaN</td>\n <td>NaN</td>\n </tr>\n <tr>\n <th>Houston</th>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>2242193.0</td>\n <td>Texas</td>\n </tr>\n <tr>\n <th>Miami</th>\n <td>FL</td>\n <td>25.791100</td>\n <td>-80.320733</td>\n <td>413201.0</td>\n <td>Florida</td>\n </tr>\n <tr>\n <th>New York</th>\n <td>NY</td>\n <td>40.705649</td>\n <td>-74.008344</td>\n <td>8363710.0</td>\n <td>New-York</td>\n </tr>\n <tr>\n <th>Salt Lake City</th>\n <td>UT</td>\n <td>40.755851</td>\n <td>-111.896657</td>\n <td>NaN</td>\n <td>NaN</td>\n </tr>\n <tr>\n <th>San Francisco</th>\n <td>CA</td>\n <td>37.781334</td>\n <td>-122.416728</td>\n <td>808976.0</td>\n <td>California</td>\n </tr>\n </tbody>\n</table>\n</div>”, “text/plain”: “ state lat lng population state\nCleveland OH 41.473508 -81.739791 NaN NaN\nHouston NaN NaN NaN 2242193.0 Texas\nMiami FL 25.791100 -80.320733 413201.0 Florida\nNew York NY 40.705649 -74.008344 8363710.0 New-York\nSalt Lake City UT 40.755851 -111.896657 NaN NaN\nSan Francisco CA 37.781334 -122.416728 808976.0 California” }, “execution_count”: 147, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


This looks a lot like a `FULL OUTER JOIN`, except that the `state` columns were
not renamed to `state_x` and `state_y`, and the `city` column is now the index.

The `append()` method is a useful shorthand for concatenating `DataFrame`s
vertically:

```{.python .input}
city_loc.append(city_pop)

```{.json .output n=None} [ { “data”: { “text/html”: “<div>\n\n<table border="1" class="dataframe">\n <thead>\n <tr style="text-align: right;">\n <th></th>\n <th>city</th>\n <th>lat</th>\n <th>lng</th>\n <th>population</th>\n <th>state</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>San Francisco</td>\n <td>37.781334</td>\n <td>-122.416728</td>\n <td>NaN</td>\n <td>CA</td>\n </tr>\n <tr>\n <th>1</th>\n <td>New York</td>\n <td>40.705649</td>\n <td>-74.008344</td>\n <td>NaN</td>\n <td>NY</td>\n </tr>\n <tr>\n <th>2</th>\n <td>Miami</td>\n <td>25.791100</td>\n <td>-80.320733</td>\n <td>NaN</td>\n <td>FL</td>\n </tr>\n <tr>\n <th>3</th>\n <td>Cleveland</td>\n <td>41.473508</td>\n <td>-81.739791</td>\n <td>NaN</td>\n <td>OH</td>\n </tr>\n <tr>\n <th>4</th>\n <td>Salt Lake City</td>\n <td>40.755851</td>\n <td>-111.896657</td>\n <td>NaN</td>\n <td>UT</td>\n </tr>\n <tr>\n <th>3</th>\n <td>San Francisco</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>808976.0</td>\n <td>California</td>\n </tr>\n <tr>\n <th>4</th>\n <td>New York</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>8363710.0</td>\n <td>New-York</td>\n </tr>\n <tr>\n <th>5</th>\n <td>Miami</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>413201.0</td>\n <td>Florida</td>\n </tr>\n <tr>\n <th>6</th>\n <td>Houston</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>2242193.0</td>\n <td>Texas</td>\n </tr>\n </tbody>\n</table>\n</div>”, “text/plain”: “ city lat lng population state\n0 San Francisco 37.781334 -122.416728 NaN CA\n1 New York 40.705649 -74.008344 NaN NY\n2 Miami 25.791100 -80.320733 NaN FL\n3 Cleveland 41.473508 -81.739791 NaN OH\n4 Salt Lake City 40.755851 -111.896657 NaN UT\n3 San Francisco NaN NaN 808976.0 California\n4 New York NaN NaN 8363710.0 New-York\n5 Miami NaN NaN 413201.0 Florida\n6 Houston NaN NaN 2242193.0 Texas” }, “execution_count”: 148, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


As always in pandas, the `append()` method does *not* actually modify
`city_loc`: it works on a copy and returns the modified copy.

## Categories
It is quite frequent to have values that represent categories, for example `1`
for female and `2` for male, or `"A"` for Good, `"B"` for Average, `"C"` for
Bad. These categorical values can be hard to read and cumbersome to handle, but
fortunately pandas makes it easy. To illustrate this, let's take the `city_pop`
`DataFrame` we created earlier, and add a column that represents a category:

```{.python .input}
city_eco = city_pop.copy()
city_eco["eco_code"] = [17, 17, 34, 20]
city_eco

```{.json .output n=None} [ { “data”: { “text/html”: “<div>\n\n<table border="1" class="dataframe">\n <thead>\n <tr style="text-align: right;">\n <th></th>\n <th>population</th>\n <th>city</th>\n <th>state</th>\n <th>eco_code</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>3</th>\n <td>808976</td>\n <td>San Francisco</td>\n <td>California</td>\n <td>17</td>\n </tr>\n <tr>\n <th>4</th>\n <td>8363710</td>\n <td>New York</td>\n <td>New-York</td>\n <td>17</td>\n </tr>\n <tr>\n <th>5</th>\n <td>413201</td>\n <td>Miami</td>\n <td>Florida</td>\n <td>34</td>\n </tr>\n <tr>\n <th>6</th>\n <td>2242193</td>\n <td>Houston</td>\n <td>Texas</td>\n <td>20</td>\n </tr>\n </tbody>\n</table>\n</div>”, “text/plain”: “ population city state eco_code\n3 808976 San Francisco California 17\n4 8363710 New York New-York 17\n5 413201 Miami Florida 34\n6 2242193 Houston Texas 20” }, “execution_count”: 149, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


Right now the `eco_code` column is full of apparently meaningless codes. Let's
fix that. First, we will create a new categorical column based on the
`eco_code`s:

```{.python .input}
city_eco["economy"] = city_eco["eco_code"].astype('category')
city_eco["economy"].cat.categories

```{.json .output n=None} [ { “data”: { “text/plain”: “Int64Index([17, 20, 34], dtype=’int64’)” }, “execution_count”: 150, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


Now we can give each category a meaningful name:

```{.python .input}
city_eco["economy"].cat.categories = ["Finance", "Energy", "Tourism"]
city_eco

```{.json .output n=None} [ { “data”: { “text/html”: “<div>\n\n<table border="1" class="dataframe">\n <thead>\n <tr style="text-align: right;">\n <th></th>\n <th>population</th>\n <th>city</th>\n <th>state</th>\n <th>eco_code</th>\n <th>economy</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>3</th>\n <td>808976</td>\n <td>San Francisco</td>\n <td>California</td>\n <td>17</td>\n <td>Finance</td>\n </tr>\n <tr>\n <th>4</th>\n <td>8363710</td>\n <td>New York</td>\n <td>New-York</td>\n <td>17</td>\n <td>Finance</td>\n </tr>\n <tr>\n <th>5</th>\n <td>413201</td>\n <td>Miami</td>\n <td>Florida</td>\n <td>34</td>\n <td>Tourism</td>\n </tr>\n <tr>\n <th>6</th>\n <td>2242193</td>\n <td>Houston</td>\n <td>Texas</td>\n <td>20</td>\n <td>Energy</td>\n </tr>\n </tbody>\n</table>\n</div>”, “text/plain”: “ population city state eco_code economy\n3 808976 San Francisco California 17 Finance\n4 8363710 New York New-York 17 Finance\n5 413201 Miami Florida 34 Tourism\n6 2242193 Houston Texas 20 Energy” }, “execution_count”: 151, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


Note that categorical values are sorted according to their categorical order,
*not* their alphabetical order:

```{.python .input}
city_eco.sort_values(by="economy", ascending=False)

```{.json .output n=None} [ { “data”: { “text/html”: “<div>\n\n<table border="1" class="dataframe">\n <thead>\n <tr style="text-align: right;">\n <th></th>\n <th>population</th>\n <th>city</th>\n <th>state</th>\n <th>eco_code</th>\n <th>economy</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>5</th>\n <td>413201</td>\n <td>Miami</td>\n <td>Florida</td>\n <td>34</td>\n <td>Tourism</td>\n </tr>\n <tr>\n <th>6</th>\n <td>2242193</td>\n <td>Houston</td>\n <td>Texas</td>\n <td>20</td>\n <td>Energy</td>\n </tr>\n <tr>\n <th>4</th>\n <td>8363710</td>\n <td>New York</td>\n <td>New-York</td>\n <td>17</td>\n <td>Finance</td>\n </tr>\n <tr>\n <th>3</th>\n <td>808976</td>\n <td>San Francisco</td>\n <td>California</td>\n <td>17</td>\n <td>Finance</td>\n </tr>\n </tbody>\n</table>\n</div>”, “text/plain”: “ population city state eco_code economy\n5 413201 Miami Florida 34 Tourism\n6 2242193 Houston Texas 20 Energy\n4 8363710 New York New-York 17 Finance\n3 808976 San Francisco California 17 Finance” }, “execution_count”: 152, “metadata”: { “tags”: [] }, “output_type”: “execute_result” } ]


## What next?
As you probably noticed by now, pandas is quite a large library with *many*
features. Although we went through the most important features, there is still a
lot to discover. Probably the best way to learn more is to get your hands dirty
with some real-life data. It is also a good idea to go through pandas' excellent
[documentation](http://pandas.pydata.org/pandas-docs/stable/index.html), in
particular the [Cookbook](http://pandas.pydata.org/pandas-
docs/stable/cookbook.html).

```{.python .input}

Citation

If you found our work useful, please cite it as:

@article{Chadha2020DistilledPandasTutorial,
  title   = {Pandas Tutorial},
  author  = {Chadha, Aman},
  journal = {Distilled AI},
  year    = {2020},
  note    = {\url{https://aman.ai}}
}