[PYTHON] [Beginner] What to do when "[Errno 2] File b'test.csv' does not exist: b'test.csv" is displayed when reading pandas csv

environment

Python 3.6.5 pandas 0.25.3

Overview

Read comma-separated csv files with pandas.read_csv ()

Issues that have occurred

FileNotFoundError: [Errno 2] File b'test.csv' does not exist: b'test.csv' Translation: b’test.csv’ not found!

data

test.csv

Name Japanese Mathematics English Science Society
0 A thick 83 89 76 97 76
1 B through 66 93 75 88 76
2 C child 100 84 96 82 94
3 Dro 60 73 63 52 70
4 E beauty 92 62 84 80 78
5 F greens 96 92 94 92 90

Source code

import pandas as pd
df = pd.read_csv("test.csv")

print(df)

For the time being, can you read csv first and check it on the console? It was an error when I tried to confirm the first move.

Solution

I added the following code and specified the current directory, and it was read without any problem. I wonder why the script and csv were placed in the same hierarchy ...

import os

#Specify the current directory
path =“Directory where csv is saved”
os.chdir(path)

Recommended Posts

[Beginner] What to do when "[Errno 2] File b'test.csv' does not exist: b'test.csv" is displayed when reading pandas csv
What to do when Japanese is not displayed on matplotlib
[EC2] What to do when selenium is stuck and processing does not proceed
What to do if sys / cdefs.h does not exist
Notes on what to do when matplotlib scatter () / scatter3d () does not work
What to do when a warning message is displayed in pip list
[Mac OS] What to do when Python is not installed as a framework. Is displayed when import matplotlib is performed.
What to do when you get angry that libxml / xmlversion.h does not exist when you put lxml with pip
Example of what to do when the sample script does not work (OpenCV-Python)
What to do if abort is displayed when inputting camera video in OpenCV
What to do when [Errno 2] No such file or directory appears in Python
What to do when the graph does not appear in jupyter (ipython) notebook
bash: cannot create temp file for here-document: What to do when No space left on device is displayed
[Python] Type Error:'WebElement' object is not iterable What to do when an error occurs
curl: (60) What to do when Issuer certificate is invalid.
What to do when python3 type venv does not work well on Raspberry Pi
What to do when is not in the sudoers file.This incident will be reported.
What to do when gdal_merge creates a huge file
What to do when only the window is displayed and nothing is displayed in pygame Note
What to do if the progress bar is not displayed in tqdm of python
What to do if Python IntelliSense is not displayed in VS Code on Windows
What to do when Python starts up in Anaconda does not come out unexpectedly
What to do if pyenv is not enabled (zsh)
How to create a new file when the specified file does not exist — write if the file exists
What to do if the image is not displayed using matplotlib etc. in the Docker container
What to do when a Missing artifact occurs in a jar that is not defined in pom.xml
When Pydev is not displayed even after adding Pydev5.2 to Eclipse (2016/8/30)
What to do when PyCharm font is strange or garbled
OSError: [Errno 40] What to do when Message too long appears
What to do if the message "Not recognized as an internal or external command, operable program or batch file" is displayed when executing the conda command after installing Miniconda.
[virtualbox] What to do when [Could not retrieve mirrorlist] appears when yum update is performed on CentOS7
[VSCode] unable to import'google.cloud' What to do when pylint (import-error) does not recognize the Python import statement
NameError: global name'dot_parser' is not defined and what to do when it comes up in python
What to do if the user name is changed and the pyenv library path does not pass
What to do if python says "fatal error:'stdio.h' file not found"
What to do when the jupyterlab extension settings are not reflected
What to do if "Unnamed: 0" is added in to_csv-> read_csv in pandas
What to do when UnicodeDecodeError occurs during read_csv in pandas (pd.read_table ())
What to do when the value type is ambiguous in Python?
[Super Beginner] [Tired Intermediate] When "command not found" or "command not found" is displayed
What to do when Ubuntu crashes
What to do when "Something is already running at port 8000" is displayed when the develop command of Gatsby is executed.
How to write what to do when an application is first displayed in Qt for Python with Designer
What to do in my case when pyenv install is not possible after upgrading to macOS Big Sur
What to do when the result downloaded via scrapy is in English
What to do if pyenv install does not proceed with an error
[Python] What to do when an error related to SSL authentication is returned
What to do when the warning "The environment is in consistent ..." appears in the Anaconda environment
Error due to UnicodeDecodeError when reading CSV file with Python [For beginners]
[Pandas] What is set_option [How to use]
[pandas] .csv file reading and display method
What to do if CERTIFICATE_VERIFY_FAILED occurs when nltk.download () is done on macOS pyhon
What to do when "TypeError: must be string, not int…" appears when using strptime
What to do when xlrd.biffh.XLRDError: Unsupported format, or corrupt file: Expected BOF record;
What to do when "TypeError: data type not understood" appears in python's numpy.zeros
What to do if NotADirectoryError: [Errno 20] Not a directory:'xdg-settings' appears in jupyter notebook
What to do if Japanese language support is not completely installed on Ubuntu 16.04
What to do if (base) is displayed at the beginning of the Mac terminal
What to do if you get the error "Error: opencv3: Does not support building both Python 2 and 3 wrappers" when installing openCV 3
[Small story] What to do if "Error with child process: Building resource'awsToolkitSamLocalResource'" does not work when Lambda is locally executed by SAM from VS Code