In this article How to read CSV files in Pandas I will write about.
This article also uses Jupyter lab. We will start on the assumption that you have installed it.
comma-separated values (abbreviation: CSV) is a data format in which text data is divided into several fields (items) and separated by a comma "," which is a delimiter. The extension is .csv and the MIME type is text / csv. Comma-Separated Values - Wikipedia
1, import Pandas 2, read csv file
First, import Pandas. It is customary in pandas to use the name'pd'. Specify with'as'.
import pandas as pd
To read the CSV file, use the read_csv function. Let's substitute it for'df'. The character code is specified by'shift-jis'. There are many other character codes such as'UTF-8'and'Unicode', so please check them out.
df = pd.read_csv('data01.csv', encoding="shift-jis")
Describe the file name you want to read in'data01.csv'. If it's in a folder, use a slash to get it. For example, if you want to read'data01.csv'in a file called "csv",
df = pd.read_csv('csv/data01.csv', encoding="shift-jis")
It will be.
Display method Display the'df' specified earlier in Jupyter lab.
import pandas as pd
df = pd.read_csv('data01.csv', encoding="shift-jis")
df
This time, How to read CSV files in Pandas I wrote an article about.
If you learn Pandas, you can do Excel and CSV operations, data analysis and graphing, so From now on, I would like to proceed with Pandas at the same time as Python.
Thank you very much.
Comma-Separated Values - Wikipedia
This article was written by a programming beginner and may be incorrect. Thank you for your understanding. Also, if you notice it, I would appreciate it if you could point it out.
Recommended Posts