elena1234

read and write into HTML file in Python

Apr 21st, 2022 (edited)
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. import pandas as pd
  2.  
  3. url = 'https://en.wikipedia.org/wiki/World_population'
  4. table = pd.read_html(url)
  5. new_table = table[4]
  6. new_table = new_table.set_index('Rank')
  7. new_table = new_table.drop('Source(official or UN)', axis=1)
  8. new_table = new_table.drop('% of world', axis=1)
  9. print(new_table)
  10.  
  11. new_table.to_html('C:/Users/eli/Desktop/simple.html')
  12.  
  13. # another way is with BeautifulSoup
  14.  
Add Comment
Please, Sign In to add comment