visualize abundance problem

I use this command to visualize abundance using jyupiter lab but there is an error

pip install pandas
pip install altair
import pandas as pd
import altair as alt
from pathlib import Path
df_feature = pd.read_csv("../data/processed/feature-table.txt", sep="\t", skiprows=1)
df_feature

here is an error
FileNotFoundError Traceback (most recent call last)
Cell In[3], line 1
----> 1 df_feature = pd.read_csv("../data/processed/feature-table.txt", sep="\t", skiprows=1)
2 df_feature

File /usr/local/lib/python3.10/dist-packages/pandas/io/parsers/readers.py:948, in read_csv(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, date_format, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, encoding_errors, dialect, on_bad_lines, delim_whitespace, low_memory, memory_map, float_precision, storage_options, dtype_backend)
935 kwds_defaults = _refine_defaults_read(
936 dialect,
937 delimiter,
(...)
944 dtype_backend=dtype_backend,
945 )
946 kwds.update(kwds_defaults)
--> 948 return _read(filepath_or_buffer, kwds)

File /usr/local/lib/python3.10/dist-packages/pandas/io/parsers/readers.py:611, in _read(filepath_or_buffer, kwds)
608 _validate_names(kwds.get("names", None))
610 # Create the parser.
--> 611 parser = TextFileReader(filepath_or_buffer, **kwds)
613 if chunksize or iterator:
614 return parser

File /usr/local/lib/python3.10/dist-packages/pandas/io/parsers/readers.py:1448, in TextFileReader.init(self, f, engine, **kwds)
1445 self.options["has_index_names"] = kwds["has_index_names"]
1447 self.handles: IOHandles | None = None
-> 1448 self._engine = self._make_engine(f, self.engine)

File /usr/local/lib/python3.10/dist-packages/pandas/io/parsers/readers.py:1705, in TextFileReader._make_engine(self, f, engine)
1703 if "b" not in mode:
1704 mode += "b"
-> 1705 self.handles = get_handle(
1706 f,
1707 mode,
1708 encoding=self.options.get("encoding", None),
1709 compression=self.options.get("compression", None),
1710 memory_map=self.options.get("memory_map", False),
1711 is_text=is_text,
1712 errors=self.options.get("encoding_errors", "strict"),
1713 storage_options=self.options.get("storage_options", None),
1714 )
1715 assert self.handles is not None
1716 f = self.handles.handle

File /usr/local/lib/python3.10/dist-packages/pandas/io/common.py:863, in get_handle(path_or_buf, mode, encoding, compression, memory_map, is_text, errors, storage_options)
858 elif isinstance(handle, str):
859 # Check whether the filename is to be opened in binary mode.
860 # Binary mode does not support 'encoding' and 'newline'.
861 if ioargs.encoding and "b" not in ioargs.mode:
862 # Encoding
--> 863 handle = open(
864 handle,
865 ioargs.mode,
866 encoding=ioargs.encoding,
867 errors=errors,
868 newline="",
869 )
870 else:
871 # Binary mode
872 handle = open(handle, ioargs.mode)

FileNotFoundError: [Errno 2] No such file or directory: '../data/processed/feature-table.txt'

Click to add a cell.

Hi @sophiasalsabila,
The root of the problem is here at the top of the error message:

Pandas is unable to find the file using the path you provided. My advice is to use the complete file path in the pd.read_csv command and also double check that the file is actually where you think it is.
I hope this is helpful to you! let me know if you have any other questions.

-Hannah

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.