Xuliqin The homework3.1

import pandas as pd
url ='https://raw.githubusercontent.com/tidyverse/datascience-box/refs/heads/main/course-materials/lab-instructions/lab-03/data/nobel.csv'
df = pd.read_csv(url)
print(df.head())
   id       firstname    surname  year category  \
0   1  Wilhelm Conrad    Röntgen  1901  Physics   
1   2      Hendrik A.    Lorentz  1902  Physics   
2   3          Pieter     Zeeman  1902  Physics   
3   4           Henri  Becquerel  1903  Physics   
4   5          Pierre      Curie  1903  Physics   

                                         affiliation       city      country  \
0                                  Munich University     Munich      Germany   
1                                  Leiden University     Leiden  Netherlands   
2                               Amsterdam University  Amsterdam  Netherlands   
3                                École Polytechnique      Paris       France   
4  École municipale de physique et de chimie indu...      Paris       France   

    born_date   died_date  ... died_country_code overall_motivation share  \
0  1845-03-27  1923-02-10  ...                DE                NaN     1   
1  1853-07-18  1928-02-04  ...                NL                NaN     2   
2  1865-05-25  1943-10-09  ...                NL                NaN     2   
3  1852-12-15  1908-08-25  ...                FR                NaN     2   
4  1859-05-15  1906-04-19  ...                FR                NaN     4   

                                          motivation  born_country_original  \
0  "in recognition of the extraordinary services ...  Prussia (now Germany)   
1  "in recognition of the extraordinary service t...        the Netherlands   
2  "in recognition of the extraordinary service t...        the Netherlands   
3  "in recognition of the extraordinary services ...                 France   
4  "in recognition of the extraordinary services ...                 France   

       born_city_original died_country_original died_city_original  \
0  Lennep (now Remscheid)               Germany             Munich   
1                  Arnhem       the Netherlands                NaN   
2              Zonnemaire       the Netherlands          Amsterdam   
3                   Paris                France                NaN   
4                   Paris                France              Paris   

   city_original country_original  
0         Munich          Germany  
1         Leiden  the Netherlands  
2      Amsterdam  the Netherlands  
3          Paris           France  
4          Paris           France  

[5 rows x 26 columns]
df
id firstname surname year category affiliation city country born_date died_date ... died_country_code overall_motivation share motivation born_country_original born_city_original died_country_original died_city_original city_original country_original
0 1 Wilhelm Conrad Röntgen 1901 Physics Munich University Munich Germany 1845-03-27 1923-02-10 ... DE NaN 1 "in recognition of the extraordinary services ... Prussia (now Germany) Lennep (now Remscheid) Germany Munich Munich Germany
1 2 Hendrik A. Lorentz 1902 Physics Leiden University Leiden Netherlands 1853-07-18 1928-02-04 ... NL NaN 2 "in recognition of the extraordinary service t... the Netherlands Arnhem the Netherlands NaN Leiden the Netherlands
2 3 Pieter Zeeman 1902 Physics Amsterdam University Amsterdam Netherlands 1865-05-25 1943-10-09 ... NL NaN 2 "in recognition of the extraordinary service t... the Netherlands Zonnemaire the Netherlands Amsterdam Amsterdam the Netherlands
3 4 Henri Becquerel 1903 Physics École Polytechnique Paris France 1852-12-15 1908-08-25 ... FR NaN 2 "in recognition of the extraordinary services ... France Paris France NaN Paris France
4 5 Pierre Curie 1903 Physics École municipale de physique et de chimie indu... Paris France 1859-05-15 1906-04-19 ... FR NaN 4 "in recognition of the extraordinary services ... France Paris France Paris Paris France
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
930 965 Sir Gregory P. Winter 2018 Chemistry MRC Laboratory of Molecular Biology Cambridge United Kingdom 1951-04-14 NaN ... NaN NaN 4 "for the phage display of peptides and antibod... United Kingdom Leicester NaN NaN Cambridge United Kingdom
931 966 Denis Mukwege 2018 Peace NaN NaN NaN 1955-03-01 NaN ... NaN NaN 2 "for their efforts to end the use of sexual vi... Belgian Congo (now Democratic Republic of the ... Bukavu NaN NaN NaN NaN
932 967 Nadia Murad 2018 Peace NaN NaN NaN NaN NaN ... NaN NaN 2 "for their efforts to end the use of sexual vi... Iraq Kojo NaN NaN NaN NaN
933 968 William D. Nordhaus 2018 Economics Yale University New Haven CT USA 1941-05-31 NaN ... NaN NaN 2 "for integrating climate change into long-run ... USA Albuquerque NM NaN NaN New Haven CT USA
934 969 Paul M. Romer 2018 Economics NYU Stern School of Business New York NY USA NaN NaN ... NaN NaN 2 "for integrating technological innovations int... USA Denver CO NaN NaN New York NY USA

935 rows × 26 columns

df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 935 entries, 0 to 934
Data columns (total 26 columns):
 #   Column                 Non-Null Count  Dtype 
---  ------                 --------------  ----- 
 0   id                     935 non-null    int64 
 1   firstname              935 non-null    object
 2   surname                906 non-null    object
 3   year                   935 non-null    int64 
 4   category               935 non-null    object
 5   affiliation            685 non-null    object
 6   city                   680 non-null    object
 7   country                681 non-null    object
 8   born_date              902 non-null    object
 9   died_date              627 non-null    object
 10  gender                 935 non-null    object
 11  born_city              907 non-null    object
 12  born_country           907 non-null    object
 13  born_country_code      907 non-null    object
 14  died_city              608 non-null    object
 15  died_country           614 non-null    object
 16  died_country_code      614 non-null    object
 17  overall_motivation     17 non-null     object
 18  share                  935 non-null    int64 
 19  motivation             935 non-null    object
 20  born_country_original  907 non-null    object
 21  born_city_original     907 non-null    object
 22  died_country_original  614 non-null    object
 23  died_city_original     608 non-null    object
 24  city_original          680 non-null    object
 25  country_original       681 non-null    object
dtypes: int64(3), object(23)
memory usage: 190.1+ KB
df[(df['country'].notna())]
id firstname surname year category affiliation city country born_date died_date ... died_country_code overall_motivation share motivation born_country_original born_city_original died_country_original died_city_original city_original country_original
0 1 Wilhelm Conrad Röntgen 1901 Physics Munich University Munich Germany 1845-03-27 1923-02-10 ... DE NaN 1 "in recognition of the extraordinary services ... Prussia (now Germany) Lennep (now Remscheid) Germany Munich Munich Germany
1 2 Hendrik A. Lorentz 1902 Physics Leiden University Leiden Netherlands 1853-07-18 1928-02-04 ... NL NaN 2 "in recognition of the extraordinary service t... the Netherlands Arnhem the Netherlands NaN Leiden the Netherlands
2 3 Pieter Zeeman 1902 Physics Amsterdam University Amsterdam Netherlands 1865-05-25 1943-10-09 ... NL NaN 2 "in recognition of the extraordinary service t... the Netherlands Zonnemaire the Netherlands Amsterdam Amsterdam the Netherlands
3 4 Henri Becquerel 1903 Physics École Polytechnique Paris France 1852-12-15 1908-08-25 ... FR NaN 2 "in recognition of the extraordinary services ... France Paris France NaN Paris France
4 5 Pierre Curie 1903 Physics École municipale de physique et de chimie indu... Paris France 1859-05-15 1906-04-19 ... FR NaN 4 "in recognition of the extraordinary services ... France Paris France Paris Paris France
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
928 963 Frances H. Arnold 2018 Chemistry California Institute of Technology (Caltech) Pasadena CA USA 1956-07-25 NaN ... NaN NaN 2 "for the directed evolution of enzymes" USA Pittsburgh PA NaN NaN Pasadena CA USA
929 964 George P. Smith 2018 Chemistry University of Missouri Columbia USA 1941-03-10 NaN ... NaN NaN 4 "for the phage display of peptides and antibod... USA Norwalk CT NaN NaN Columbia USA
930 965 Sir Gregory P. Winter 2018 Chemistry MRC Laboratory of Molecular Biology Cambridge United Kingdom 1951-04-14 NaN ... NaN NaN 4 "for the phage display of peptides and antibod... United Kingdom Leicester NaN NaN Cambridge United Kingdom
933 968 William D. Nordhaus 2018 Economics Yale University New Haven CT USA 1941-05-31 NaN ... NaN NaN 2 "for integrating climate change into long-run ... USA Albuquerque NM NaN NaN New Haven CT USA
934 969 Paul M. Romer 2018 Economics NYU Stern School of Business New York NY USA NaN NaN ... NaN NaN 2 "for integrating technological innovations int... USA Denver CO NaN NaN New York NY USA

681 rows × 26 columns

df[(df['died_date'].isna())]
id firstname surname year category affiliation city country born_date died_date ... died_country_code overall_motivation share motivation born_country_original born_city_original died_country_original died_city_original city_original country_original
68 68 Chen Ning Yang 1957 Physics Institute for Advanced Study Princeton NJ USA 1922-09-22 NaN ... NaN NaN 2 "for their penetrating investigation of the so... China Hofei Anhwei NaN NaN Princeton NJ USA
69 69 Tsung-Dao Lee 1957 Physics Columbia University New York NY USA 1926-11-24 NaN ... NaN NaN 2 "for their penetrating investigation of the so... China Shanghai NaN NaN New York NY USA
94 95 Leon N. Cooper 1972 Physics Brown University Providence RI USA 1930-02-28 NaN ... NaN NaN 3 "for their jointly developed theory of superco... USA New York NY NaN NaN Providence RI USA
96 97 Leo Esaki 1973 Physics IBM Thomas J. Watson Research Center Yorktown Heights NY USA 1925-03-12 NaN ... NaN NaN 4 "for their experimental discoveries regarding ... Japan Osaka NaN NaN Yorktown Heights NY USA
97 98 Ivar Giaever 1973 Physics General Electric Company Schenectady NY USA 1929-04-05 NaN ... NaN NaN 4 "for their experimental discoveries regarding ... Norway Bergen NaN NaN Schenectady NY USA
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
930 965 Sir Gregory P. Winter 2018 Chemistry MRC Laboratory of Molecular Biology Cambridge United Kingdom 1951-04-14 NaN ... NaN NaN 4 "for the phage display of peptides and antibod... United Kingdom Leicester NaN NaN Cambridge United Kingdom
931 966 Denis Mukwege 2018 Peace NaN NaN NaN 1955-03-01 NaN ... NaN NaN 2 "for their efforts to end the use of sexual vi... Belgian Congo (now Democratic Republic of the ... Bukavu NaN NaN NaN NaN
932 967 Nadia Murad 2018 Peace NaN NaN NaN NaN NaN ... NaN NaN 2 "for their efforts to end the use of sexual vi... Iraq Kojo NaN NaN NaN NaN
933 968 William D. Nordhaus 2018 Economics Yale University New Haven CT USA 1941-05-31 NaN ... NaN NaN 2 "for integrating climate change into long-run ... USA Albuquerque NM NaN NaN New Haven CT USA
934 969 Paul M. Romer 2018 Economics NYU Stern School of Business New York NY USA NaN NaN ... NaN NaN 2 "for integrating technological innovations int... USA Denver CO NaN NaN New York NY USA

308 rows × 26 columns