Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pivot table module error while reading gdp.csv #1

Open
ArcusConsulting opened this issue Dec 3, 2021 · 4 comments
Open

Pivot table module error while reading gdp.csv #1

ArcusConsulting opened this issue Dec 3, 2021 · 4 comments

Comments

@ArcusConsulting
Copy link

I get the following error after I run pd.read_csv('gdp.csv'). I even copied the code directly from GitHub:

UnicodeDecodeError Traceback (most recent call last)
C:\Users\LECLER~1\AppData\Local\Temp/ipykernel_18476/2984350304.py in
----> 1 df_gdp = pd.read_csv('gdp.csv')
2 df_gdp

~\Anaconda3\lib\site-packages\pandas\util_decorators.py in wrapper(*args, **kwargs)
309 stacklevel=stacklevel,
310 )
--> 311 return func(*args, **kwargs)
312
313 return wrapper

~\Anaconda3\lib\site-packages\pandas\io\parsers\readers.py in read_csv(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, 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, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, encoding_errors, dialect, error_bad_lines, warn_bad_lines, on_bad_lines, delim_whitespace, low_memory, memory_map, float_precision, storage_options)
584 kwds.update(kwds_defaults)
585
--> 586 return _read(filepath_or_buffer, kwds)
587
588

~\Anaconda3\lib\site-packages\pandas\io\parsers\readers.py in _read(filepath_or_buffer, kwds)
480
481 # Create the parser.
--> 482 parser = TextFileReader(filepath_or_buffer, **kwds)
483
484 if chunksize or iterator:

~\Anaconda3\lib\site-packages\pandas\io\parsers\readers.py in init(self, f, engine, **kwds)
809 self.options["has_index_names"] = kwds["has_index_names"]
810
--> 811 self._engine = self._make_engine(self.engine)
812
813 def close(self):

~\Anaconda3\lib\site-packages\pandas\io\parsers\readers.py in _make_engine(self, engine)
1038 )
1039 # error: Too many arguments for "ParserBase"
-> 1040 return mapping[engine](self.f, **self.options) # type: ignore[call-arg]
1041
1042 def _failover_to_python(self):

~\Anaconda3\lib\site-packages\pandas\io\parsers\c_parser_wrapper.py in init(self, src, **kwds)
67 kwds["dtype"] = ensure_dtype_objs(kwds.get("dtype", None))
68 try:
---> 69 self._reader = parsers.TextReader(self.handles.handle, **kwds)
70 except Exception:
71 self.handles.close()

~\Anaconda3\lib\site-packages\pandas_libs\parsers.pyx in pandas._libs.parsers.TextReader.cinit()

~\Anaconda3\lib\site-packages\pandas_libs\parsers.pyx in pandas._libs.parsers.TextReader._get_header()

~\Anaconda3\lib\site-packages\pandas_libs\parsers.pyx in pandas._libs.parsers.TextReader._tokenize_rows()

~\Anaconda3\lib\site-packages\pandas_libs\parsers.pyx in pandas._libs.parsers.raise_parser_error()

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xf4 in position 20740: invalid continuation byte

@ArcusConsulting
Copy link
Author

My csv file is in the same folder as my program. Not sure what is happening. I am able to read the other files in this course, except for gdp.csv.

@thepycoach
Copy link
Owner

My csv file is in the same folder as my program. Not sure what is happening. I am able to read the other files in this course, except for gdp.csv.

Hi!

Try this: df_gdp = pd.read_csv("gdp.csv" , encoding="latin-1")

Let me know if that works.

@ArcusConsulting
Copy link
Author

Worked; thanks!

@Joseyboboye33
Copy link

My csv file is in the same folder as my program. Not sure what is happening. I am able to read the other files in this course, except for gdp.csv.

Hi!

Try this: df_gdp = pd.read_csv("gdp.csv" , encoding="latin-1")

Let me know if that works.

Oops🥲...literally thinking the error can from my ends😂.
Thanks it worked out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants