0

This is the current code:

import pandas as pd

# Load your dataset (adjust the path as needed)
data = pd.read_csv('/Users/aditya/ID Tech Python Files/ID Lab Tech Correct 1/Science Fair/lib/creditcard.csv')

I currently have creditcard.cvs put under the lib section on the branch sidebar thing

How do I solve the error message below?

Traceback (most recent call last):
  File "/Users/aditya/ID Tech Python Files/ID Lab Tech Correct 1/Science Fair/main.py", line 6, in <module>
    data = pd.read_csv('/Users/aditya/ID Tech Python Files/ID Lab Tech Correct 1/Science Fair/lib/creditcard.csv')
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aditya/ID Tech Python Files/ID Lab Tech Correct 1/Science Fair/.venv/lib/python3.11/site-packages/pandas/io/parsers/readers.py", line 1026, in read_csv
    return _read(filepath_or_buffer, kwds)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aditya/ID Tech Python Files/ID Lab Tech Correct 1/Science Fair/.venv/lib/python3.11/site-packages/pandas/io/parsers/readers.py", line 620, in _read
    parser = TextFileReader(filepath_or_buffer, **kwds)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aditya/ID Tech Python Files/ID Lab Tech Correct 1/Science Fair/.venv/lib/python3.11/site-packages/pandas/io/parsers/readers.py", line 1620, in __init__
    self._engine = self._make_engine(f, self.engine)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/aditya/ID Tech Python Files/ID Lab Tech Correct 1/Science Fair/.venv/lib/python3.11/site-packages/pandas/io/parsers/readers.py", line 1880, in _make_engine
    self.handles = get_handle(
                   ^^^^^^^^^^^
  File "/Users/aditya/ID Tech Python Files/ID Lab Tech Correct 1/Science Fair/.venv/lib/python3.11/site-packages/pandas/io/common.py", line 873, in get_handle
    handle = open(
             ^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/Users/aditya/ID Tech Python Files/ID Lab Tech Correct 1/Science Fair/lib/creditcard.csv'

Process finished with exit code 1
4
  • Try data = pd.read_csv('/Users/aditya/ID Tech Python Files/ID Lab Tech Correct 1/Science Fair/.venv/lib/creditcard.csv') Commented Mar 10 at 3:28
  • 1
    A FileNotFoundError exception is self-explanatory. The specified file does not exist at that location Commented Mar 10 at 8:13
  • Hi Aditya, welcome to SO. As @AdonBilivit mentioned, the error means that the filepath you provided doesn't exist. Perhaps use the method explained here to copy the absolute path to the csv file. Commented Mar 11 at 13:28
  • Per the comment # Load your dataset (adjust the path as needed), did you change the path from the original code? Commented Mar 11 at 15:05

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.