[PYTHON] How to read CSV files in Pandas

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.

What is a CSV file?

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

manner

1, import Pandas 2, read csv file

1, import Pandas

First, import Pandas. It is customary in pandas to use the name'pd'. Specify with'as'.

import pandas as pd

2, read CSV file

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

Summary

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.

reference

Comma-Separated Values - Wikipedia

Note

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

How to read CSV files in Pandas
Convert UTF-8 CSV files to read in Excel
2 ways to read all csv files in a folder
How to read csv containing only integers in Python
[R] [Python] Memo to read multiple csv files in multiple zip files
How to convert csv to tsv in CLI
Read all csv files in the folder
How to use Pandas 2
How to read PyPI
How to read JSON
Read CSV file: pandas
How to read a CSV file with Python 2/3
Summary of how to import files in Python 3
[Python] How to read excel file with pandas
Read CSV files uploaded to Flask without saving
How to get the files in the [Python] folder
How to read time series data in PyTorch
How to read a file in a different directory
How to change multiple columns of csv in Pandas (Unixtime-> Japan Time)
[Python] How to read a csv file (read_csv method of pandas module)
Read csv with python pandas
How to load files in Google Drive with Google Colaboratory
How to access with cache when reading_json in pandas
How to use Pandas Rolling
How to output CSV of multi-line header with pandas
How to convert JSON file to CSV file with Python Pandas
[Python] How to deal with pandas read_html read error
How to use variables in systemd Unit definition files
How to download files from Selenium in Python in Chrome
How to add page numbers to PDF files (in Python)
I tried to summarize how to use pandas in python
How to upload files in Django generic class view
How to develop in Python
How to reference static files in a Django project
Batch convert all xlsx files in the folder to CSV files
Summary of how to write .proto files used in gRPC
How to get an overview of your data in Pandas
How to read an Excel file (.xlsx) with Pandas [Python]
How to create dataframes and mess with elements in pandas
Data science companion in python, how to specify elements in pandas
Transpose CSV files in Python Part 1
[Python] Loading csv files using pandas
[Python] How to do PCA in Python
How to handle session in SQLAlchemy
How to read e-Stat subregion data
How to use classes in Theano
[Python] How to use Pandas Series
How to collect images in Python
How to update Spyder in Anaconda
How to use SQLite in Python
How to read the SNLI dataset
How to convert 0.5 to 1056964608 in one shot
How to reflect CSS in Django
How to kill processes in bulk
How to use Mysql in python
How to wrap C in Python
How to use PubChem in Python
Read files in parallel with Python
Bring files in Windows to WSL
How to run TensorFlow 1.0 code in 2.0
Ignore # line and read in pandas