{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2020-06-19T10:54:52.429180Z",
     "iopub.status.busy": "2020-06-19T10:54:52.428913Z",
     "iopub.status.idle": "2020-06-19T10:54:52.879358Z",
     "shell.execute_reply": "2020-06-19T10:54:52.878297Z",
     "shell.execute_reply.started": "2020-06-19T10:54:52.429139Z"
    }
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2020-06-19T10:54:53.392619Z",
     "iopub.status.busy": "2020-06-19T10:54:53.392358Z",
     "iopub.status.idle": "2020-06-19T10:54:53.410386Z",
     "shell.execute_reply": "2020-06-19T10:54:53.409417Z",
     "shell.execute_reply.started": "2020-06-19T10:54:53.392578Z"
    }
   },
   "outputs": [],
   "source": [
    "pd_series = pd.Series(np.random.rand(10**6))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2020-06-19T10:54:53.749564Z",
     "iopub.status.busy": "2020-06-19T10:54:53.749305Z",
     "iopub.status.idle": "2020-06-19T10:54:56.841550Z",
     "shell.execute_reply": "2020-06-19T10:54:56.840454Z",
     "shell.execute_reply.started": "2020-06-19T10:54:53.749524Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "3.73 ms ± 149 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n"
     ]
    }
   ],
   "source": [
    "%%timeit\n",
    "pd_series.sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2020-06-19T10:54:56.843462Z",
     "iopub.status.busy": "2020-06-19T10:54:56.843233Z",
     "iopub.status.idle": "2020-06-19T10:54:58.672214Z",
     "shell.execute_reply": "2020-06-19T10:54:58.671294Z",
     "shell.execute_reply.started": "2020-06-19T10:54:56.843424Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "2.21 ms ± 154 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)\n"
     ]
    }
   ],
   "source": [
    "%%timeit\n",
    "np.nansum(pd_series.values)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2020-06-19T10:54:58.673653Z",
     "iopub.status.busy": "2020-06-19T10:54:58.673416Z",
     "iopub.status.idle": "2020-06-19T10:55:02.262894Z",
     "shell.execute_reply": "2020-06-19T10:55:02.262031Z",
     "shell.execute_reply.started": "2020-06-19T10:54:58.673614Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "429 µs ± 51.1 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)\n"
     ]
    }
   ],
   "source": [
    "%%timeit\n",
    "pd_series.sum(skipna=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2020-06-19T10:55:02.264044Z",
     "iopub.status.busy": "2020-06-19T10:55:02.263808Z",
     "iopub.status.idle": "2020-06-19T10:55:05.417113Z",
     "shell.execute_reply": "2020-06-19T10:55:05.416563Z",
     "shell.execute_reply.started": "2020-06-19T10:55:02.264012Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "382 µs ± 42.8 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)\n"
     ]
    }
   ],
   "source": [
    "%%timeit\n",
    "pd_series.values.sum()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {
    "execution": {
     "iopub.execute_input": "2020-06-19T10:55:05.419524Z",
     "iopub.status.busy": "2020-06-19T10:55:05.419341Z",
     "iopub.status.idle": "2020-06-19T10:55:08.424401Z",
     "shell.execute_reply": "2020-06-19T10:55:08.423641Z",
     "shell.execute_reply.started": "2020-06-19T10:55:05.419495Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "361 µs ± 39.6 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)\n"
     ]
    }
   ],
   "source": [
    "%%timeit\n",
    "np.sum(pd_series.values)"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}