In [1]:
import pandas as pd
In [2]:
#load the data
df = pd.read_csv("https://github.com/TheUpshot/nyt_weddings/raw/master/nyt_wedding_announcements.csv")
In [3]:
#sample of 5 lines of the dataframe
df.head()
Out[3]:
url
name_status
bride_age
groom_age
0
http://www.nytimes.com/1985/12/01/style/myra-c...
keeping
NaN
NaN
1
http://www.nytimes.com/1985/12/22/style/susan-...
taking
NaN
NaN
2
http://www.nytimes.com/1985/11/03/style/andrea...
taking
NaN
NaN
3
http://www.nytimes.com/1985/11/10/style/laetit...
keeping
NaN
NaN
4
http://www.nytimes.com/1985/10/06/style/leslie...
keeping
NaN
NaN
In [4]:
#info on the dataset
df.info()
<class 'pandas.core.frame.DataFrame'>
Int64Index: 7835 entries, 0 to 7834
Data columns (total 4 columns):
url 7835 non-null object
name_status 7835 non-null object
bride_age 6512 non-null float64
groom_age 6468 non-null float64
dtypes: float64(2), object(2)
memory usage: 306.1+ KB
In [6]:
#learning more about the dataset
df.describe()
Out[6]:
bride_age
groom_age
count
6512.000000
6468.000000
mean
30.457156
32.577767
std
6.126452
7.517557
min
20.000000
16.000000
25%
27.000000
28.000000
50%
29.000000
31.000000
75%
32.000000
35.000000
max
90.000000
92.000000
In [9]:
#sorting your dataframe by a column
df.sort(columns='name_status')
Out[9]:
url
name_status
bride_age
groom_age
2882
http://www.nytimes.com/1995/06/25/style/weddin...
both names
30
29
5885
http://www.nytimes.com/2010/10/17/fashion/wedd...
both names
29
32
1635
http://www.nytimes.com/1990/10/14/style/linda-...
both names
27
30
4801
http://www.nytimes.com/2000/06/25/style/weddin...
both names
24
27
2804
http://www.nytimes.com/1995/06/25/style/weddin...
both names
28
34
1050
http://www.nytimes.com/1990/10/15/style/ann-ki...
both names
42
50
3317
http://www.nytimes.com/1995/08/27/style/weddin...
both names
NaN
NaN
1052
http://www.nytimes.com/1990/10/15/style/lisa-e...
both names
NaN
NaN
7592
http://www.nytimes.com/2014/11/16/fashion/wedd...
both names
31
34
1642
http://www.nytimes.com/1990/06/11/style/ivy-s-...
both names
31
34
2894
http://www.nytimes.com/1995/06/18/style/weddin...
both names
30
30
1111
http://www.nytimes.com/1990/04/08/style/miss-w...
both names
NaN
27
1644
http://www.nytimes.com/1990/05/27/style/miss-b...
both names
NaN
NaN
6648
http://www.nytimes.com/2010/05/30/fashion/wedd...
both names
27
29
4110
http://www.nytimes.com/2000/05/14/style/weddin...
both names
33
31
861
http://www.nytimes.com/1990/05/21/style/paul-m...
both names
30
36
7410
http://www.nytimes.com/2014/07/06/fashion/wedd...
both names
25
26
832
http://www.nytimes.com/1990/11/04/style/amy-bo...
both names
24
24
5095
http://www.nytimes.com/2005/09/18/fashion/wedd...
both names
34
39
1904
http://www.nytimes.com/1995/06/04/style/weddin...
both names
25
28
4049
http://www.nytimes.com/2000/06/04/style/weddin...
both names
30
29
2604
http://www.nytimes.com/1995/02/19/style/weddin...
both names
21
25
3540
http://www.nytimes.com/2000/06/04/style/weddin...
both names
29
33
799
http://www.nytimes.com/1990/03/26/style/gail-o...
both names
NaN
NaN
6660
http://www.nytimes.com/2010/08/15/fashion/wedd...
both names
26
26
4675
http://www.nytimes.com/2000/02/13/style/weddin...
both names
32
35
825
http://www.nytimes.com/1990/05/13/style/donna-...
both names
NaN
NaN
912
http://www.nytimes.com/1990/09/17/style/ms-eck...
both names
NaN
NaN
4081
http://www.nytimes.com/2000/06/25/style/weddin...
both names
31
29
3354
http://www.nytimes.com/1995/08/13/style/weddin...
both names
26
36
...
...
...
...
...
6052
http://www.nytimes.com/2010/04/25/fashion/wedd...
unclear
27
26
2963
http://www.nytimes.com/1995/05/14/style/weddin...
unclear
28
30
2960
http://www.nytimes.com/1995/05/21/style/karen-...
unclear
27
27
6055
http://www.nytimes.com/2010/03/07/fashion/wedd...
unclear
29
28
6056
http://www.nytimes.com/2010/12/19/fashion/wedd...
unclear
28
27
6057
http://www.nytimes.com/2010/02/28/fashion/wedd...
unclear
33
33
6058
http://www.nytimes.com/2010/10/31/fashion/wedd...
unclear
31
32
6059
http://www.nytimes.com/2010/11/28/fashion/wedd...
unclear
25
27
324
http://www.nytimes.com/1985/12/01/style/jean-p...
unclear
NaN
NaN
306
http://www.nytimes.com/1985/10/07/style/jane-s...
unclear
NaN
NaN
2956
http://www.nytimes.com/1995/05/21/style/judith...
unclear
31
35
6063
http://www.nytimes.com/2010/09/19/fashion/wedd...
unclear
34
29
6064
http://www.nytimes.com/2010/08/08/fashion/wedd...
unclear
31
31
6065
http://www.nytimes.com/2010/07/04/fashion/wedd...
unclear
32
31
6066
http://www.nytimes.com/2010/06/06/fashion/wedd...
unclear
24
29
1687
http://www.nytimes.com/1990/06/17/style/page-p...
unclear
25
27
2951
http://www.nytimes.com/1995/05/21/style/alice-...
unclear
37
37
2948
http://www.nytimes.com/1995/05/21/style/weddin...
unclear
29
31
6070
http://www.nytimes.com/2010/10/03/fashion/wedd...
unclear
42
49
1686
http://www.nytimes.com/1990/06/04/style/lisa-p...
unclear
28
27
305
http://www.nytimes.com/1985/10/20/style/kathle...
unclear
NaN
NaN
6073
http://www.nytimes.com/2010/04/11/fashion/wedd...
unclear
36
30
302
http://www.nytimes.com/1985/12/01/style/amy-ma...
unclear
NaN
NaN
7828
http://www.nytimes.com/2014/08/31/fashion/wedd...
unclear
41
45
2947
http://www.nytimes.com/1995/05/21/style/simone...
unclear
30
28
1681
http://www.nytimes.com/1990/04/30/style/arthur...
unclear
NaN
NaN
6078
http://www.nytimes.com/2010/10/10/fashion/wedd...
unclear
36
35
301
http://www.nytimes.com/1985/10/20/style/shere-...
unclear
NaN
NaN
1679
http://www.nytimes.com/1990/11/25/style/linda-...
unclear
NaN
NaN
2946
http://www.nytimes.com/1995/05/21/style/elizab...
unclear
32
32
7835 rows × 4 columns
In [ ]:
Content source: JessicaGarson/Simple_Pandas
Similar notebooks: