Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions ..\data\scrapeddata.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
United States of America,Federal state,US USA 840,US,00,Unnamed: 5,Unnamed: 6,U.S.,U.S..1,U.S.A.,Unnamed: 10,Unnamed: 11,Unnamed: 12,Unnamed: 13,Unnamed: 14
Alabama,State,US-AL,AL,1.0,AL,AL,Ala.,Ala.,,,,,,
Alaska,State,US-AK,AK,2.0,AK,AK,Alaska,Alaska,Alas.,,,,,
Arizona,State,US-AZ,AZ,4.0,AZ,AZ,Ariz.,Ariz.,Az.,,,,,
Arkansas,State,US-AR,AR,5.0,AR,AR,Ark.,Ark.,,,,,,
California,State,US-CA,CA,6.0,CA,CF,Calif.,Calif.,"Ca., Cal.",,,,,
Colorado,State,US-CO,CO,8.0,CO,CL,Colo.,Colo.,Col.,,,,,
Connecticut,State,US-CT,CT,9.0,CT,CT,Conn.,Conn.,Ct.,,,,,
Delaware,State,US-DE,DE,10.0,DE,DL,Del.,Del.,De.,,,,,
DistrictofColumbia,Federal district,US-DC,DC,11.0,DC,DC,D.C.,D.C.,Wash. D.C.,,,,,
Florida,State,US-FL,FL,12.0,FL,FL,Fla.,Fla.,"Fl., Flor.",,,,,
Georgia,State,US-GA,GA,13.0,GA,GA,Ga.,Ga.,Geo.,,,,,
Hawaii,State,US-HI,HI,15.0,HI,HA,Hawaii,Hawaii,H.I.,,,,,
Idaho,State,US-ID,ID,16.0,ID,ID,Idaho,Idaho,"Id., Ida.",,,,,
Illinois,State,US-IL,IL,17.0,IL,IL,Ill.,Ill.,"Il., Ills., Ill's",,,,,
Indiana,State,US-IN,IN,18.0,IN,IN,Ind.,Ind.,In.,,,,,
Iowa,State,US-IA,IA,19.0,IA,IA,Iowa,Iowa,"Ia., Ioa.[1]",,,,,
Kansas,State,US-KS,KS,20.0,KS,KA,Kans.,Kan.,"Ks., Ka.",,,,,
Kentucky,State (Commonwealth),US-KY,KY,21.0,KY,KY,Ky.,Ky.,"Ken., Kent.",,,,,
Louisiana,State,US-LA,LA,22.0,LA,LA,La.,La.,,,,,,
Maine,State,US-ME,ME,23.0,ME,ME,Maine,Maine,Me.,,,,,
Maryland,State,US-MD,MD,24.0,MD,MD,Md.,Md.,,,,,,
Massachusetts,State (Commonwealth),US-MA,MA,25.0,MA,MS,Mass.,Mass.,,,,,,
Michigan,State,US-MI,MI,26.0,MI,MC,Mich.,Mich.,,,,,,
Minnesota,State,US-MN,MN,27.0,MN,MN,Minn.,Minn.,Mn.,,,,,
Mississippi,State,US-MS,MS,28.0,MS,MI,Miss.,Miss.,,,,,,
Missouri,State,US-MO,MO,29.0,MO,MO,Mo.,Mo.,,,,,,
Montana,State,US-MT,MT,30.0,MT,MT,Mont.,Mont.,,,,,,
Nebraska,State,US-NE,NE,31.0,NE,NB,Nebr.,Neb.,,,,,,
Nevada,State,US-NV,NV,32.0,NV,NV,Nev.,Nev.,Nv.,,,,,
NewHampshire,State,US-NH,NH,33.0,NH,NH,N.H.,N.H.,,,,,,
NewJersey,State,US-NJ,NJ,34.0,NJ,NJ,N.J.,N.J.,N.Jersey,,,,,
NewMexico,State,US-NM,NM,35.0,NM,NM,N. Mex.,N.M.,New M.,,,,,
NewYork,State,US-NY,NY,36.0,NY,NY,N.Y.,N.Y.,N. York,,,,,
NorthCarolina,State,US-NC,NC,37.0,NC,NC,N.C.,N.C.,N. Car.,,,,,
NorthDakota,State,US-ND,ND,38.0,ND,ND,N. Dak.,N.D.,NoDak,,,,,
Ohio,State,US-OH,OH,39.0,OH,OH,Ohio,Ohio,"O., Oh.",,,,,
Oklahoma,State,US-OK,OK,40.0,OK,OK,Okla.,Okla.,Ok.,,,,,
Oregon,State,US-OR,OR,41.0,OR,OR,Oreg.,Ore.,Or.,,,,,
Pennsylvania,State (Commonwealth),US-PA,PA,42.0,PA,PA,Pa.,Pa.,"Penn., Penna.",,,,,
RhodeIsland,State,US-RI,RI,44.0,RI,RI,R.I.,R.I.,"R.I. & P.P., R. Isl.",,,,,
SouthCarolina,State,US-SC,SC,45.0,SC,SC,S.C.,S.C.,S. Car.,,,,,
SouthDakota,State,US-SD,SD,46.0,SD,SD,S. Dak.,S.D.,SoDak,,,,,
Tennessee,State,US-TN,TN,47.0,TN,TN,Tenn.,Tenn.,,,,,,
Texas,State,US-TX,TX,48.0,TX,TX,Tex.,Texas,Tx.,,,,,
Utah,State,US-UT,UT,49.0,UT,UT,Utah,Utah,Ut.,,,,,
Vermont,State,US-VT,VT,50.0,VT,VT,Vt.,Vt.,,,,,,
Virginia,State (Commonwealth),US-VA,VA,51.0,VA,VA,Va.,Va.,Virg.,,,,,
Washington,State,US-WA,WA,53.0,WA,WN,Wash.,Wash.,"Wa., Wn.[2]",,,,,
WestVirginia,State,US-WV,WV,54.0,WV,WV,W. Va.,W.Va.,"W.V., W. Virg.",,,,,
Wisconsin,State,US-WI,WI,55.0,WI,WS,Wis.,Wis.,"Wi., Wisc.",,,,,
Wyoming,State,US-WY,WY,56.0,WY,WY,Wyo.,Wyo.,Wy.,,,,,
AmericanSamoa,Insular area (Territory),ASASM016US-AS,AS,60.0,AS,AS,A.S.,,,,,,,
Guam,Insular area (Territory),GUGUM316US-GU,GU,66.0,GU,GU,Guam,,,,,,,
NorthernMarianaIslands,Insular area (Commonwealth),MPMNP580US-MP,MP,69.0,MP,CM,M.P.,,CNMI[3],,,,,
PuertoRico,Insular area (Territory),PRPRI630US-PR,PR,72.0,PR,PR,P.R.,,,,,,,
U.S.VirginIslands,Insular area (Territory),VIVIR850US-VI,VI,78.0,VI,VI,V.I.,,U.S.V.I.,,,,,
U.S.MinorOutlyingIslands,Insular areas,UMUMI581US-UM,UM,74.0,,,,,,,,,,
BakerIsland,island,UM-81,,81.0,,,,,XB[4],,,,,
HowlandIsland,island,UM-84,,84.0,,,,,XH[4],,,,,
JarvisIsland,island,UM-86,,86.0,,,,,XQ[4],,,,,
JohnstonAtoll,atoll,UM-67,,67.0,,,,,XU[4],,,,,
KingmanReef,atoll,UM-89,,89.0,,,,,XM[4],,,,,
MidwayIslands,atoll,UM-71,,71.0,,,,,QM[4],,,,,
NavassaIsland,island,UM-76,,76.0,,,,,XV[4],,,,,
PalmyraAtoll[5],atoll[5],UM-95,,95.0,,,,,XL[4],,,,,
WakeIsland,atoll,UM-79,,79.0,,,,,QW[4],,,,,
Micronesia,Freely associated state,FMFSM583,FM,64.0,FM,,,,,,,,,
MarshallIslands,Freely associated state,MHMHL584,MH,68.0,MH,,,,,,,,,
Palau,Freely associated state,PWPLW585,PW,70.0,PW,,,,,,,,,
U.S.ArmedForces–Americas[6],US military mail code,,,,AA,,,,,,,,,
U.S.ArmedForces–Europe[7],US military mail code,,,,AE,,,,,,,,,
U.S.ArmedForces–Pacific[8],US military mail code,,,,AP,,,,,,,,,
NorthernMarianaIslands,Obsolete postal code[9],,,,CM,,,,,,,,,
PanamaCanalZone,Obsolete postal code,PZPCZ594,,,CZ,,,,,,,,,
Nebraska,Obsolete postal code[10],,,,NB,,,,,,,,,
PhilippineIslands,Obsolete postal code,PHPHL608[11],,,PI,,,,,,,,,
TrustTerritoryofthePacificIslands,Obsolete postal code,PCPCI582,,,TT,,,,,,,,,
78 changes: 78 additions & 0 deletions D:\GreyAtom\Guided_Project\Scraped_Data\scrapeddata.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
United States of America,Federal state,US USA 840,US,00,,,U.S.,U.S.,U.S.A.
Alabama,State,US-AL,AL,01,AL,AL,Ala.,Ala.,
Alaska,State,US-AK,AK,02,AK,AK,Alaska,Alaska,Alas.
Arizona,State,US-AZ,AZ,04,AZ,AZ,Ariz.,Ariz.,Az.
Arkansas,State,US-AR,AR,05,AR,AR,Ark.,Ark.,
California,State,US-CA,CA,06,CA,CF,Calif.,Calif.,"Ca., Cal."
Colorado,State,US-CO,CO,08,CO,CL,Colo.,Colo.,Col.
Connecticut,State,US-CT,CT,09,CT,CT,Conn.,Conn.,Ct.
Delaware,State,US-DE,DE,10,DE,DL,Del.,Del.,De.
District of Columbia,Federal district,US-DC,DC,11,DC,DC,D.C.,D.C.,Wash. D.C.
Florida,State,US-FL,FL,12,FL,FL,Fla.,Fla.,"Fl., Flor."
Georgia,State,US-GA,GA,13,GA,GA,Ga.,Ga.,Geo.
Hawaii,State,US-HI,HI,15,HI,HA,Hawaii,Hawaii,H.I.
Idaho,State,US-ID,ID,16,ID,ID,Idaho,Idaho,"Id., Ida."
Illinois,State,US-IL,IL,17,IL,IL,Ill.,Ill.,"Il., Ills., Ill's"
Indiana,State,US-IN,IN,18,IN,IN,Ind.,Ind.,In.
Iowa,State,US-IA,IA,19,IA,IA,Iowa,Iowa,"Ia., Ioa.[1]"
Kansas,State,US-KS,KS,20,KS,KA,Kans.,Kan.,"Ks., Ka."
Kentucky,State (Commonwealth),US-KY,KY,21,KY,KY,Ky.,Ky.,"Ken., Kent."
Louisiana,State,US-LA,LA,22,LA,LA,La.,La.,
Maine,State,US-ME,ME,23,ME,ME,Maine,Maine,Me.
Maryland,State,US-MD,MD,24,MD,MD,Md.,Md.,
Massachusetts,State (Commonwealth),US-MA,MA,25,MA,MS,Mass.,Mass.,
Michigan,State,US-MI,MI,26,MI,MC,Mich.,Mich.,
Minnesota,State,US-MN,MN,27,MN,MN,Minn.,Minn.,Mn.
Mississippi,State,US-MS,MS,28,MS,MI,Miss.,Miss.,
Missouri,State,US-MO,MO,29,MO,MO,Mo.,Mo.,
Montana,State,US-MT,MT,30,MT,MT,Mont.,Mont.,
Nebraska,State,US-NE,NE,31,NE,NB,Nebr.,Neb.,
Nevada,State,US-NV,NV,32,NV,NV,Nev.,Nev.,Nv.
New Hampshire,State,US-NH,NH,33,NH,NH,N.H.,N.H.,
New Jersey,State,US-NJ,NJ,34,NJ,NJ,N.J.,N.J.,N.Jersey
New Mexico,State,US-NM,NM,35,NM,NM,N. Mex.,N.M.,New M.
New York,State,US-NY,NY,36,NY,NY,N.Y.,N.Y.,N. York
North Carolina,State,US-NC,NC,37,NC,NC,N.C.,N.C.,N. Car.
North Dakota,State,US-ND,ND,38,ND,ND,N. Dak.,N.D.,NoDak
Ohio,State,US-OH,OH,39,OH,OH,Ohio,Ohio,"O., Oh."
Oklahoma,State,US-OK,OK,40,OK,OK,Okla.,Okla.,Ok.
Oregon,State,US-OR,OR,41,OR,OR,Oreg.,Ore.,Or.
Pennsylvania,State (Commonwealth),US-PA,PA,42,PA,PA,Pa.,Pa.,"Penn., Penna."
Rhode Island,State,US-RI,RI,44,RI,RI,R.I.,R.I.,"R.I. & P.P., R. Isl."
South Carolina,State,US-SC,SC,45,SC,SC,S.C.,S.C.,S. Car.
South Dakota,State,US-SD,SD,46,SD,SD,S. Dak.,S.D.,SoDak
Tennessee,State,US-TN,TN,47,TN,TN,Tenn.,Tenn.,
Texas,State,US-TX,TX,48,TX,TX,Tex.,Texas,Tx.
Utah,State,US-UT,UT,49,UT,UT,Utah,Utah,Ut.
Vermont,State,US-VT,VT,50,VT,VT,Vt.,Vt.,
Virginia,State (Commonwealth),US-VA,VA,51,VA,VA,Va.,Va.,Virg.
Washington,State,US-WA,WA,53,WA,WN,Wash.,Wash.,"Wa., Wn.[2]"
West Virginia,State,US-WV,WV,54,WV,WV,W. Va.,W.Va.,"W.V., W. Virg."
Wisconsin,State,US-WI,WI,55,WI,WS,Wis.,Wis.,"Wi., Wisc."
Wyoming,State,US-WY,WY,56,WY,WY,Wyo.,Wyo.,Wy.
American Samoa,Insular area (Territory),ASASM016US-AS,AS,60,AS,AS,A.S.,,
Guam,Insular area (Territory),GUGUM316US-GU,GU,66,GU,GU,Guam,,
Northern Mariana Islands,Insular area (Commonwealth),MPMNP580US-MP,MP,69,MP,CM,M.P.,,CNMI[3]
Puerto Rico,Insular area (Territory),PRPRI630US-PR,PR,72,PR,PR,P.R.,,
U.S. Virgin Islands,Insular area (Territory),VIVIR850US-VI,VI,78,VI,VI,V.I.,,U.S.V.I.
U.S. Minor Outlying Islands,Insular areas,UMUMI581US-UM,UM,74,,,,,
Baker Island,island,UM-81,,81,,,,,XB[4]
Howland Island,island,UM-84,,84,,,,,XH[4]
Jarvis Island,island,UM-86,,86,,,,,XQ[4]
Johnston Atoll,atoll,UM-67,,67,,,,,XU[4]
Kingman Reef,atoll,UM-89,,89,,,,,XM[4]
Midway Islands,atoll,UM-71,,71,,,,,QM[4]
Navassa Island,island,UM-76,,76,,,,,XV[4]
Palmyra Atoll[5],atoll[5],UM-95,,95,,,,,XL[4]
Wake Island,atoll,UM-79,,79,,,,,QW[4]
Micronesia,Freely associated state,FMFSM583,FM,64,FM,,,,
Marshall Islands,Freely associated state,MHMHL584,MH,68,MH,,,,
Palau,Freely associated state,PWPLW585,PW,70,PW,,,,
U.S. Armed Forces – Americas[6],US military mail code,,,,AA,,,,
U.S. Armed Forces – Europe[7],US military mail code,,,,AE,,,,
U.S. Armed Forces – Pacific[8],US military mail code,,,,AP,,,,
Northern Mariana Islands,Obsolete postal code[9],,,,CM,,,,
Panama Canal Zone,Obsolete postal code,PZPCZ594,,,CZ,,,,
Nebraska,Obsolete postal code[10],,,,NB,,,,
Philippine Islands,Obsolete postal code,PHPHL608[11],,,PI,,,,
Trust Territory of the Pacific Islands,Obsolete postal code,PCPCI582,,,TT,,,,
Binary file modified __pycache__/__init__.cpython-36.pyc
Binary file not shown.
28 changes: 14 additions & 14 deletions data/scraped.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
,United States of America,Federal state,US USA 840,US,00,,,U.S.,U.S.,U.S.A.,,,,,
,United States of America,Federal state,".mw-parser-output .monospaced{font-family:monospace,monospace}USUSA840",US,00,,,U.S.,U.S.,U.S.A.,,,,,
12,Alabama,State,US-AL,AL,01,AL,AL,Ala.,Ala.,,,,,,
13,Alaska,State,US-AK,AK,02,AK,AK,Alaska,Alaska,Alas.,,,,,
14,Arizona,State,US-AZ,AZ,04,AZ,AZ,Ariz.,Ariz.,Az.,,,,,
Expand All @@ -9,7 +9,7 @@
19,Delaware,State,US-DE,DE,10,DE,DL,Del.,Del.,De.,,,,,
20,DistrictofColumbia,Federal district,US-DC,DC,11,DC,DC,D.C.,D.C.,Wash. D.C.,,,,,
21,Florida,State,US-FL,FL,12,FL,FL,Fla.,Fla.,"Fl., Flor.",,,,,
22,Georgia,State,US-GA,GA,13,GA,GA,Ga.,Ga.,,,,,,
22,Georgia,State,US-GA,GA,13,GA,GA,Ga.,Ga.,Geo.,,,,,
23,Hawaii,State,US-HI,HI,15,HI,HA,Hawaii,Hawaii,H.I.,,,,,
24,Idaho,State,US-ID,ID,16,ID,ID,Idaho,Idaho,"Id., Ida.",,,,,
25,Illinois,State,US-IL,IL,17,IL,IL,Ill.,Ill.,"Il., Ills., Ill's",,,,,
Expand Down Expand Up @@ -50,12 +50,12 @@
60,WestVirginia,State,US-WV,WV,54,WV,WV,W. Va.,W.Va.,"W.V., W. Virg.",,,,,
61,Wisconsin,State,US-WI,WI,55,WI,WS,Wis.,Wis.,"Wi., Wisc.",,,,,
62,Wyoming,State,US-WY,WY,56,WY,WY,Wyo.,Wyo.,Wy.,,,,,
63,AmericanSamoa,Insular area (Territory),AS ASM 016 US-AS,AS,60,AS,AS,A.S.,,,,,,,
64,Guam,Insular area (Territory),GU GUM 316 US-GU,GU,66,GU,GU,Guam,,,,,,,
65,NorthernMarianaIslands,Insular area (Commonwealth),MP MNP 580 US-MP,MP,69,MP,CM,M.P.,,CNMI[3],,,,,
66,PuertoRico,Insular area (Territory),PR PRI 630 US-PR,PR,72,PR,PR,P.R.,,,,,,,
67,U.S.VirginIslands,Insular area (Territory),VI VIR 850 US-VI,VI,78,VI,VI,V.I.,,U.S.V.I.,,,,,
68,U.S.MinorOutlyingIslands,Insular areas,UM UMI 581 US-UM,UM,74,,,,,,,,,,
63,AmericanSamoa,Insular area (Territory),ASASM016US-AS,AS,60,AS,AS,A.S.,,,,,,,
64,Guam,Insular area (Territory),GUGUM316US-GU,GU,66,GU,GU,Guam,,,,,,,
65,NorthernMarianaIslands,Insular area (Commonwealth),MPMNP580US-MP,MP,69,MP,CM,M.P.,,CNMI[3],,,,,
66,PuertoRico,Insular area (Territory),PRPRI630US-PR,PR,72,PR,PR,P.R.,,,,,,,
67,U.S.VirginIslands,Insular area (Territory),VIVIR850US-VI,VI,78,VI,VI,V.I.,,U.S.V.I.,,,,,
68,U.S.MinorOutlyingIslands,Insular areas,UMUMI581US-UM,UM,74,,,,,,,,,,
69,BakerIsland,island,UM-81,,81,,,,,XB[4],,,,,
70,HowlandIsland,island,UM-84,,84,,,,,XH[4],,,,,
71,JarvisIsland,island,UM-86,,86,,,,,XQ[4],,,,,
Expand All @@ -65,14 +65,14 @@
75,NavassaIsland,island,UM-76,,76,,,,,XV[4],,,,,
76,PalmyraAtoll[5],atoll[5],UM-95,,95,,,,,XL[4],,,,,
77,WakeIsland,atoll,UM-79,,79,,,,,QW[4],,,,,
78,Micronesia,Freely associated state,FM FSM 583,FM,64,FM,,,,,,,,,
79,MarshallIslands,Freely associated state,MH MHL 584,MH,68,MH,,,,,,,,,
80,Palau,Freely associated state,PW PLW 585,PW,70,PW,,,,,,,,,
78,Micronesia,Freely associated state,FMFSM583,FM,64,FM,,,,,,,,,
79,MarshallIslands,Freely associated state,MHMHL584,MH,68,MH,,,,,,,,,
80,Palau,Freely associated state,PWPLW585,PW,70,PW,,,,,,,,,
81,U.S.ArmedForces–Americas[6],US military mail code,,,,AA,,,,,,,,,
82,U.S.ArmedForces–Europe[7],US military mail code,,,,AE,,,,,,,,,
83,U.S.ArmedForces–Pacific[8],US military mail code,,,,AP,,,,,,,,,
84,NorthernMarianaIslands,Obsolete postal code[9],,,,CM,,,,,,,,,
85,PanamaCanalZone,Obsolete postal code,PZ PCZ 594,,,CZ,,,,,,,,,
85,PanamaCanalZone,Obsolete postal code,PZPCZ594,,,CZ,,,,,,,,,
86,Nebraska,Obsolete postal code[10],,,,NB,,,,,,,,,
87,PhilippineIslands,Obsolete postal code,PH PHL 608[11],,,PI,,,,,,,,,
88,TrustTerritoryofthePacificIslands,Obsolete postal code,PC PCI 582,,,TT,,,,,,,,,
87,PhilippineIslands,Obsolete postal code,PHPHL608[11],,,PI,,,,,,,,,
88,TrustTerritoryofthePacificIslands,Obsolete postal code,PCPCI582,,,TT,,,,,,,,,
Binary file modified q01_load_data/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified q01_load_data/__pycache__/build.cpython-36.pyc
Binary file not shown.
11 changes: 9 additions & 2 deletions q01_load_data/build.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# %load q01_load_data/build.py
import pandas as pd


path = './data/excel-comp-data.xlsx'
def q01_load_data(path):
"write your solution here"
df = pd.read_excel(path)
df['state'] = df['state'].map(lambda x: x.lower())
df['total'] = df['Jan'] + df['Feb'] + df['Mar']
return df

q01_load_data(path)

Binary file modified q01_load_data/tests/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified q01_load_data/tests/__pycache__/tests.cpython-36.pyc
Binary file not shown.
Binary file modified q02_append_row/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified q02_append_row/__pycache__/build.cpython-36.pyc
Binary file not shown.
23 changes: 21 additions & 2 deletions q02_append_row/build.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,30 @@
# %load q02_append_row/build.py
import pandas as pd
import sys, os
#sys.path.append(os.path.join(os.path.dirname(os.curdir)))
from greyatomlib.pandas_guided_project.q01_load_data.build import q01_load_data


path = './data/excel-comp-data.xlsx'
def q02_append_row(path):
"write your solution here"
data_set = q01_load_data(path)
'''
Approach 1
'''
data_set.at['Grand Total', 'Jan'] = data_set['Jan'].sum()
data_set.at['Grand Total', 'Feb'] = data_set['Feb'].sum()
data_set.at['Grand Total', 'Mar'] = data_set['Mar'].sum()
data_set.at['Grand Total', 'total'] = data_set['total'].sum()

'''
Approach 2
'''
#data_set.loc['Grand Total', 'Jan'] = data_set['Jan'].sum()
#data_set.loc['Grand Total', 'Feb'] = data_set['Feb'].sum()
#data_set.loc['Grand Total', 'Mar'] = data_set['Mar'].sum()
#data_set.loc['Grand Total', 'total'] = data_set['total'].sum()
return data_set
q02_append_row(path)




Expand Down
Binary file modified q02_append_row/tests/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified q02_append_row/tests/__pycache__/tests.cpython-36.pyc
Binary file not shown.
Binary file modified q03_scrape_clean/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified q03_scrape_clean/__pycache__/build.cpython-36.pyc
Binary file not shown.
17 changes: 16 additions & 1 deletion q03_scrape_clean/build.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
# %load q03_scrape_clean/build.py
import pandas as pd
import re
import sys, os
import csv
import requests
sys.path.append(os.path.join(os.path.dirname(os.curdir)))

url = 'https://en.wikipedia.org/wiki/List_of_U.S._state_abbreviations'

def q03_scrape_clean(url):
"write your solution here"
#data_from_page = requests.get(url)
list_of_tables = pd.read_html(url, header = 0, skiprows = 11, attrs = {'class' : 'wikitable sortable'})
df1 = pd.DataFrame(list_of_tables[0])
df1 = df1.rename(columns = {'.mw-parser-output .monospaced{font-family:monospace,monospace}USUSA840' : 'US USA 840'})
df1['United States of America'] = df1['United States of America'].str.replace(' ', '')
df1.to_csv('..\data\scrapeddata.csv', index = False)

return df1

q03_scrape_clean(url)



Binary file modified q03_scrape_clean/tests/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified q03_scrape_clean/tests/__pycache__/tests.cpython-36.pyc
Binary file not shown.
Binary file modified q04_mapping/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified q04_mapping/__pycache__/build.cpython-36.pyc
Binary file not shown.
24 changes: 22 additions & 2 deletions q04_mapping/build.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
# %load q04_mapping/build.py
import pandas as pd
import sys, os
import numpy as np
#sys.path.append(os.path.join(os.path.dirname(os.curdir)))
sys.path.append(os.path.join(os.path.dirname(os.curdir)))
from greyatomlib.pandas_guided_project.q02_append_row.build import q02_append_row

#Custom
from greyatomlib.pandas_guided_project.q03_scrape_clean.build import q03_scrape_clean

def q04_mapping(path1,path2):
"write your solution here"
df_from_appended_row = q02_append_row(path1)
df_from_scraped_data = q03_scrape_clean(path2)

#Approach 1 for creating a dictionary
mapping = df_from_scraped_data.set_index('United States of America').to_dict()['U.S.']
mapping = {k.lower(): v for k,v in mapping.items()}
df_final = df_from_appended_row

#Inseting 'abbr' at column 6 - Approach 2 for this is given below
df_final.insert(6, 'abbr', '')
df_final['abbr'] = df_final['state'].map(mapping)

return df_final

path1 = 'data/excel-comp-data.xlsx'
path2 = 'https://en.wikipedia.org/wiki/List_of_U.S._state_abbreviations'
q04_mapping(path1, path2)


Binary file modified q04_mapping/tests/__pycache__/__init__.cpython-36.pyc
Binary file not shown.
Binary file modified q04_mapping/tests/__pycache__/test.cpython-36.pyc
Binary file not shown.