Get country code with python

I needed a country code to do a certain competition. I wondered if I would have a chance to use it in the future, so I made it.

Created with a function. Scraping source

Python jupyterCode

country_code.ipynb


def country_code(output,file_name):
    '''
    ***help***
    output :Currently csv only
    file_name :Get any file name
The pandas I'm using this time.read_html is lxml, html5lib,
beautifulsoup4 is required, so install it with pip
    '''
    import pandas as pd
    url = "https://www-yousei.jsps.go.jp/yousei1/kuniList.do"
    dfs = pd.read_html(url,header = 0)
    if output == "csv":
        dfs[0].to_csv(file_name + ".csv")
    return dfs[0]

Since it is also uploaded to Git, it would be helpful if you could raise the code to get other codes if you are interested. GitHub Link

I'm new to GitHub and there are many things I don't understand, so if you have any questions, please let me know in the comments.

Recommended Posts

Get country code with python
Get date with python
Python with VS Code (Windows 10)
Get Twitter timeline with python
Get Youtube data with python
Debug Python with VS Code
Get thread ID with python
Get started with Python! ~ ② Grammar ~
Get stock price with Python
Get home directory with python
Get keyboard events with python
Get Alembic information with Python
Document Python code with Doxygen
Get started with Python! ~ ① Environment construction ~
Link to get started with python
Get reviews with python googlemap api
Get the weather with Python requests
Get web screen capture with python
Get the weather with Python requests 2
[Python] Get economic data with DataReader
How to get started with Python
[Small story] Get timestamp with Python
Get Qiita trends with Python scraping
Get started with Python in Blender
Install python with mac vs code
Get weather information with Python & scraping
System trade starting with Python3: Get the latest program code
Get additional data in LDAP with python
Get property information by scraping with python
FizzBuzz with Python3
Get html from element with Python selenium
Scraping with Python
[Note] Get data from PostgreSQL with Python
Statistics with python
Scraping with Python
Python with Go
[Python] Get the variable name with str
Twilio with Python
Integrate with Python
Play with 2016-Python
python character code
AES256 with python
Tested with Python
python starts with ()
with syntax (Python)
Get Started with TopCoder in Python (2020 Edition)
[Python] Algorithm-aware code
Bingo with python
Zundokokiyoshi with python
[Python] Get the character code of the file
[Python] Get Python package information with PyPI API
Get the EDINET code list in Python
How Python beginners get started with Python with Progete
Let's get along with Python # 0 (Environment construction)
Excel with Python
Microcomputer with Python
[Blender x Python] Let's get started with Blender Python !!
Cast with python
I tried to get the authentication code of Qiita API with Python.
Python hand play (let's get started with AtCoder?)
[Python] Get the files in a folder with Python