Dropping values
In [3]:
from pandas import Series, DataFrame
import pandas as pd
import numpy as np
from scipy import stats
# import qgrid
import matplotlib.pyplot as plt
import seaborn as sns
In [6]:
df = pd.read_csv('buffy.csv')
In [8]:
df.columns
Out[8]:
Index([u'Character', u'Species', u'Height (inches)', u'Actor DOB', u'Number of Episodes', u'Ranking', u'Gender'], dtype='object')
In [10]:
df
Out[10]:
Character
Species
Height (inches)
Actor DOB
Number of Episodes
Ranking
Gender
0
Buffy
Human
64.0
4/14/77
145
5
F
1
Xander
Human
70.0
4/12/71
145
11
M
2
Willow
Human
64.5
3/24/74
144
1
F
3
Giles
Human
73.0
2/20/54
123
3
M
4
Cordelia
Human
67.0
7/23/70
58
7
F
5
Angel
Vampire
73.0
5/16/69
59
19
M
6
Oz
Werewolf
64.0
2/8/74
40
18
M
7
Spike
Vampire
69.0
8/20/62
97
2
M
8
Anya
Human
63.5
4/8/73
85
10
F
9
Tara
Human
64.0
1/8/77
47
13
F
10
Dawn
Human
66.0
10/11/85
66
50
F
11
Joyce
Human
67.0
4/17/55
58
24
F
12
Faith
Human
65.0
12/30/80
20
4
F
13
Drusilla
Vampire
66.0
3/30/65
17
12
F
In [12]:
season4 = df.drop(4)
In [13]:
season4
Out[13]:
Character
Species
Height (inches)
Actor DOB
Number of Episodes
Ranking
Gender
0
Buffy
Human
64.0
4/14/77
145
5
F
1
Xander
Human
70.0
4/12/71
145
11
M
2
Willow
Human
64.5
3/24/74
144
1
F
3
Giles
Human
73.0
2/20/54
123
3
M
5
Angel
Vampire
73.0
5/16/69
59
19
M
6
Oz
Werewolf
64.0
2/8/74
40
18
M
7
Spike
Vampire
69.0
8/20/62
97
2
M
8
Anya
Human
63.5
4/8/73
85
10
F
9
Tara
Human
64.0
1/8/77
47
13
F
10
Dawn
Human
66.0
10/11/85
66
50
F
11
Joyce
Human
67.0
4/17/55
58
24
F
12
Faith
Human
65.0
12/30/80
20
4
F
13
Drusilla
Vampire
66.0
3/30/65
17
12
F
In [14]:
justthefacts = df.drop('Ranking', axis=1)
In [15]:
justthefacts
Out[15]:
Character
Species
Height (inches)
Actor DOB
Number of Episodes
Gender
0
Buffy
Human
64.0
4/14/77
145
F
1
Xander
Human
70.0
4/12/71
145
M
2
Willow
Human
64.5
3/24/74
144
F
3
Giles
Human
73.0
2/20/54
123
M
4
Cordelia
Human
67.0
7/23/70
58
F
5
Angel
Vampire
73.0
5/16/69
59
M
6
Oz
Werewolf
64.0
2/8/74
40
M
7
Spike
Vampire
69.0
8/20/62
97
M
8
Anya
Human
63.5
4/8/73
85
F
9
Tara
Human
64.0
1/8/77
47
F
10
Dawn
Human
66.0
10/11/85
66
F
11
Joyce
Human
67.0
4/17/55
58
F
12
Faith
Human
65.0
12/30/80
20
F
13
Drusilla
Vampire
66.0
3/30/65
17
F
In [16]:
tall = df[df['Height (inches)'] > 64.0]
In [17]:
tall
Out[17]:
Character
Species
Height (inches)
Actor DOB
Number of Episodes
Ranking
Gender
1
Xander
Human
70.0
4/12/71
145
11
M
2
Willow
Human
64.5
3/24/74
144
1
F
3
Giles
Human
73.0
2/20/54
123
3
M
4
Cordelia
Human
67.0
7/23/70
58
7
F
5
Angel
Vampire
73.0
5/16/69
59
19
M
7
Spike
Vampire
69.0
8/20/62
97
2
M
10
Dawn
Human
66.0
10/11/85
66
50
F
11
Joyce
Human
67.0
4/17/55
58
24
F
12
Faith
Human
65.0
12/30/80
20
4
F
13
Drusilla
Vampire
66.0
3/30/65
17
12
F
In [18]:
df.ix[5]
Out[18]:
Character Angel
Species Vampire
Height (inches) 73
Actor DOB 5/16/69
Number of Episodes 59
Ranking 19
Gender M
Name: 5, dtype: object
In [24]:
giles_stats = df.ix[3, ['Actor DOB', 'Gender']]
In [25]:
giles_stats
Out[25]:
Actor DOB 2/20/54
Gender M
Name: 3, dtype: object
In [ ]:
Content source: meli-lewis/datascience
Similar notebooks: