Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- url = "http://www.sejm.gov.pl/Sejm9.nsf/agent.xsp?symbol=glosowania&NrKadencji=9&NrPosiedzenia=18&NrGlosowania=1"
- df = pd.read_html(url, encoding='utf-8')[0]
- columns = [c for c in df.columns.to_list() if c!="Klub/Koło"]
- objects = [x for x in columns if df[x].dtype==object and x!="Klub/Koło"]
- def obj_to_int(df,columns):
- for c in columns:
- df[c] = df[c].map(lambda x: 0 if x=="-" else int(x))
- return df
- df2 = obj_to_int(df, columns)
- print(df2)
- df2.to_csv("sejm.csv")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement