{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "___\n", "\n", "\n", "___\n", "
Copyright by Pierian Data Inc.
\n", "
For more information, visit us at www.pieriandata.com
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Conditional Filtering" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Imports" ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": true }, "outputs": [], "source": [ "import numpy as np\n", "import pandas as pd" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": true }, "outputs": [], "source": [ "df = pd.read_csv('tips.csv')" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
total_billtipsexsmokerdaytimesizeprice_per_personPayer NameCC NumberPayment ID
016.991.01FemaleNoSunDinner28.49Christy Cunningham3560325168603410Sun2959
110.341.66MaleNoSunDinner33.45Douglas Tucker4478071379779230Sun4608
221.013.50MaleNoSunDinner37.00Travis Walters6011812112971322Sun4458
323.683.31MaleNoSunDinner211.84Nathaniel Harris4676137647685994Sun5260
424.593.61FemaleNoSunDinner46.15Tonya Carter4832732618637221Sun2251
\n", "
" ], "text/plain": [ " total_bill tip sex smoker day time size price_per_person \\\n", "0 16.99 1.01 Female No Sun Dinner 2 8.49 \n", "1 10.34 1.66 Male No Sun Dinner 3 3.45 \n", "2 21.01 3.50 Male No Sun Dinner 3 7.00 \n", "3 23.68 3.31 Male No Sun Dinner 2 11.84 \n", "4 24.59 3.61 Female No Sun Dinner 4 6.15 \n", "\n", " Payer Name CC Number Payment ID \n", "0 Christy Cunningham 3560325168603410 Sun2959 \n", "1 Douglas Tucker 4478071379779230 Sun4608 \n", "2 Travis Walters 6011812112971322 Sun4458 \n", "3 Nathaniel Harris 4676137647685994 Sun5260 \n", "4 Tonya Carter 4832732618637221 Sun2251 " ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df.head()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Conditions" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "collapsed": true }, "outputs": [], "source": [ "# df['total_bill'] > 30" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": true }, "outputs": [], "source": [ "bool_series = df['total_bill'] > 30" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
total_billtipsexsmokerdaytimesizeprice_per_personPayer NameCC NumberPayment ID
1135.265.00FemaleNoSunDinner48.82Diane Macias4577817359320969Sun6686
2339.427.58MaleNoSatDinner49.86Lance Peterson3542584061609808Sat239
3931.275.00MaleNoSatDinner310.42Mr. Brandon Berry6011525851069856Sat6373
4430.405.60MaleNoSunDinner47.60Todd Cooper503846761263Sun2274
4732.406.00MaleNoSunDinner48.10James Barnes3552002592874186Sun9677
5234.815.20FemaleNoSunDinner48.70Emily Daniel4291280793094374Sun6165
5638.013.00MaleYesSatDinner49.50James Christensen DDS349793629453226Sat8903
5948.276.73MaleNoSatDinner412.07Brian Ortiz6596453823950595Sat8139
8332.685.00MaleYesThurLunch216.34Daniel Murphy5356177501009133Thur8801
8534.835.17FemaleNoThurLunch48.71Shawna Cook6011787464177340Thur7972
9540.174.73MaleYesFriDinner410.04Aaron Bentley180026611638690Fri9628
10244.302.50FemaleYesSatDinner314.77Heather Cohen379771118886604Sat6240
11238.074.00MaleNoSunDinner312.69Jeff Lopez3572865915176463Sun591
14134.306.70MaleNoThurLunch65.72Steven Carlson3526515703718508Thur1025
14241.195.00MaleNoThurLunch58.24Eric Andrews4356531761046453Thur3621
15648.175.00MaleNoSunDinner68.03Ryan Gonzales3523151482063321Sun7518
16731.714.50MaleNoSunDinner47.93Michael Lawson3566285921227119Sun3719
17050.8110.00MaleYesSatDinner316.94Gregory Clark5473850968388236Sat1954
17331.853.18MaleYesSunDinner215.92Scott Perez3577115550328507Sun9335
17532.903.11MaleYesSunDinner216.45Nathan Reynolds370307040837149Sun5109
17934.633.55MaleYesSunDinner217.32Brian Bailey346656312114848Sun9851
18034.653.68MaleYesSunDinner48.66James Hebert DDS676168737648Sun7544
18245.353.50MaleYesSunDinner315.12Jose Parsons4112207559459910Sun2337
18440.553.00MaleYesSunDinner220.27Stephen Cox3547798222044029Sun5140
18730.462.00MaleYesSunDinner56.09David Barrett4792882899700988Sun9987
19743.115.00FemaleYesThurLunch410.78Brooke Soto5544902205760175Thur9313
20738.733.00MaleYesSatDinner49.68Ricky Ramirez347817964484033Sat4505
21030.062.00MaleYesSatDinner310.02Shawn Mendoza30184049218122Sat8361
21248.339.00MaleNoSatDinner412.08Alex Williamson676218815212Sat4590
21930.143.09FemaleYesSatDinner47.54Shelby House502097403252Sat8863
23732.831.17MaleYesSatDinner216.42Thomas Brown4284722681265508Sat2929
23835.834.67FemaleNoSatDinner311.94Kimberly Crane676184013727Sat9777
\n", "
" ], "text/plain": [ " total_bill tip sex smoker day time size price_per_person \\\n", "11 35.26 5.00 Female No Sun Dinner 4 8.82 \n", "23 39.42 7.58 Male No Sat Dinner 4 9.86 \n", "39 31.27 5.00 Male No Sat Dinner 3 10.42 \n", "44 30.40 5.60 Male No Sun Dinner 4 7.60 \n", "47 32.40 6.00 Male No Sun Dinner 4 8.10 \n", "52 34.81 5.20 Female No Sun Dinner 4 8.70 \n", "56 38.01 3.00 Male Yes Sat Dinner 4 9.50 \n", "59 48.27 6.73 Male No Sat Dinner 4 12.07 \n", "83 32.68 5.00 Male Yes Thur Lunch 2 16.34 \n", "85 34.83 5.17 Female No Thur Lunch 4 8.71 \n", "95 40.17 4.73 Male Yes Fri Dinner 4 10.04 \n", "102 44.30 2.50 Female Yes Sat Dinner 3 14.77 \n", "112 38.07 4.00 Male No Sun Dinner 3 12.69 \n", "141 34.30 6.70 Male No Thur Lunch 6 5.72 \n", "142 41.19 5.00 Male No Thur Lunch 5 8.24 \n", "156 48.17 5.00 Male No Sun Dinner 6 8.03 \n", "167 31.71 4.50 Male No Sun Dinner 4 7.93 \n", "170 50.81 10.00 Male Yes Sat Dinner 3 16.94 \n", "173 31.85 3.18 Male Yes Sun Dinner 2 15.92 \n", "175 32.90 3.11 Male Yes Sun Dinner 2 16.45 \n", "179 34.63 3.55 Male Yes Sun Dinner 2 17.32 \n", "180 34.65 3.68 Male Yes Sun Dinner 4 8.66 \n", "182 45.35 3.50 Male Yes Sun Dinner 3 15.12 \n", "184 40.55 3.00 Male Yes Sun Dinner 2 20.27 \n", "187 30.46 2.00 Male Yes Sun Dinner 5 6.09 \n", "197 43.11 5.00 Female Yes Thur Lunch 4 10.78 \n", "207 38.73 3.00 Male Yes Sat Dinner 4 9.68 \n", "210 30.06 2.00 Male Yes Sat Dinner 3 10.02 \n", "212 48.33 9.00 Male No Sat Dinner 4 12.08 \n", "219 30.14 3.09 Female Yes Sat Dinner 4 7.54 \n", "237 32.83 1.17 Male Yes Sat Dinner 2 16.42 \n", "238 35.83 4.67 Female No Sat Dinner 3 11.94 \n", "\n", " Payer Name CC Number Payment ID \n", "11 Diane Macias 4577817359320969 Sun6686 \n", "23 Lance Peterson 3542584061609808 Sat239 \n", "39 Mr. Brandon Berry 6011525851069856 Sat6373 \n", "44 Todd Cooper 503846761263 Sun2274 \n", "47 James Barnes 3552002592874186 Sun9677 \n", "52 Emily Daniel 4291280793094374 Sun6165 \n", "56 James Christensen DDS 349793629453226 Sat8903 \n", "59 Brian Ortiz 6596453823950595 Sat8139 \n", "83 Daniel Murphy 5356177501009133 Thur8801 \n", "85 Shawna Cook 6011787464177340 Thur7972 \n", "95 Aaron Bentley 180026611638690 Fri9628 \n", "102 Heather Cohen 379771118886604 Sat6240 \n", "112 Jeff Lopez 3572865915176463 Sun591 \n", "141 Steven Carlson 3526515703718508 Thur1025 \n", "142 Eric Andrews 4356531761046453 Thur3621 \n", "156 Ryan Gonzales 3523151482063321 Sun7518 \n", "167 Michael Lawson 3566285921227119 Sun3719 \n", "170 Gregory Clark 5473850968388236 Sat1954 \n", "173 Scott Perez 3577115550328507 Sun9335 \n", "175 Nathan Reynolds 370307040837149 Sun5109 \n", "179 Brian Bailey 346656312114848 Sun9851 \n", "180 James Hebert DDS 676168737648 Sun7544 \n", "182 Jose Parsons 4112207559459910 Sun2337 \n", "184 Stephen Cox 3547798222044029 Sun5140 \n", "187 David Barrett 4792882899700988 Sun9987 \n", "197 Brooke Soto 5544902205760175 Thur9313 \n", "207 Ricky Ramirez 347817964484033 Sat4505 \n", "210 Shawn Mendoza 30184049218122 Sat8361 \n", "212 Alex Williamson 676218815212 Sat4590 \n", "219 Shelby House 502097403252 Sat8863 \n", "237 Thomas Brown 4284722681265508 Sat2929 \n", "238 Kimberly Crane 676184013727 Sat9777 " ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df[bool_series]" ] }, { "cell_type": "code", "execution_count": 13, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
total_billtipsexsmokerdaytimesizeprice_per_personPayer NameCC NumberPayment ID
1135.265.00FemaleNoSunDinner48.82Diane Macias4577817359320969Sun6686
2339.427.58MaleNoSatDinner49.86Lance Peterson3542584061609808Sat239
3931.275.00MaleNoSatDinner310.42Mr. Brandon Berry6011525851069856Sat6373
4430.405.60MaleNoSunDinner47.60Todd Cooper503846761263Sun2274
4732.406.00MaleNoSunDinner48.10James Barnes3552002592874186Sun9677
5234.815.20FemaleNoSunDinner48.70Emily Daniel4291280793094374Sun6165
5638.013.00MaleYesSatDinner49.50James Christensen DDS349793629453226Sat8903
5948.276.73MaleNoSatDinner412.07Brian Ortiz6596453823950595Sat8139
8332.685.00MaleYesThurLunch216.34Daniel Murphy5356177501009133Thur8801
8534.835.17FemaleNoThurLunch48.71Shawna Cook6011787464177340Thur7972
9540.174.73MaleYesFriDinner410.04Aaron Bentley180026611638690Fri9628
10244.302.50FemaleYesSatDinner314.77Heather Cohen379771118886604Sat6240
11238.074.00MaleNoSunDinner312.69Jeff Lopez3572865915176463Sun591
14134.306.70MaleNoThurLunch65.72Steven Carlson3526515703718508Thur1025
14241.195.00MaleNoThurLunch58.24Eric Andrews4356531761046453Thur3621
15648.175.00MaleNoSunDinner68.03Ryan Gonzales3523151482063321Sun7518
16731.714.50MaleNoSunDinner47.93Michael Lawson3566285921227119Sun3719
17050.8110.00MaleYesSatDinner316.94Gregory Clark5473850968388236Sat1954
17331.853.18MaleYesSunDinner215.92Scott Perez3577115550328507Sun9335
17532.903.11MaleYesSunDinner216.45Nathan Reynolds370307040837149Sun5109
17934.633.55MaleYesSunDinner217.32Brian Bailey346656312114848Sun9851
18034.653.68MaleYesSunDinner48.66James Hebert DDS676168737648Sun7544
18245.353.50MaleYesSunDinner315.12Jose Parsons4112207559459910Sun2337
18440.553.00MaleYesSunDinner220.27Stephen Cox3547798222044029Sun5140
18730.462.00MaleYesSunDinner56.09David Barrett4792882899700988Sun9987
19743.115.00FemaleYesThurLunch410.78Brooke Soto5544902205760175Thur9313
20738.733.00MaleYesSatDinner49.68Ricky Ramirez347817964484033Sat4505
21030.062.00MaleYesSatDinner310.02Shawn Mendoza30184049218122Sat8361
21248.339.00MaleNoSatDinner412.08Alex Williamson676218815212Sat4590
21930.143.09FemaleYesSatDinner47.54Shelby House502097403252Sat8863
23732.831.17MaleYesSatDinner216.42Thomas Brown4284722681265508Sat2929
23835.834.67FemaleNoSatDinner311.94Kimberly Crane676184013727Sat9777
\n", "
" ], "text/plain": [ " total_bill tip sex smoker day time size price_per_person \\\n", "11 35.26 5.00 Female No Sun Dinner 4 8.82 \n", "23 39.42 7.58 Male No Sat Dinner 4 9.86 \n", "39 31.27 5.00 Male No Sat Dinner 3 10.42 \n", "44 30.40 5.60 Male No Sun Dinner 4 7.60 \n", "47 32.40 6.00 Male No Sun Dinner 4 8.10 \n", "52 34.81 5.20 Female No Sun Dinner 4 8.70 \n", "56 38.01 3.00 Male Yes Sat Dinner 4 9.50 \n", "59 48.27 6.73 Male No Sat Dinner 4 12.07 \n", "83 32.68 5.00 Male Yes Thur Lunch 2 16.34 \n", "85 34.83 5.17 Female No Thur Lunch 4 8.71 \n", "95 40.17 4.73 Male Yes Fri Dinner 4 10.04 \n", "102 44.30 2.50 Female Yes Sat Dinner 3 14.77 \n", "112 38.07 4.00 Male No Sun Dinner 3 12.69 \n", "141 34.30 6.70 Male No Thur Lunch 6 5.72 \n", "142 41.19 5.00 Male No Thur Lunch 5 8.24 \n", "156 48.17 5.00 Male No Sun Dinner 6 8.03 \n", "167 31.71 4.50 Male No Sun Dinner 4 7.93 \n", "170 50.81 10.00 Male Yes Sat Dinner 3 16.94 \n", "173 31.85 3.18 Male Yes Sun Dinner 2 15.92 \n", "175 32.90 3.11 Male Yes Sun Dinner 2 16.45 \n", "179 34.63 3.55 Male Yes Sun Dinner 2 17.32 \n", "180 34.65 3.68 Male Yes Sun Dinner 4 8.66 \n", "182 45.35 3.50 Male Yes Sun Dinner 3 15.12 \n", "184 40.55 3.00 Male Yes Sun Dinner 2 20.27 \n", "187 30.46 2.00 Male Yes Sun Dinner 5 6.09 \n", "197 43.11 5.00 Female Yes Thur Lunch 4 10.78 \n", "207 38.73 3.00 Male Yes Sat Dinner 4 9.68 \n", "210 30.06 2.00 Male Yes Sat Dinner 3 10.02 \n", "212 48.33 9.00 Male No Sat Dinner 4 12.08 \n", "219 30.14 3.09 Female Yes Sat Dinner 4 7.54 \n", "237 32.83 1.17 Male Yes Sat Dinner 2 16.42 \n", "238 35.83 4.67 Female No Sat Dinner 3 11.94 \n", "\n", " Payer Name CC Number Payment ID \n", "11 Diane Macias 4577817359320969 Sun6686 \n", "23 Lance Peterson 3542584061609808 Sat239 \n", "39 Mr. Brandon Berry 6011525851069856 Sat6373 \n", "44 Todd Cooper 503846761263 Sun2274 \n", "47 James Barnes 3552002592874186 Sun9677 \n", "52 Emily Daniel 4291280793094374 Sun6165 \n", "56 James Christensen DDS 349793629453226 Sat8903 \n", "59 Brian Ortiz 6596453823950595 Sat8139 \n", "83 Daniel Murphy 5356177501009133 Thur8801 \n", "85 Shawna Cook 6011787464177340 Thur7972 \n", "95 Aaron Bentley 180026611638690 Fri9628 \n", "102 Heather Cohen 379771118886604 Sat6240 \n", "112 Jeff Lopez 3572865915176463 Sun591 \n", "141 Steven Carlson 3526515703718508 Thur1025 \n", "142 Eric Andrews 4356531761046453 Thur3621 \n", "156 Ryan Gonzales 3523151482063321 Sun7518 \n", "167 Michael Lawson 3566285921227119 Sun3719 \n", "170 Gregory Clark 5473850968388236 Sat1954 \n", "173 Scott Perez 3577115550328507 Sun9335 \n", "175 Nathan Reynolds 370307040837149 Sun5109 \n", "179 Brian Bailey 346656312114848 Sun9851 \n", "180 James Hebert DDS 676168737648 Sun7544 \n", "182 Jose Parsons 4112207559459910 Sun2337 \n", "184 Stephen Cox 3547798222044029 Sun5140 \n", "187 David Barrett 4792882899700988 Sun9987 \n", "197 Brooke Soto 5544902205760175 Thur9313 \n", "207 Ricky Ramirez 347817964484033 Sat4505 \n", "210 Shawn Mendoza 30184049218122 Sat8361 \n", "212 Alex Williamson 676218815212 Sat4590 \n", "219 Shelby House 502097403252 Sat8863 \n", "237 Thomas Brown 4284722681265508 Sat2929 \n", "238 Kimberly Crane 676184013727 Sat9777 " ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df[df['total_bill']>30]" ] }, { "cell_type": "code", "execution_count": 14, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
total_billtipsexsmokerdaytimesizeprice_per_personPayer NameCC NumberPayment ID
110.341.66MaleNoSunDinner33.45Douglas Tucker4478071379779230Sun4608
221.013.50MaleNoSunDinner37.00Travis Walters6011812112971322Sun4458
323.683.31MaleNoSunDinner211.84Nathaniel Harris4676137647685994Sun5260
525.294.71MaleNoSunDinner46.32Erik Smith213140353657882Sun9679
68.772.00MaleNoSunDinner24.38Kristopher Johnson2223727524230344Sun5985
726.883.12MaleNoSunDinner46.72Robert Buck3514785077705092Sun8157
815.041.96MaleNoSunDinner27.52Joseph Mcdonald3522866365840377Sun6820
914.783.23MaleNoSunDinner27.39Jerome Abbott3532124519049786Sun3775
1010.271.71MaleNoSunDinner25.14William Riley566287581219Sun2546
1215.421.57MaleNoSunDinner27.71Chad Harrington577040572932Sun1300
1318.433.00MaleNoSunDinner44.61Joshua Jones6011163105616890Sun2971
1521.583.92MaleNoSunDinner210.79Matthew Reilly180073029785069Sun1878
1716.293.71MaleNoSunDinner35.43John Pittman6521340257218708Sun2998
1920.653.35MaleNoSatDinner36.88Timothy Oneal6568069240986485Sat9213
2017.924.08MaleNoSatDinner28.96Thomas Rice4403296224639756Sat1709
2339.427.58MaleNoSatDinner49.86Lance Peterson3542584061609808Sat239
2419.823.18MaleNoSatDinner29.91Christopher Ross36739148167928Sat6236
2517.812.34MaleNoSatDinner44.45Robert Perkins30502930499388Sat907
2613.372.00MaleNoSatDinner26.68Kyle Avery6531339539615499Sat6651
2712.692.00MaleNoSatDinner26.34Patrick Barber30155551880343Sat394
2821.704.30MaleNoSatDinner210.85David Collier5529694315416009Sat3697
309.551.45MaleNoSatDinner24.78Grant Hall30196517521548Sat4099
3118.352.50MaleNoSatDinner44.59Danny Santiago630415546013Sat4947
3417.783.27MaleNoSatDinner28.89Jacob Castillo3551492000704805Sat8124
3524.063.60MaleNoSatDinner38.02Joseph Mullins5519770449260299Sat632
3616.312.00MaleNoSatDinner35.44William Ford3527691170179398Sat9139
3818.692.31MaleNoSatDinner36.23Brandon Bradley4427601595688633Sat4056
3931.275.00MaleNoSatDinner310.42Mr. Brandon Berry6011525851069856Sat6373
4016.042.24MaleNoSatDinner35.35Adam Edwards3544447755679420Sat8549
4117.462.54MaleNoSunDinner28.73David Boyer3536678244278149Sun9460
....................................
1957.561.44MaleNoThurLunch23.78Michael White4865390263095532Thur697
19610.342.00MaleYesThurLunch25.17Eric Martin30442491190342Thur9862
19913.512.00MaleYesThurLunch26.76Joseph Murphy MD6547218923471275Thur2428
20018.714.00MaleYesThurLunch36.24Jason Conrad4581233003487Thur6048
20420.534.00MaleYesThurLunch45.13Scott Kim3570611756827620Thur2160
20626.593.41MaleYesSatDinner38.86Daniel Owens38971087967574Sat1
20738.733.00MaleYesSatDinner49.68Ricky Ramirez347817964484033Sat4505
20824.272.03MaleYesSatDinner212.14Jason Carter4268942915626180Sat6048
21030.062.00MaleYesSatDinner310.02Shawn Mendoza30184049218122Sat8361
21125.895.16MaleYesSatDinner46.47Christopher Li6011962464150569Sat6735
21248.339.00MaleNoSatDinner412.08Alex Williamson676218815212Sat4590
21628.153.00MaleYesSatDinner55.63Shawn Barnett PhD4590982568244Sat7320
21711.591.50MaleYesSatDinner25.80Gary Orr30324521283406Sat8489
2187.741.44MaleYesSatDinner23.87Nicholas Archer340517153733524Sat4772
22012.162.20MaleYesFriLunch26.08Ricky Johnson213109508670736Fri4607
2228.581.92MaleYesFriLunch18.58Jason Lawrence3505302934650403Fri6624
22413.421.58MaleYesFriLunch26.71Ronald Vaughn DVM341503466406403Fri5959
22720.453.00MaleNoSatDinner45.11Robert Bradley213141668145910Sat4319
22813.282.72MaleNoSatDinner26.64Glenn Jones502061651712Sat2937
23024.012.00MaleYesSatDinner46.00Michael Osborne4258682154026Sat7872
23115.693.00MaleYesSatDinner35.23Jason Parks4812333796161Sat6334
23211.613.39MaleNoSatDinner25.80James Taylor6011482917327995Sat2124
23310.771.47MaleNoSatDinner25.38Paul Novak6011698897610858Sat1467
23415.533.00MaleYesSatDinner27.76Tracy Douglas4097938155941930Sat7220
23510.071.25MaleNoSatDinner25.04Sean Gonzalez3534021246117605Sat4615
23612.601.00MaleYesSatDinner26.30Matthew Myers3543676378973965Sat5032
23732.831.17MaleYesSatDinner216.42Thomas Brown4284722681265508Sat2929
23929.035.92MaleNoSatDinner39.68Michael Avila5296068606052842Sat2657
24122.672.00MaleYesSatDinner211.34Keith Wong6011891618747196Sat3880
24217.821.75MaleNoSatDinner28.91Dennis Dixon4375220550950Sat17
\n", "

157 rows × 11 columns

\n", "
" ], "text/plain": [ " total_bill tip sex smoker day time size price_per_person \\\n", "1 10.34 1.66 Male No Sun Dinner 3 3.45 \n", "2 21.01 3.50 Male No Sun Dinner 3 7.00 \n", "3 23.68 3.31 Male No Sun Dinner 2 11.84 \n", "5 25.29 4.71 Male No Sun Dinner 4 6.32 \n", "6 8.77 2.00 Male No Sun Dinner 2 4.38 \n", "7 26.88 3.12 Male No Sun Dinner 4 6.72 \n", "8 15.04 1.96 Male No Sun Dinner 2 7.52 \n", "9 14.78 3.23 Male No Sun Dinner 2 7.39 \n", "10 10.27 1.71 Male No Sun Dinner 2 5.14 \n", "12 15.42 1.57 Male No Sun Dinner 2 7.71 \n", "13 18.43 3.00 Male No Sun Dinner 4 4.61 \n", "15 21.58 3.92 Male No Sun Dinner 2 10.79 \n", "17 16.29 3.71 Male No Sun Dinner 3 5.43 \n", "19 20.65 3.35 Male No Sat Dinner 3 6.88 \n", "20 17.92 4.08 Male No Sat Dinner 2 8.96 \n", "23 39.42 7.58 Male No Sat Dinner 4 9.86 \n", "24 19.82 3.18 Male No Sat Dinner 2 9.91 \n", "25 17.81 2.34 Male No Sat Dinner 4 4.45 \n", "26 13.37 2.00 Male No Sat Dinner 2 6.68 \n", "27 12.69 2.00 Male No Sat Dinner 2 6.34 \n", "28 21.70 4.30 Male No Sat Dinner 2 10.85 \n", "30 9.55 1.45 Male No Sat Dinner 2 4.78 \n", "31 18.35 2.50 Male No Sat Dinner 4 4.59 \n", "34 17.78 3.27 Male No Sat Dinner 2 8.89 \n", "35 24.06 3.60 Male No Sat Dinner 3 8.02 \n", "36 16.31 2.00 Male No Sat Dinner 3 5.44 \n", "38 18.69 2.31 Male No Sat Dinner 3 6.23 \n", "39 31.27 5.00 Male No Sat Dinner 3 10.42 \n", "40 16.04 2.24 Male No Sat Dinner 3 5.35 \n", "41 17.46 2.54 Male No Sun Dinner 2 8.73 \n", ".. ... ... ... ... ... ... ... ... \n", "195 7.56 1.44 Male No Thur Lunch 2 3.78 \n", "196 10.34 2.00 Male Yes Thur Lunch 2 5.17 \n", "199 13.51 2.00 Male Yes Thur Lunch 2 6.76 \n", "200 18.71 4.00 Male Yes Thur Lunch 3 6.24 \n", "204 20.53 4.00 Male Yes Thur Lunch 4 5.13 \n", "206 26.59 3.41 Male Yes Sat Dinner 3 8.86 \n", "207 38.73 3.00 Male Yes Sat Dinner 4 9.68 \n", "208 24.27 2.03 Male Yes Sat Dinner 2 12.14 \n", "210 30.06 2.00 Male Yes Sat Dinner 3 10.02 \n", "211 25.89 5.16 Male Yes Sat Dinner 4 6.47 \n", "212 48.33 9.00 Male No Sat Dinner 4 12.08 \n", "216 28.15 3.00 Male Yes Sat Dinner 5 5.63 \n", "217 11.59 1.50 Male Yes Sat Dinner 2 5.80 \n", "218 7.74 1.44 Male Yes Sat Dinner 2 3.87 \n", "220 12.16 2.20 Male Yes Fri Lunch 2 6.08 \n", "222 8.58 1.92 Male Yes Fri Lunch 1 8.58 \n", "224 13.42 1.58 Male Yes Fri Lunch 2 6.71 \n", "227 20.45 3.00 Male No Sat Dinner 4 5.11 \n", "228 13.28 2.72 Male No Sat Dinner 2 6.64 \n", "230 24.01 2.00 Male Yes Sat Dinner 4 6.00 \n", "231 15.69 3.00 Male Yes Sat Dinner 3 5.23 \n", "232 11.61 3.39 Male No Sat Dinner 2 5.80 \n", "233 10.77 1.47 Male No Sat Dinner 2 5.38 \n", "234 15.53 3.00 Male Yes Sat Dinner 2 7.76 \n", "235 10.07 1.25 Male No Sat Dinner 2 5.04 \n", "236 12.60 1.00 Male Yes Sat Dinner 2 6.30 \n", "237 32.83 1.17 Male Yes Sat Dinner 2 16.42 \n", "239 29.03 5.92 Male No Sat Dinner 3 9.68 \n", "241 22.67 2.00 Male Yes Sat Dinner 2 11.34 \n", "242 17.82 1.75 Male No Sat Dinner 2 8.91 \n", "\n", " Payer Name CC Number Payment ID \n", "1 Douglas Tucker 4478071379779230 Sun4608 \n", "2 Travis Walters 6011812112971322 Sun4458 \n", "3 Nathaniel Harris 4676137647685994 Sun5260 \n", "5 Erik Smith 213140353657882 Sun9679 \n", "6 Kristopher Johnson 2223727524230344 Sun5985 \n", "7 Robert Buck 3514785077705092 Sun8157 \n", "8 Joseph Mcdonald 3522866365840377 Sun6820 \n", "9 Jerome Abbott 3532124519049786 Sun3775 \n", "10 William Riley 566287581219 Sun2546 \n", "12 Chad Harrington 577040572932 Sun1300 \n", "13 Joshua Jones 6011163105616890 Sun2971 \n", "15 Matthew Reilly 180073029785069 Sun1878 \n", "17 John Pittman 6521340257218708 Sun2998 \n", "19 Timothy Oneal 6568069240986485 Sat9213 \n", "20 Thomas Rice 4403296224639756 Sat1709 \n", "23 Lance Peterson 3542584061609808 Sat239 \n", "24 Christopher Ross 36739148167928 Sat6236 \n", "25 Robert Perkins 30502930499388 Sat907 \n", "26 Kyle Avery 6531339539615499 Sat6651 \n", "27 Patrick Barber 30155551880343 Sat394 \n", "28 David Collier 5529694315416009 Sat3697 \n", "30 Grant Hall 30196517521548 Sat4099 \n", "31 Danny Santiago 630415546013 Sat4947 \n", "34 Jacob Castillo 3551492000704805 Sat8124 \n", "35 Joseph Mullins 5519770449260299 Sat632 \n", "36 William Ford 3527691170179398 Sat9139 \n", "38 Brandon Bradley 4427601595688633 Sat4056 \n", "39 Mr. Brandon Berry 6011525851069856 Sat6373 \n", "40 Adam Edwards 3544447755679420 Sat8549 \n", "41 David Boyer 3536678244278149 Sun9460 \n", ".. ... ... ... \n", "195 Michael White 4865390263095532 Thur697 \n", "196 Eric Martin 30442491190342 Thur9862 \n", "199 Joseph Murphy MD 6547218923471275 Thur2428 \n", "200 Jason Conrad 4581233003487 Thur6048 \n", "204 Scott Kim 3570611756827620 Thur2160 \n", "206 Daniel Owens 38971087967574 Sat1 \n", "207 Ricky Ramirez 347817964484033 Sat4505 \n", "208 Jason Carter 4268942915626180 Sat6048 \n", "210 Shawn Mendoza 30184049218122 Sat8361 \n", "211 Christopher Li 6011962464150569 Sat6735 \n", "212 Alex Williamson 676218815212 Sat4590 \n", "216 Shawn Barnett PhD 4590982568244 Sat7320 \n", "217 Gary Orr 30324521283406 Sat8489 \n", "218 Nicholas Archer 340517153733524 Sat4772 \n", "220 Ricky Johnson 213109508670736 Fri4607 \n", "222 Jason Lawrence 3505302934650403 Fri6624 \n", "224 Ronald Vaughn DVM 341503466406403 Fri5959 \n", "227 Robert Bradley 213141668145910 Sat4319 \n", "228 Glenn Jones 502061651712 Sat2937 \n", "230 Michael Osborne 4258682154026 Sat7872 \n", "231 Jason Parks 4812333796161 Sat6334 \n", "232 James Taylor 6011482917327995 Sat2124 \n", "233 Paul Novak 6011698897610858 Sat1467 \n", "234 Tracy Douglas 4097938155941930 Sat7220 \n", "235 Sean Gonzalez 3534021246117605 Sat4615 \n", "236 Matthew Myers 3543676378973965 Sat5032 \n", "237 Thomas Brown 4284722681265508 Sat2929 \n", "239 Michael Avila 5296068606052842 Sat2657 \n", "241 Keith Wong 6011891618747196 Sat3880 \n", "242 Dennis Dixon 4375220550950 Sat17 \n", "\n", "[157 rows x 11 columns]" ] }, "execution_count": 14, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df[df['sex'] == 'Male']" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Multiple Conditions\n", "\n", "Recall the steps:\n", "\n", "* Get the conditions\n", "* Wrap each condition in parenthesis\n", "* Use the | or & operator, depending if you want an \n", " * OR | (either condition is True)\n", " * AND & (both conditions must be True)\n", "* You can also use the ~ operator as a NOT operation" ] }, { "cell_type": "code", "execution_count": 33, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
total_billtipsexsmokerdaytimesizeprice_per_personPayer NameCC NumberPayment ID
2339.427.58MaleNoSatDinner49.86Lance Peterson3542584061609808Sat239
3931.275.00MaleNoSatDinner310.42Mr. Brandon Berry6011525851069856Sat6373
4430.405.60MaleNoSunDinner47.60Todd Cooper503846761263Sun2274
4732.406.00MaleNoSunDinner48.10James Barnes3552002592874186Sun9677
5638.013.00MaleYesSatDinner49.50James Christensen DDS349793629453226Sat8903
5948.276.73MaleNoSatDinner412.07Brian Ortiz6596453823950595Sat8139
8332.685.00MaleYesThurLunch216.34Daniel Murphy5356177501009133Thur8801
9540.174.73MaleYesFriDinner410.04Aaron Bentley180026611638690Fri9628
11238.074.00MaleNoSunDinner312.69Jeff Lopez3572865915176463Sun591
14134.306.70MaleNoThurLunch65.72Steven Carlson3526515703718508Thur1025
14241.195.00MaleNoThurLunch58.24Eric Andrews4356531761046453Thur3621
15648.175.00MaleNoSunDinner68.03Ryan Gonzales3523151482063321Sun7518
16731.714.50MaleNoSunDinner47.93Michael Lawson3566285921227119Sun3719
17050.8110.00MaleYesSatDinner316.94Gregory Clark5473850968388236Sat1954
17331.853.18MaleYesSunDinner215.92Scott Perez3577115550328507Sun9335
17532.903.11MaleYesSunDinner216.45Nathan Reynolds370307040837149Sun5109
17934.633.55MaleYesSunDinner217.32Brian Bailey346656312114848Sun9851
18034.653.68MaleYesSunDinner48.66James Hebert DDS676168737648Sun7544
18245.353.50MaleYesSunDinner315.12Jose Parsons4112207559459910Sun2337
18440.553.00MaleYesSunDinner220.27Stephen Cox3547798222044029Sun5140
18730.462.00MaleYesSunDinner56.09David Barrett4792882899700988Sun9987
20738.733.00MaleYesSatDinner49.68Ricky Ramirez347817964484033Sat4505
21030.062.00MaleYesSatDinner310.02Shawn Mendoza30184049218122Sat8361
21248.339.00MaleNoSatDinner412.08Alex Williamson676218815212Sat4590
23732.831.17MaleYesSatDinner216.42Thomas Brown4284722681265508Sat2929
\n", "
" ], "text/plain": [ " total_bill tip sex smoker day time size price_per_person \\\n", "23 39.42 7.58 Male No Sat Dinner 4 9.86 \n", "39 31.27 5.00 Male No Sat Dinner 3 10.42 \n", "44 30.40 5.60 Male No Sun Dinner 4 7.60 \n", "47 32.40 6.00 Male No Sun Dinner 4 8.10 \n", "56 38.01 3.00 Male Yes Sat Dinner 4 9.50 \n", "59 48.27 6.73 Male No Sat Dinner 4 12.07 \n", "83 32.68 5.00 Male Yes Thur Lunch 2 16.34 \n", "95 40.17 4.73 Male Yes Fri Dinner 4 10.04 \n", "112 38.07 4.00 Male No Sun Dinner 3 12.69 \n", "141 34.30 6.70 Male No Thur Lunch 6 5.72 \n", "142 41.19 5.00 Male No Thur Lunch 5 8.24 \n", "156 48.17 5.00 Male No Sun Dinner 6 8.03 \n", "167 31.71 4.50 Male No Sun Dinner 4 7.93 \n", "170 50.81 10.00 Male Yes Sat Dinner 3 16.94 \n", "173 31.85 3.18 Male Yes Sun Dinner 2 15.92 \n", "175 32.90 3.11 Male Yes Sun Dinner 2 16.45 \n", "179 34.63 3.55 Male Yes Sun Dinner 2 17.32 \n", "180 34.65 3.68 Male Yes Sun Dinner 4 8.66 \n", "182 45.35 3.50 Male Yes Sun Dinner 3 15.12 \n", "184 40.55 3.00 Male Yes Sun Dinner 2 20.27 \n", "187 30.46 2.00 Male Yes Sun Dinner 5 6.09 \n", "207 38.73 3.00 Male Yes Sat Dinner 4 9.68 \n", "210 30.06 2.00 Male Yes Sat Dinner 3 10.02 \n", "212 48.33 9.00 Male No Sat Dinner 4 12.08 \n", "237 32.83 1.17 Male Yes Sat Dinner 2 16.42 \n", "\n", " Payer Name CC Number Payment ID \n", "23 Lance Peterson 3542584061609808 Sat239 \n", "39 Mr. Brandon Berry 6011525851069856 Sat6373 \n", "44 Todd Cooper 503846761263 Sun2274 \n", "47 James Barnes 3552002592874186 Sun9677 \n", "56 James Christensen DDS 349793629453226 Sat8903 \n", "59 Brian Ortiz 6596453823950595 Sat8139 \n", "83 Daniel Murphy 5356177501009133 Thur8801 \n", "95 Aaron Bentley 180026611638690 Fri9628 \n", "112 Jeff Lopez 3572865915176463 Sun591 \n", "141 Steven Carlson 3526515703718508 Thur1025 \n", "142 Eric Andrews 4356531761046453 Thur3621 \n", "156 Ryan Gonzales 3523151482063321 Sun7518 \n", "167 Michael Lawson 3566285921227119 Sun3719 \n", "170 Gregory Clark 5473850968388236 Sat1954 \n", "173 Scott Perez 3577115550328507 Sun9335 \n", "175 Nathan Reynolds 370307040837149 Sun5109 \n", "179 Brian Bailey 346656312114848 Sun9851 \n", "180 James Hebert DDS 676168737648 Sun7544 \n", "182 Jose Parsons 4112207559459910 Sun2337 \n", "184 Stephen Cox 3547798222044029 Sun5140 \n", "187 David Barrett 4792882899700988 Sun9987 \n", "207 Ricky Ramirez 347817964484033 Sat4505 \n", "210 Shawn Mendoza 30184049218122 Sat8361 \n", "212 Alex Williamson 676218815212 Sat4590 \n", "237 Thomas Brown 4284722681265508 Sat2929 " ] }, "execution_count": 33, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df[(df['total_bill'] > 30) & (df['sex']=='Male')]" ] }, { "cell_type": "code", "execution_count": 34, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
total_billtipsexsmokerdaytimesizeprice_per_personPayer NameCC NumberPayment ID
1135.265.00FemaleNoSunDinner48.82Diane Macias4577817359320969Sun6686
5234.815.20FemaleNoSunDinner48.70Emily Daniel4291280793094374Sun6165
8534.835.17FemaleNoThurLunch48.71Shawna Cook6011787464177340Thur7972
10244.302.50FemaleYesSatDinner314.77Heather Cohen379771118886604Sat6240
19743.115.00FemaleYesThurLunch410.78Brooke Soto5544902205760175Thur9313
21930.143.09FemaleYesSatDinner47.54Shelby House502097403252Sat8863
23835.834.67FemaleNoSatDinner311.94Kimberly Crane676184013727Sat9777
\n", "
" ], "text/plain": [ " total_bill tip sex smoker day time size price_per_person \\\n", "11 35.26 5.00 Female No Sun Dinner 4 8.82 \n", "52 34.81 5.20 Female No Sun Dinner 4 8.70 \n", "85 34.83 5.17 Female No Thur Lunch 4 8.71 \n", "102 44.30 2.50 Female Yes Sat Dinner 3 14.77 \n", "197 43.11 5.00 Female Yes Thur Lunch 4 10.78 \n", "219 30.14 3.09 Female Yes Sat Dinner 4 7.54 \n", "238 35.83 4.67 Female No Sat Dinner 3 11.94 \n", "\n", " Payer Name CC Number Payment ID \n", "11 Diane Macias 4577817359320969 Sun6686 \n", "52 Emily Daniel 4291280793094374 Sun6165 \n", "85 Shawna Cook 6011787464177340 Thur7972 \n", "102 Heather Cohen 379771118886604 Sat6240 \n", "197 Brooke Soto 5544902205760175 Thur9313 \n", "219 Shelby House 502097403252 Sat8863 \n", "238 Kimberly Crane 676184013727 Sat9777 " ] }, "execution_count": 34, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df[(df['total_bill'] > 30) & ~(df['sex']=='Male')]" ] }, { "cell_type": "code", "execution_count": 35, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
total_billtipsexsmokerdaytimesizeprice_per_personPayer NameCC NumberPayment ID
1135.265.00FemaleNoSunDinner48.82Diane Macias4577817359320969Sun6686
5234.815.20FemaleNoSunDinner48.70Emily Daniel4291280793094374Sun6165
8534.835.17FemaleNoThurLunch48.71Shawna Cook6011787464177340Thur7972
10244.302.50FemaleYesSatDinner314.77Heather Cohen379771118886604Sat6240
19743.115.00FemaleYesThurLunch410.78Brooke Soto5544902205760175Thur9313
21930.143.09FemaleYesSatDinner47.54Shelby House502097403252Sat8863
23835.834.67FemaleNoSatDinner311.94Kimberly Crane676184013727Sat9777
\n", "
" ], "text/plain": [ " total_bill tip sex smoker day time size price_per_person \\\n", "11 35.26 5.00 Female No Sun Dinner 4 8.82 \n", "52 34.81 5.20 Female No Sun Dinner 4 8.70 \n", "85 34.83 5.17 Female No Thur Lunch 4 8.71 \n", "102 44.30 2.50 Female Yes Sat Dinner 3 14.77 \n", "197 43.11 5.00 Female Yes Thur Lunch 4 10.78 \n", "219 30.14 3.09 Female Yes Sat Dinner 4 7.54 \n", "238 35.83 4.67 Female No Sat Dinner 3 11.94 \n", "\n", " Payer Name CC Number Payment ID \n", "11 Diane Macias 4577817359320969 Sun6686 \n", "52 Emily Daniel 4291280793094374 Sun6165 \n", "85 Shawna Cook 6011787464177340 Thur7972 \n", "102 Heather Cohen 379771118886604 Sat6240 \n", "197 Brooke Soto 5544902205760175 Thur9313 \n", "219 Shelby House 502097403252 Sat8863 \n", "238 Kimberly Crane 676184013727 Sat9777 " ] }, "execution_count": 35, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df[(df['total_bill'] > 30) & (df['sex']!='Male')]" ] }, { "cell_type": "code", "execution_count": 30, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
total_billtipsexsmokerdaytimesizeprice_per_personPayer NameCC NumberPayment ID
016.991.01FemaleNoSunDinner28.49Christy Cunningham3560325168603410Sun2959
110.341.66MaleNoSunDinner33.45Douglas Tucker4478071379779230Sun4608
221.013.50MaleNoSunDinner37.00Travis Walters6011812112971322Sun4458
323.683.31MaleNoSunDinner211.84Nathaniel Harris4676137647685994Sun5260
424.593.61FemaleNoSunDinner46.15Tonya Carter4832732618637221Sun2251
525.294.71MaleNoSunDinner46.32Erik Smith213140353657882Sun9679
68.772.00MaleNoSunDinner24.38Kristopher Johnson2223727524230344Sun5985
726.883.12MaleNoSunDinner46.72Robert Buck3514785077705092Sun8157
815.041.96MaleNoSunDinner27.52Joseph Mcdonald3522866365840377Sun6820
914.783.23MaleNoSunDinner27.39Jerome Abbott3532124519049786Sun3775
1010.271.71MaleNoSunDinner25.14William Riley566287581219Sun2546
1135.265.00FemaleNoSunDinner48.82Diane Macias4577817359320969Sun6686
1215.421.57MaleNoSunDinner27.71Chad Harrington577040572932Sun1300
1318.433.00MaleNoSunDinner44.61Joshua Jones6011163105616890Sun2971
1414.833.02FemaleNoSunDinner27.42Vanessa Jones30016702287574Sun3848
1521.583.92MaleNoSunDinner210.79Matthew Reilly180073029785069Sun1878
1610.331.67FemaleNoSunDinner33.44Elizabeth Foster4240025044626033Sun9715
1716.293.71MaleNoSunDinner35.43John Pittman6521340257218708Sun2998
1816.973.50FemaleNoSunDinner35.66Laura Martinez30422275171379Sun2789
1920.653.35MaleNoSatDinner36.88Timothy Oneal6568069240986485Sat9213
2017.924.08MaleNoSatDinner28.96Thomas Rice4403296224639756Sat1709
2120.292.75FemaleNoSatDinner210.14Natalie Gardner5448125351489749Sat9618
2215.772.23FemaleNoSatDinner27.88Ashley Shelton3524119516293213Sat9786
2339.427.58MaleNoSatDinner49.86Lance Peterson3542584061609808Sat239
2419.823.18MaleNoSatDinner29.91Christopher Ross36739148167928Sat6236
2517.812.34MaleNoSatDinner44.45Robert Perkins30502930499388Sat907
2613.372.00MaleNoSatDinner26.68Kyle Avery6531339539615499Sat6651
2712.692.00MaleNoSatDinner26.34Patrick Barber30155551880343Sat394
2821.704.30MaleNoSatDinner210.85David Collier5529694315416009Sat3697
2919.653.00FemaleNoSatDinner29.82Melinda Murphy5489272944576051Sat2467
....................................
20626.593.41MaleYesSatDinner38.86Daniel Owens38971087967574Sat1
20738.733.00MaleYesSatDinner49.68Ricky Ramirez347817964484033Sat4505
20824.272.03MaleYesSatDinner212.14Jason Carter4268942915626180Sat6048
20912.762.23FemaleYesSatDinner26.38Sarah Cunningham341876516331163Sat1274
21030.062.00MaleYesSatDinner310.02Shawn Mendoza30184049218122Sat8361
21125.895.16MaleYesSatDinner46.47Christopher Li6011962464150569Sat6735
21248.339.00MaleNoSatDinner412.08Alex Williamson676218815212Sat4590
21313.272.50FemaleYesSatDinner26.64Robin Andersen580140531089Sat1374
21428.176.50FemaleYesSatDinner39.39Marissa Jackson4922302538691962Sat3374
21512.901.10FemaleYesSatDinner26.45Jessica Owen4726904879471Sat6983
21628.153.00MaleYesSatDinner55.63Shawn Barnett PhD4590982568244Sat7320
21711.591.50MaleYesSatDinner25.80Gary Orr30324521283406Sat8489
2187.741.44MaleYesSatDinner23.87Nicholas Archer340517153733524Sat4772
21930.143.09FemaleYesSatDinner47.54Shelby House502097403252Sat8863
22720.453.00MaleNoSatDinner45.11Robert Bradley213141668145910Sat4319
22813.282.72MaleNoSatDinner26.64Glenn Jones502061651712Sat2937
22922.122.88FemaleYesSatDinner211.06Jennifer Russell4793003293608Sat3943
23024.012.00MaleYesSatDinner46.00Michael Osborne4258682154026Sat7872
23115.693.00MaleYesSatDinner35.23Jason Parks4812333796161Sat6334
23211.613.39MaleNoSatDinner25.80James Taylor6011482917327995Sat2124
23310.771.47MaleNoSatDinner25.38Paul Novak6011698897610858Sat1467
23415.533.00MaleYesSatDinner27.76Tracy Douglas4097938155941930Sat7220
23510.071.25MaleNoSatDinner25.04Sean Gonzalez3534021246117605Sat4615
23612.601.00MaleYesSatDinner26.30Matthew Myers3543676378973965Sat5032
23732.831.17MaleYesSatDinner216.42Thomas Brown4284722681265508Sat2929
23835.834.67FemaleNoSatDinner311.94Kimberly Crane676184013727Sat9777
23929.035.92MaleNoSatDinner39.68Michael Avila5296068606052842Sat2657
24027.182.00FemaleYesSatDinner213.59Monica Sanders3506806155565404Sat1766
24122.672.00MaleYesSatDinner211.34Keith Wong6011891618747196Sat3880
24217.821.75MaleNoSatDinner28.91Dennis Dixon4375220550950Sat17
\n", "

163 rows × 11 columns

\n", "
" ], "text/plain": [ " total_bill tip sex smoker day time size price_per_person \\\n", "0 16.99 1.01 Female No Sun Dinner 2 8.49 \n", "1 10.34 1.66 Male No Sun Dinner 3 3.45 \n", "2 21.01 3.50 Male No Sun Dinner 3 7.00 \n", "3 23.68 3.31 Male No Sun Dinner 2 11.84 \n", "4 24.59 3.61 Female No Sun Dinner 4 6.15 \n", "5 25.29 4.71 Male No Sun Dinner 4 6.32 \n", "6 8.77 2.00 Male No Sun Dinner 2 4.38 \n", "7 26.88 3.12 Male No Sun Dinner 4 6.72 \n", "8 15.04 1.96 Male No Sun Dinner 2 7.52 \n", "9 14.78 3.23 Male No Sun Dinner 2 7.39 \n", "10 10.27 1.71 Male No Sun Dinner 2 5.14 \n", "11 35.26 5.00 Female No Sun Dinner 4 8.82 \n", "12 15.42 1.57 Male No Sun Dinner 2 7.71 \n", "13 18.43 3.00 Male No Sun Dinner 4 4.61 \n", "14 14.83 3.02 Female No Sun Dinner 2 7.42 \n", "15 21.58 3.92 Male No Sun Dinner 2 10.79 \n", "16 10.33 1.67 Female No Sun Dinner 3 3.44 \n", "17 16.29 3.71 Male No Sun Dinner 3 5.43 \n", "18 16.97 3.50 Female No Sun Dinner 3 5.66 \n", "19 20.65 3.35 Male No Sat Dinner 3 6.88 \n", "20 17.92 4.08 Male No Sat Dinner 2 8.96 \n", "21 20.29 2.75 Female No Sat Dinner 2 10.14 \n", "22 15.77 2.23 Female No Sat Dinner 2 7.88 \n", "23 39.42 7.58 Male No Sat Dinner 4 9.86 \n", "24 19.82 3.18 Male No Sat Dinner 2 9.91 \n", "25 17.81 2.34 Male No Sat Dinner 4 4.45 \n", "26 13.37 2.00 Male No Sat Dinner 2 6.68 \n", "27 12.69 2.00 Male No Sat Dinner 2 6.34 \n", "28 21.70 4.30 Male No Sat Dinner 2 10.85 \n", "29 19.65 3.00 Female No Sat Dinner 2 9.82 \n", ".. ... ... ... ... ... ... ... ... \n", "206 26.59 3.41 Male Yes Sat Dinner 3 8.86 \n", "207 38.73 3.00 Male Yes Sat Dinner 4 9.68 \n", "208 24.27 2.03 Male Yes Sat Dinner 2 12.14 \n", "209 12.76 2.23 Female Yes Sat Dinner 2 6.38 \n", "210 30.06 2.00 Male Yes Sat Dinner 3 10.02 \n", "211 25.89 5.16 Male Yes Sat Dinner 4 6.47 \n", "212 48.33 9.00 Male No Sat Dinner 4 12.08 \n", "213 13.27 2.50 Female Yes Sat Dinner 2 6.64 \n", "214 28.17 6.50 Female Yes Sat Dinner 3 9.39 \n", "215 12.90 1.10 Female Yes Sat Dinner 2 6.45 \n", "216 28.15 3.00 Male Yes Sat Dinner 5 5.63 \n", "217 11.59 1.50 Male Yes Sat Dinner 2 5.80 \n", "218 7.74 1.44 Male Yes Sat Dinner 2 3.87 \n", "219 30.14 3.09 Female Yes Sat Dinner 4 7.54 \n", "227 20.45 3.00 Male No Sat Dinner 4 5.11 \n", "228 13.28 2.72 Male No Sat Dinner 2 6.64 \n", "229 22.12 2.88 Female Yes Sat Dinner 2 11.06 \n", "230 24.01 2.00 Male Yes Sat Dinner 4 6.00 \n", "231 15.69 3.00 Male Yes Sat Dinner 3 5.23 \n", "232 11.61 3.39 Male No Sat Dinner 2 5.80 \n", "233 10.77 1.47 Male No Sat Dinner 2 5.38 \n", "234 15.53 3.00 Male Yes Sat Dinner 2 7.76 \n", "235 10.07 1.25 Male No Sat Dinner 2 5.04 \n", "236 12.60 1.00 Male Yes Sat Dinner 2 6.30 \n", "237 32.83 1.17 Male Yes Sat Dinner 2 16.42 \n", "238 35.83 4.67 Female No Sat Dinner 3 11.94 \n", "239 29.03 5.92 Male No Sat Dinner 3 9.68 \n", "240 27.18 2.00 Female Yes Sat Dinner 2 13.59 \n", "241 22.67 2.00 Male Yes Sat Dinner 2 11.34 \n", "242 17.82 1.75 Male No Sat Dinner 2 8.91 \n", "\n", " Payer Name CC Number Payment ID \n", "0 Christy Cunningham 3560325168603410 Sun2959 \n", "1 Douglas Tucker 4478071379779230 Sun4608 \n", "2 Travis Walters 6011812112971322 Sun4458 \n", "3 Nathaniel Harris 4676137647685994 Sun5260 \n", "4 Tonya Carter 4832732618637221 Sun2251 \n", "5 Erik Smith 213140353657882 Sun9679 \n", "6 Kristopher Johnson 2223727524230344 Sun5985 \n", "7 Robert Buck 3514785077705092 Sun8157 \n", "8 Joseph Mcdonald 3522866365840377 Sun6820 \n", "9 Jerome Abbott 3532124519049786 Sun3775 \n", "10 William Riley 566287581219 Sun2546 \n", "11 Diane Macias 4577817359320969 Sun6686 \n", "12 Chad Harrington 577040572932 Sun1300 \n", "13 Joshua Jones 6011163105616890 Sun2971 \n", "14 Vanessa Jones 30016702287574 Sun3848 \n", "15 Matthew Reilly 180073029785069 Sun1878 \n", "16 Elizabeth Foster 4240025044626033 Sun9715 \n", "17 John Pittman 6521340257218708 Sun2998 \n", "18 Laura Martinez 30422275171379 Sun2789 \n", "19 Timothy Oneal 6568069240986485 Sat9213 \n", "20 Thomas Rice 4403296224639756 Sat1709 \n", "21 Natalie Gardner 5448125351489749 Sat9618 \n", "22 Ashley Shelton 3524119516293213 Sat9786 \n", "23 Lance Peterson 3542584061609808 Sat239 \n", "24 Christopher Ross 36739148167928 Sat6236 \n", "25 Robert Perkins 30502930499388 Sat907 \n", "26 Kyle Avery 6531339539615499 Sat6651 \n", "27 Patrick Barber 30155551880343 Sat394 \n", "28 David Collier 5529694315416009 Sat3697 \n", "29 Melinda Murphy 5489272944576051 Sat2467 \n", ".. ... ... ... \n", "206 Daniel Owens 38971087967574 Sat1 \n", "207 Ricky Ramirez 347817964484033 Sat4505 \n", "208 Jason Carter 4268942915626180 Sat6048 \n", "209 Sarah Cunningham 341876516331163 Sat1274 \n", "210 Shawn Mendoza 30184049218122 Sat8361 \n", "211 Christopher Li 6011962464150569 Sat6735 \n", "212 Alex Williamson 676218815212 Sat4590 \n", "213 Robin Andersen 580140531089 Sat1374 \n", "214 Marissa Jackson 4922302538691962 Sat3374 \n", "215 Jessica Owen 4726904879471 Sat6983 \n", "216 Shawn Barnett PhD 4590982568244 Sat7320 \n", "217 Gary Orr 30324521283406 Sat8489 \n", "218 Nicholas Archer 340517153733524 Sat4772 \n", "219 Shelby House 502097403252 Sat8863 \n", "227 Robert Bradley 213141668145910 Sat4319 \n", "228 Glenn Jones 502061651712 Sat2937 \n", "229 Jennifer Russell 4793003293608 Sat3943 \n", "230 Michael Osborne 4258682154026 Sat7872 \n", "231 Jason Parks 4812333796161 Sat6334 \n", "232 James Taylor 6011482917327995 Sat2124 \n", "233 Paul Novak 6011698897610858 Sat1467 \n", "234 Tracy Douglas 4097938155941930 Sat7220 \n", "235 Sean Gonzalez 3534021246117605 Sat4615 \n", "236 Matthew Myers 3543676378973965 Sat5032 \n", "237 Thomas Brown 4284722681265508 Sat2929 \n", "238 Kimberly Crane 676184013727 Sat9777 \n", "239 Michael Avila 5296068606052842 Sat2657 \n", "240 Monica Sanders 3506806155565404 Sat1766 \n", "241 Keith Wong 6011891618747196 Sat3880 \n", "242 Dennis Dixon 4375220550950 Sat17 \n", "\n", "[163 rows x 11 columns]" ] }, "execution_count": 30, "metadata": {}, "output_type": "execute_result" } ], "source": [ "# The Weekend\n", "df[(df['day'] =='Sun') | (df['day']=='Sat')]" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Conditional Operator isin()\n", "\n", "We can use .isin() operator to filter by a list of options." ] }, { "cell_type": "code", "execution_count": 36, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "0 True\n", "1 True\n", "2 True\n", "3 True\n", "4 True\n", "5 True\n", "6 True\n", "7 True\n", "8 True\n", "9 True\n", "10 True\n", "11 True\n", "12 True\n", "13 True\n", "14 True\n", "15 True\n", "16 True\n", "17 True\n", "18 True\n", "19 True\n", "20 True\n", "21 True\n", "22 True\n", "23 True\n", "24 True\n", "25 True\n", "26 True\n", "27 True\n", "28 True\n", "29 True\n", " ... \n", "214 True\n", "215 True\n", "216 True\n", "217 True\n", "218 True\n", "219 True\n", "220 False\n", "221 False\n", "222 False\n", "223 False\n", "224 False\n", "225 False\n", "226 False\n", "227 True\n", "228 True\n", "229 True\n", "230 True\n", "231 True\n", "232 True\n", "233 True\n", "234 True\n", "235 True\n", "236 True\n", "237 True\n", "238 True\n", "239 True\n", "240 True\n", "241 True\n", "242 True\n", "243 False\n", "Name: day, Length: 244, dtype: bool" ] }, "execution_count": 36, "metadata": {}, "output_type": "execute_result" } ], "source": [ "options = ['Sat','Sun']\n", "df['day'].isin(options)" ] }, { "cell_type": "code", "execution_count": 37, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", "\n", "\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
total_billtipsexsmokerdaytimesizeprice_per_personPayer NameCC NumberPayment ID
016.991.01FemaleNoSunDinner28.49Christy Cunningham3560325168603410Sun2959
110.341.66MaleNoSunDinner33.45Douglas Tucker4478071379779230Sun4608
221.013.50MaleNoSunDinner37.00Travis Walters6011812112971322Sun4458
323.683.31MaleNoSunDinner211.84Nathaniel Harris4676137647685994Sun5260
424.593.61FemaleNoSunDinner46.15Tonya Carter4832732618637221Sun2251
525.294.71MaleNoSunDinner46.32Erik Smith213140353657882Sun9679
68.772.00MaleNoSunDinner24.38Kristopher Johnson2223727524230344Sun5985
726.883.12MaleNoSunDinner46.72Robert Buck3514785077705092Sun8157
815.041.96MaleNoSunDinner27.52Joseph Mcdonald3522866365840377Sun6820
914.783.23MaleNoSunDinner27.39Jerome Abbott3532124519049786Sun3775
1010.271.71MaleNoSunDinner25.14William Riley566287581219Sun2546
1135.265.00FemaleNoSunDinner48.82Diane Macias4577817359320969Sun6686
1215.421.57MaleNoSunDinner27.71Chad Harrington577040572932Sun1300
1318.433.00MaleNoSunDinner44.61Joshua Jones6011163105616890Sun2971
1414.833.02FemaleNoSunDinner27.42Vanessa Jones30016702287574Sun3848
1521.583.92MaleNoSunDinner210.79Matthew Reilly180073029785069Sun1878
1610.331.67FemaleNoSunDinner33.44Elizabeth Foster4240025044626033Sun9715
1716.293.71MaleNoSunDinner35.43John Pittman6521340257218708Sun2998
1816.973.50FemaleNoSunDinner35.66Laura Martinez30422275171379Sun2789
1920.653.35MaleNoSatDinner36.88Timothy Oneal6568069240986485Sat9213
2017.924.08MaleNoSatDinner28.96Thomas Rice4403296224639756Sat1709
2120.292.75FemaleNoSatDinner210.14Natalie Gardner5448125351489749Sat9618
2215.772.23FemaleNoSatDinner27.88Ashley Shelton3524119516293213Sat9786
2339.427.58MaleNoSatDinner49.86Lance Peterson3542584061609808Sat239
2419.823.18MaleNoSatDinner29.91Christopher Ross36739148167928Sat6236
2517.812.34MaleNoSatDinner44.45Robert Perkins30502930499388Sat907
2613.372.00MaleNoSatDinner26.68Kyle Avery6531339539615499Sat6651
2712.692.00MaleNoSatDinner26.34Patrick Barber30155551880343Sat394
2821.704.30MaleNoSatDinner210.85David Collier5529694315416009Sat3697
2919.653.00FemaleNoSatDinner29.82Melinda Murphy5489272944576051Sat2467
....................................
20626.593.41MaleYesSatDinner38.86Daniel Owens38971087967574Sat1
20738.733.00MaleYesSatDinner49.68Ricky Ramirez347817964484033Sat4505
20824.272.03MaleYesSatDinner212.14Jason Carter4268942915626180Sat6048
20912.762.23FemaleYesSatDinner26.38Sarah Cunningham341876516331163Sat1274
21030.062.00MaleYesSatDinner310.02Shawn Mendoza30184049218122Sat8361
21125.895.16MaleYesSatDinner46.47Christopher Li6011962464150569Sat6735
21248.339.00MaleNoSatDinner412.08Alex Williamson676218815212Sat4590
21313.272.50FemaleYesSatDinner26.64Robin Andersen580140531089Sat1374
21428.176.50FemaleYesSatDinner39.39Marissa Jackson4922302538691962Sat3374
21512.901.10FemaleYesSatDinner26.45Jessica Owen4726904879471Sat6983
21628.153.00MaleYesSatDinner55.63Shawn Barnett PhD4590982568244Sat7320
21711.591.50MaleYesSatDinner25.80Gary Orr30324521283406Sat8489
2187.741.44MaleYesSatDinner23.87Nicholas Archer340517153733524Sat4772
21930.143.09FemaleYesSatDinner47.54Shelby House502097403252Sat8863
22720.453.00MaleNoSatDinner45.11Robert Bradley213141668145910Sat4319
22813.282.72MaleNoSatDinner26.64Glenn Jones502061651712Sat2937
22922.122.88FemaleYesSatDinner211.06Jennifer Russell4793003293608Sat3943
23024.012.00MaleYesSatDinner46.00Michael Osborne4258682154026Sat7872
23115.693.00MaleYesSatDinner35.23Jason Parks4812333796161Sat6334
23211.613.39MaleNoSatDinner25.80James Taylor6011482917327995Sat2124
23310.771.47MaleNoSatDinner25.38Paul Novak6011698897610858Sat1467
23415.533.00MaleYesSatDinner27.76Tracy Douglas4097938155941930Sat7220
23510.071.25MaleNoSatDinner25.04Sean Gonzalez3534021246117605Sat4615
23612.601.00MaleYesSatDinner26.30Matthew Myers3543676378973965Sat5032
23732.831.17MaleYesSatDinner216.42Thomas Brown4284722681265508Sat2929
23835.834.67FemaleNoSatDinner311.94Kimberly Crane676184013727Sat9777
23929.035.92MaleNoSatDinner39.68Michael Avila5296068606052842Sat2657
24027.182.00FemaleYesSatDinner213.59Monica Sanders3506806155565404Sat1766
24122.672.00MaleYesSatDinner211.34Keith Wong6011891618747196Sat3880
24217.821.75MaleNoSatDinner28.91Dennis Dixon4375220550950Sat17
\n", "

163 rows × 11 columns

\n", "
" ], "text/plain": [ " total_bill tip sex smoker day time size price_per_person \\\n", "0 16.99 1.01 Female No Sun Dinner 2 8.49 \n", "1 10.34 1.66 Male No Sun Dinner 3 3.45 \n", "2 21.01 3.50 Male No Sun Dinner 3 7.00 \n", "3 23.68 3.31 Male No Sun Dinner 2 11.84 \n", "4 24.59 3.61 Female No Sun Dinner 4 6.15 \n", "5 25.29 4.71 Male No Sun Dinner 4 6.32 \n", "6 8.77 2.00 Male No Sun Dinner 2 4.38 \n", "7 26.88 3.12 Male No Sun Dinner 4 6.72 \n", "8 15.04 1.96 Male No Sun Dinner 2 7.52 \n", "9 14.78 3.23 Male No Sun Dinner 2 7.39 \n", "10 10.27 1.71 Male No Sun Dinner 2 5.14 \n", "11 35.26 5.00 Female No Sun Dinner 4 8.82 \n", "12 15.42 1.57 Male No Sun Dinner 2 7.71 \n", "13 18.43 3.00 Male No Sun Dinner 4 4.61 \n", "14 14.83 3.02 Female No Sun Dinner 2 7.42 \n", "15 21.58 3.92 Male No Sun Dinner 2 10.79 \n", "16 10.33 1.67 Female No Sun Dinner 3 3.44 \n", "17 16.29 3.71 Male No Sun Dinner 3 5.43 \n", "18 16.97 3.50 Female No Sun Dinner 3 5.66 \n", "19 20.65 3.35 Male No Sat Dinner 3 6.88 \n", "20 17.92 4.08 Male No Sat Dinner 2 8.96 \n", "21 20.29 2.75 Female No Sat Dinner 2 10.14 \n", "22 15.77 2.23 Female No Sat Dinner 2 7.88 \n", "23 39.42 7.58 Male No Sat Dinner 4 9.86 \n", "24 19.82 3.18 Male No Sat Dinner 2 9.91 \n", "25 17.81 2.34 Male No Sat Dinner 4 4.45 \n", "26 13.37 2.00 Male No Sat Dinner 2 6.68 \n", "27 12.69 2.00 Male No Sat Dinner 2 6.34 \n", "28 21.70 4.30 Male No Sat Dinner 2 10.85 \n", "29 19.65 3.00 Female No Sat Dinner 2 9.82 \n", ".. ... ... ... ... ... ... ... ... \n", "206 26.59 3.41 Male Yes Sat Dinner 3 8.86 \n", "207 38.73 3.00 Male Yes Sat Dinner 4 9.68 \n", "208 24.27 2.03 Male Yes Sat Dinner 2 12.14 \n", "209 12.76 2.23 Female Yes Sat Dinner 2 6.38 \n", "210 30.06 2.00 Male Yes Sat Dinner 3 10.02 \n", "211 25.89 5.16 Male Yes Sat Dinner 4 6.47 \n", "212 48.33 9.00 Male No Sat Dinner 4 12.08 \n", "213 13.27 2.50 Female Yes Sat Dinner 2 6.64 \n", "214 28.17 6.50 Female Yes Sat Dinner 3 9.39 \n", "215 12.90 1.10 Female Yes Sat Dinner 2 6.45 \n", "216 28.15 3.00 Male Yes Sat Dinner 5 5.63 \n", "217 11.59 1.50 Male Yes Sat Dinner 2 5.80 \n", "218 7.74 1.44 Male Yes Sat Dinner 2 3.87 \n", "219 30.14 3.09 Female Yes Sat Dinner 4 7.54 \n", "227 20.45 3.00 Male No Sat Dinner 4 5.11 \n", "228 13.28 2.72 Male No Sat Dinner 2 6.64 \n", "229 22.12 2.88 Female Yes Sat Dinner 2 11.06 \n", "230 24.01 2.00 Male Yes Sat Dinner 4 6.00 \n", "231 15.69 3.00 Male Yes Sat Dinner 3 5.23 \n", "232 11.61 3.39 Male No Sat Dinner 2 5.80 \n", "233 10.77 1.47 Male No Sat Dinner 2 5.38 \n", "234 15.53 3.00 Male Yes Sat Dinner 2 7.76 \n", "235 10.07 1.25 Male No Sat Dinner 2 5.04 \n", "236 12.60 1.00 Male Yes Sat Dinner 2 6.30 \n", "237 32.83 1.17 Male Yes Sat Dinner 2 16.42 \n", "238 35.83 4.67 Female No Sat Dinner 3 11.94 \n", "239 29.03 5.92 Male No Sat Dinner 3 9.68 \n", "240 27.18 2.00 Female Yes Sat Dinner 2 13.59 \n", "241 22.67 2.00 Male Yes Sat Dinner 2 11.34 \n", "242 17.82 1.75 Male No Sat Dinner 2 8.91 \n", "\n", " Payer Name CC Number Payment ID \n", "0 Christy Cunningham 3560325168603410 Sun2959 \n", "1 Douglas Tucker 4478071379779230 Sun4608 \n", "2 Travis Walters 6011812112971322 Sun4458 \n", "3 Nathaniel Harris 4676137647685994 Sun5260 \n", "4 Tonya Carter 4832732618637221 Sun2251 \n", "5 Erik Smith 213140353657882 Sun9679 \n", "6 Kristopher Johnson 2223727524230344 Sun5985 \n", "7 Robert Buck 3514785077705092 Sun8157 \n", "8 Joseph Mcdonald 3522866365840377 Sun6820 \n", "9 Jerome Abbott 3532124519049786 Sun3775 \n", "10 William Riley 566287581219 Sun2546 \n", "11 Diane Macias 4577817359320969 Sun6686 \n", "12 Chad Harrington 577040572932 Sun1300 \n", "13 Joshua Jones 6011163105616890 Sun2971 \n", "14 Vanessa Jones 30016702287574 Sun3848 \n", "15 Matthew Reilly 180073029785069 Sun1878 \n", "16 Elizabeth Foster 4240025044626033 Sun9715 \n", "17 John Pittman 6521340257218708 Sun2998 \n", "18 Laura Martinez 30422275171379 Sun2789 \n", "19 Timothy Oneal 6568069240986485 Sat9213 \n", "20 Thomas Rice 4403296224639756 Sat1709 \n", "21 Natalie Gardner 5448125351489749 Sat9618 \n", "22 Ashley Shelton 3524119516293213 Sat9786 \n", "23 Lance Peterson 3542584061609808 Sat239 \n", "24 Christopher Ross 36739148167928 Sat6236 \n", "25 Robert Perkins 30502930499388 Sat907 \n", "26 Kyle Avery 6531339539615499 Sat6651 \n", "27 Patrick Barber 30155551880343 Sat394 \n", "28 David Collier 5529694315416009 Sat3697 \n", "29 Melinda Murphy 5489272944576051 Sat2467 \n", ".. ... ... ... \n", "206 Daniel Owens 38971087967574 Sat1 \n", "207 Ricky Ramirez 347817964484033 Sat4505 \n", "208 Jason Carter 4268942915626180 Sat6048 \n", "209 Sarah Cunningham 341876516331163 Sat1274 \n", "210 Shawn Mendoza 30184049218122 Sat8361 \n", "211 Christopher Li 6011962464150569 Sat6735 \n", "212 Alex Williamson 676218815212 Sat4590 \n", "213 Robin Andersen 580140531089 Sat1374 \n", "214 Marissa Jackson 4922302538691962 Sat3374 \n", "215 Jessica Owen 4726904879471 Sat6983 \n", "216 Shawn Barnett PhD 4590982568244 Sat7320 \n", "217 Gary Orr 30324521283406 Sat8489 \n", "218 Nicholas Archer 340517153733524 Sat4772 \n", "219 Shelby House 502097403252 Sat8863 \n", "227 Robert Bradley 213141668145910 Sat4319 \n", "228 Glenn Jones 502061651712 Sat2937 \n", "229 Jennifer Russell 4793003293608 Sat3943 \n", "230 Michael Osborne 4258682154026 Sat7872 \n", "231 Jason Parks 4812333796161 Sat6334 \n", "232 James Taylor 6011482917327995 Sat2124 \n", "233 Paul Novak 6011698897610858 Sat1467 \n", "234 Tracy Douglas 4097938155941930 Sat7220 \n", "235 Sean Gonzalez 3534021246117605 Sat4615 \n", "236 Matthew Myers 3543676378973965 Sat5032 \n", "237 Thomas Brown 4284722681265508 Sat2929 \n", "238 Kimberly Crane 676184013727 Sat9777 \n", "239 Michael Avila 5296068606052842 Sat2657 \n", "240 Monica Sanders 3506806155565404 Sat1766 \n", "241 Keith Wong 6011891618747196 Sat3880 \n", "242 Dennis Dixon 4375220550950 Sat17 \n", "\n", "[163 rows x 11 columns]" ] }, "execution_count": 37, "metadata": {}, "output_type": "execute_result" } ], "source": [ "df[df['day'].isin(['Sat','Sun'])]" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "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.6" } }, "nbformat": 4, "nbformat_minor": 2 }