Advertisement
jarekmor

sejm

Mar 21st, 2023
671
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.51 KB | None | 0 0
  1. import pandas as pd
  2.  
  3. url = "http://www.sejm.gov.pl/Sejm9.nsf/agent.xsp?symbol=glosowania&NrKadencji=9&NrPosiedzenia=18&NrGlosowania=1"
  4.  
  5. df = pd.read_html(url, encoding='utf-8')[0]
  6.  
  7. columns = [c for c in df.columns.to_list() if c!="Klub/Koło"]
  8. objects = [x for x in columns if df[x].dtype==object and x!="Klub/Koło"]
  9.  
  10. def obj_to_int(df,columns):
  11.     for c in columns:
  12.         df[c] = df[c].map(lambda x: 0 if x=="-" else int(x))
  13.     return df
  14.  
  15. df2 = obj_to_int(df, columns)
  16. print(df2)
  17.  
  18. df2.to_csv("sejm.csv")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement