test.txt
๋ฐ test_รฉ.txt
๋ ๋์ผํ ํ์ผ์ด๋ฉฐ ์ด๋ฆ ๋ง ๋ณ๊ฒฝ๋ฉ๋๋ค.
pd.read_csv('test.txt')
Out[3]:
1 1 1
0 1 1 1
1 1 1 1
pd.read_csv('test_รฉ.txt')
Traceback (most recent call last):
File "<ipython-input-4-fd67679d1d17>", line 1, in <module>
pd.read_csv('test_รฉ.txt')
File "d:\app\python36\lib\site-packages\pandas\io\parsers.py", line 646, in parser_f
return _read(filepath_or_buffer, kwds)
File "d:\app\python36\lib\site-packages\pandas\io\parsers.py", line 389, in _read
parser = TextFileReader(filepath_or_buffer, **kwds)
File "d:\app\python36\lib\site-packages\pandas\io\parsers.py", line 730, in __init__
self._make_engine(self.engine)
File "d:\app\python36\lib\site-packages\pandas\io\parsers.py", line 923, in _make_engine
self._engine = CParserWrapper(self.f, **self.options)
File "d:\app\python36\lib\site-packages\pandas\io\parsers.py", line 1390, in __init__
self._reader = _parser.TextReader(src, **kwds)
File "pandas\parser.pyx", line 373, in pandas.parser.TextReader.__cinit__ (pandas\parser.c:4184)
File "pandas\parser.pyx", line 669, in pandas.parser.TextReader._setup_parser_source (pandas\parser.c:8471)
OSError: Initializing from file failed
Pandas๋ ํ์ผ ๊ฒฝ๋ก์ ์ ์ผํธ๊ฐ์๋ ํ์ผ์ ์ฝ์ผ๋ ค๊ณ ํ ๋ OSError๋ฅผ ๋ฐํํฉ๋๋ค.
๋ฌธ์ ๋ ์๋ก์ด ๊ฒ์ ๋๋ค (Python 3.6 ๋ฐ Pandas 0.19.2๋ก ์ ๊ทธ๋ ์ด๋ํ๊ธฐ ๋๋ฌธ์)
pd.show_versions()
์ปค๋ฐ : ์์
ํ์ด์ฌ : 3.6.0.final.0
ํ์ด์ฌ ๋นํธ : 64
์ด์์ฒด์ : Windows
OS ๋ฆด๋ฆฌ์ค : 7
๊ธฐ๊ณ : AMD64
ํ๋ก์ธ์ : Intel64 Family 6 Model 94 Stepping 3, GenuineIntel
byteorder : ์กฐ๊ธ
LC_ALL : ์์
LANG : fr
๋ก์ผ์ผ : ์์. ์์
ํ๋ค : 0.19.2
์ฝ : ์์
ํ : 9.0.1
setuptools : 32.3.1
์ฌ์ด ํค : 0.25.2
numpy : 1.11.3
scipy : 0.18.1
statsmodels : ์์
xarray : ์์
IPython : 5.1.0
์คํํฌ์ค : 1.5.1
patsy : ์์
dateutil : 2.6.0
pytz : 2016.10
blosc : ์์
๋ณ๋ชฉ ํ์ : 1.2.0
ํ
์ด๋ธ : ์์
numexpr : 2.6.1
matplotlib : 1.5.3
openpyxl : ์์
xlrd : ์์
xlwt : ์์
xlsxwriter : ์์
lxml : ์์
bs4 : ์์
html5lib : 0.999999999
httplib2 : ์์
apiclient : ์์
sqlalchemy : 1.1.4
pymysql : ์์
psycopg2 : ์์
jinja2 : 2.9.3
boto : ์์
pandas_datareader : ์์
๋ด ๋์ ๊ฐ์น๊ฐ ์์ต๋๋ค. Mac OSX ๋ฐ Ubuntu์์ ๋น ๋ฅด๊ฒ ์ฌ์ฉํด ๋ณด์์ต๋๋ค.
๋ฌธ์ . ์๋๋ฅผ ์ฐธ์กฐํ์ญ์์ค.
์ด๊ฒ์ด ํ๊ฒฝ / ํ๋ซํผ ๋ฌธ์ ์ผ๊น์? LOCALE
๊ฐ
None.None
ํฉ๋๋ค. ๋ถํํ๋ ๋๋ ์ด๊ฒ์ ์๋ ํ Windows ์์คํ
์ด ์์ต๋๋ค.
์. ์ธ์ ํ๋ฏ์ด ๋น์ ์ด ํ ๋ณธ ์ ์ด ์ด์ ๋ฅผ ์ค๋ช
ํ ๊ฒ
python3.6 ๋ฐ pandas 0.19.2๋ก ์
๊ทธ๋ ์ด๋ํ์ญ์์ค.
์ฐธ๊ณ : ๋ฐฉ๊ธ python3.6์ผ๋ก virtualenv๋ฅผ ์ค์ ํ๊ณ pip๋ฅผ ์ฌ์ฉํ์ฌ pandas 0.19.2๋ฅผ ์ค์นํ์ต๋๋ค.
>>> import pandas as pd
>>> pd.read_csv('test_รฉ.txt')
a b c
0 1 2 3
1 4 5 6
pd.show_versions ()์ ์ถ๋ ฅ
์ค์น๋ ๋ฒ์
์ปค๋ฐ : ์์
ํ์ด์ฌ : 3.6.0.final.0
ํ์ด์ฌ ๋นํธ : 64
์ด์์ฒด์ : Linux
OS ๋ฆด๋ฆฌ์ค : 4.4.0-57- ์ผ๋ฐ
์ปดํจํฐ : x86_64
ํ๋ก์ธ์ : x86_64
byteorder : ์กฐ๊ธ
LC_ALL : ์์
LANG : en_GB.UTF-8
๋ก์ปฌ : en_GB.UTF-8
ํ๋ค : 0.19.2
์ฝ : ์์
ํ : 9.0.1
setuptools : 32.3.1
Cython : ์์
numpy : 1.11.3
scipy : ์์
statsmodels : ์์
xarray : ์์
IPython : ์์
์คํํฌ์ค : ์์
patsy : ์์
dateutil : 2.6.0
pytz : 2016.10
blosc : ์์
๋ณ๋ชฉ ํ์ : ์์
ํ
์ด๋ธ : ์์
numexpr : ์์
matplotlib : ์์
openpyxl : ์์
xlrd : ์์
xlwt : ์์
xlsxwriter : ์์
lxml : ์์
bs4 : ์์
html5lib : ์์
httplib2 : ์์
apiclient : ์์
sqlalchemy : ์์
pymysql : ์์
psycopg2 : ์์
jinja2 : ์์
boto : ์์
pandas_datareader : ์์
3.6์ Windows์ ํ์ผ ์์คํ ์ธ์ฝ๋ฉ์ ascii์์ utf8๋ก ์ ํํ๋ค๊ณ ์๊ฐํฉ๋๋ค. ๊ทธ ์ธ์๋ 3.6 ์ฉ Windows์์๋ ์์ง ํ ์คํธ๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค (ํ์ํ ํจํค์ง ์ค ์ผ๋ถ๋ ์ด์ ๋ง ์ฌ์ฉ ๊ฐ๋ฅํ๊ธฐ ๋๋ฌธ์ ๋๋ค).
๋ฟก๋ฟก
๊ทธ๋์ 3.6์ ๋ํ appveyor (windows)์ ๋ํ ๋น๋ ์ง์์ ์ถ๊ฐ ํ์ผ๋ฏ๋ก ํ ์คํธ๋ฅผ ๋ฐ์ด์ ์๋ํ๋์ง ํ์ธํ๋ ๊ฒ์ด ์ข์ต๋๋ค.
ํ๋ก๊ทธ๋จ์ด pd.read_csv (file_path)์์ ์ค์ง๋์์ ๋๋ ๋์ผํ ๋ฌธ์ ์ ์ง๋ฉดํ์ต๋๋ค. ํ์ด์ฌ์ 3.6์ผ๋ก ์ ๊ทธ๋ ์ด๋ ํ ํ์ ์ํฉ์ ์ ์ ๋น์ทํฉ๋๋ค (๋ง์ง๋ง์ผ๋ก ์ค์น ํ ํ์ด์ฌ์ด ์ ํํ ์ด๋ค ๋ฒ์ ์ธ์ง, ์๋ง๋ 3.5 ...์ธ์ง ๋ชจ๋ฅด๊ฒ ์ต๋๋ค.).
@jreback ์ฌ๊ธฐ์ ์์ ์์ํ ๋ค์ ๋จ๊ณ๋ ๋ฌด์์
๋๊น?
'๋ ์๊ฐ'PR์ ๋ํด ์ธ๊ธํ์
จ์ต๋๋ค. ๊ทธ๊ฒ ๋ฌด์จ ๋ป์
๋๊น?
Windows๋ฅผ ์ฌ์ฉํ์ง ์๋ ๋์ ๋์์ ์ค ์ ์์ต๋๋ค (Windows์์ ์๋ํ์ง ์๋ ์ฝ๋๋ฅผ ๋๋ฒ๊น ํ๋ VM์ด โโ์์ต๋๋ค).
BTW, ํด๊ฒฐ ๋ฐฉ๋ฒ : ์ด๋ฆ ๋์ ํ์ผ ํธ๋ค ์ ๋ฌ
pd.read_csv(open('test_รฉ.txt', 'r'))
(๊ด๋ จ ๋ฌธ์ ์๋ ๋ช ๊ฐ์ง ํด๊ฒฐ ๋ฐฉ๋ฒ์ด ์์ง๋ง์ด ๋ฌธ์ ๋ ๋ณด์ง ๋ชปํ์ต๋๋ค)
@tpietruszka ๋ PR์ ๋ํ ์๊ฒฌ์ ์ฐธ์กฐํ์ญ์์ค : https://github.com/pandas-dev/pandas/pull/15092 (๊ฐ์ธ ํฌํฌ์์ ์ ๊ฑฐ๋์์ผ๋ฉฐ ๊ฑฐ์ โโ๊ฑฐ๊ธฐ์์์์ต๋๋ค).
๊ธฐ๋ณธ์ ์ผ๋ก wnidows์ py3.6 (๋ค๋ฅธ ํ์ด์ฌ๊ณผ ๋น๊ต)์์ ๊ฒฝ๋ก๋ฅผ ๋ค๋ฅด๊ฒ ์ธ์ฝ๋ฉํด์ผํฉ๋๋ค. ๊ธฐ๋ณธ์ ์ผ๋ก ๊ตฌํํด์ผํฉ๋๋ค : https://docs.python.org/3/whatsnew/3.6.html#pep -529-change-windows-filesystem-encoding-to-utf-8
๋ด ์ด์ ์ฝ๋ (์คํํ ์ ์์) :
import pandas as pd
import os
file_path='./dict/ๅญๅ
ธ.csv'
df_name = pd.read_csv(file_path,sep=',' )
์ ์ฝ๋ (์ฑ๊ณต) :
import pandas as pd
import os
file_path='./dict/dict.csv'
df_name = pd.read_csv(file_path,sep=',' )
์ด ๋ฒ๊ทธ๋ ํ์ผ ์ด๋ฆ ๋ฌธ์ ๋ผ๊ณ ์๊ฐํฉ๋๋ค.
์ค๊ตญ์ด์์ ์์ด๋ก ํ์ผ ์ด๋ฆ์ ๋ณ๊ฒฝํ๋ฉด ์ง๊ธ ์คํํ ์ ์์ต๋๋ค.
๋๊ตฐ๊ฐ๊ฐ ๊ฐ์ ๋ฌธ์ ๋ฅผ ๊ฒช์ ๊ธฐ ๋๋ฌธ์ ์ฌ๊ธฐ์ ์ค๋ฉด pandas๊ฐ pep 529์ ํจ๊ป ์๋ํ๋๋ก ์์ ๋ ๋๊น์ง ํด๊ฒฐ์ฑ ์ด ์์ต๋๋ค (๊ธฐ๋ณธ์ ์ผ๋ก ๋น ASCII ๋ฌธ์๋ ๊ฒฝ๋ก์ ์๊ฑฐ๋ ํ์ผ ์ด๋ฆ์ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค)
์ฝ๋ ์์ ๋ถ๋ถ์ ๋ค์ ๋ ์ค์ ์ฝ์ ํ์ฌ ์ฐฝ์์ ๊ฒฝ๋ก๋ฅผ ์ฒ๋ฆฌํ๋ ์ด์ ๋ฐฉ์์ผ๋ก ๋๋๋ฆฝ๋๋ค.
import sys
sys._enablelegacywindowsfsencoding()
์์ ์๋ฃจ์
์ ์ฌ์ฉํ๊ณ ์๋ํฉ๋๋ค. @fotisj ๋๋จํ ๊ฐ์ฌํฉ๋๋ค!
๊ทธ๋ฌ๋ DataFrame.to_csv ()๊ฐ ๋์ผํ ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ง ์๋ ์ด์ ์ ๋ํด ์ฌ์ ํ ํผ๋ ์ค๋ฝ์ต๋๋ค. ์ฆ, ์ ๋ ์ฝ๋ ํ์ผ ๊ฒฝ๋ก์ ๊ฒฝ์ฐ ์ฐ๊ธฐ๋ ๊ด์ฐฎ์ง ๋ง ์ฝ๊ธฐ๋ ๊ทธ๋ ์ง ์์ต๋๋ค.
path = os.path.join ( 'E : ่ฏญๆ', 'sina.csv')
pd.read_csv (open (path, 'r', encoding = 'utf8'))
์ฑ๊ณตํ์ต๋๋ค.
์ํฅ์๋ฐ๋ ์์คํ ์ ๊ฐ์ง ๋๊ตฐ๊ฐ๊ฐ์ด ๋ผ์ธ์ ๋ณ๊ฒฝํ๋์ง ํ์ธํ ์ ์์ต๋๊น?
...์
return _expand_user(os.fsencode(filepath_or_buffer)), None, compression
๊ณ ์ณ?
์๋ ๊ทธ๋ ์ง ์์.
๊ฒฐ๊ณผ : OSError : ์์ ํ์ผ ๊ฒฝ๋ก ์ด๋ฆ ๋๋ ํ์ผ๊ณผ ์ ์ฌํ ๊ฐ์ฒด,
(Windows 10)
OSError Traceback (most recent call last)
<ipython-input-2-e8247998d6d4> in <module>()
1
----> 2 df = pd.read_csv(r'D:\mydata\Dropbox\uni\progrs\test รถรคau\n\teu.csv', sep='\t')
C:\conda\lib\site-packages\pandas\io\parsers.py in parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, escapechar, comment, encoding, dialect, tupleize_cols, error_bad_lines, warn_bad_lines, skipfooter, skip_footer, doublequote, delim_whitespace, as_recarray, compact_ints, use_unsigned, low_memory, buffer_lines, memory_map, float_precision)
707 skip_blank_lines=skip_blank_lines)
708
--> 709 return _read(filepath_or_buffer, kwds)
710
711 parser_f.__name__ = name
C:\conda\lib\site-packages\pandas\io\parsers.py in _read(filepath_or_buffer, kwds)
447
448 # Create the parser.
--> 449 parser = TextFileReader(filepath_or_buffer, **kwds)
450
451 if chunksize or iterator:
C:\conda\lib\site-packages\pandas\io\parsers.py in __init__(self, f, engine, **kwds)
816 self.options['has_index_names'] = kwds['has_index_names']
817
--> 818 self._make_engine(self.engine)
819
820 def close(self):
C:\conda\lib\site-packages\pandas\io\parsers.py in _make_engine(self, engine)
1047 def _make_engine(self, engine='c'):
1048 if engine == 'c':
-> 1049 self._engine = CParserWrapper(self.f, **self.options)
1050 else:
1051 if engine == 'python':
C:\conda\lib\site-packages\pandas\io\parsers.py in __init__(self, src, **kwds)
1693 kwds['allow_leading_cols'] = self.index_col is not False
1694
-> 1695 self._reader = parsers.TextReader(src, **kwds)
1696
1697 # XXX
pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader.__cinit__()
pandas/_libs/parsers.pyx in pandas._libs.parsers.TextReader._setup_parser_source()
OSError: Expected file path name or file-like object, got <class 'bytes'> type
์, ์ฃ์กํฉ๋๋ค. fsdecode๊ฐ ๊ฑฐ๊ธฐ์์ ์๋ํฉ๋๊น?
๋ณด๋ธ ์ฌ๋ : Fotis Jannidis [email protected]
์ ์ก : 2018 ๋
2 ์ 3 ์ผ ํ ์์ผ ์ค์ 8:00:13
๋ฐ๋ ์ฌ๋ : pandas-dev / pandas
์ฐธ์กฐ : Tom Augspurger; ๋
ผํ
์ ๋ชฉ : Re : [pandas-dev / pandas] ํ์ผ ๊ฒฝ๋ก์ ์
์ผํธ๊ฐ์๋ ํ์ผ์ ์ฝ์ ๋ OSError ๋ฐ์ (# 15086)
์๋ ๊ทธ๋ ์ง ์์.
๊ฒฐ๊ณผ : OSError : ์์ ํ์ผ ๊ฒฝ๋ก ์ด๋ฆ ๋๋ ํ์ผ๊ณผ ์ ์ฌํ ๊ฐ์ฒด,
โ
๋๊ธ์ ๋ฌ์ ๊ธฐ ๋๋ฌธ์ ์์ ํ ๊ฒ์
๋๋ค.
์ด ์ด๋ฉ์ผ์ ์ง์ ๋ต์ฅํ๊ฑฐ๋ GitHub https://github.com/pandas-dev/pandas/issues/15086#issuecomment-362809602 ์์ ๋ณด๊ฑฐ๋ https://github.com/notifications/unsubscribe-auth/ ์ค๋ ๋๋ฅผ ์์๊ฑฐํฉ๋๋ค.
์๋์. fsdecode๋ฅผ ์ฌ์ฉํ๋ฉด ์๋ ์์๋ ๊ฒ๊ณผ ๋์ผํ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค ( error_msg.txt ).
์๋ํด ์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค.
๋ณด๋ธ ์ฌ๋ : Fotis Jannidis [email protected]
์ ์ก : 2018 ๋
2 ์ 3 ์ผ ํ ์์ผ ์ค์ 8:57:07
๋ฐ๋ ์ฌ๋ : pandas-dev / pandas
์ฐธ์กฐ : Tom Augspurger; ๋
ผํ
์ ๋ชฉ : Re : [pandas-dev / pandas] ํ์ผ ๊ฒฝ๋ก์ ์
์ผํธ๊ฐ์๋ ํ์ผ์ ์ฝ์ ๋ OSError ๋ฐ์ (# 15086)
์๋์. fsdecode๋ฅผ ์ฌ์ฉํ๋ฉด ์๋ ์์๋ ๊ฒ๊ณผ ๋์ผํ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค (error_msg.txt https://github.com/pandas-dev/pandas/files/1691837/error_msg.txt )
โ
๋๊ธ์ ๋ฌ์ ๊ธฐ ๋๋ฌธ์ ์์ ํ ๊ฒ์
๋๋ค.
์ด ์ด๋ฉ์ผ์ ์ง์ ๋ต์ฅํ๊ฑฐ๋ GitHub https://github.com/pandas-dev/pandas/issues/15086#issuecomment-362818153 ์์ ๋ณด๊ฑฐ๋ https://github.com/notifications/unsubscribe-auth/ ์ค๋ ๋๋ฅผ ์์๊ฑฐํฉ๋๋ค.
์ค๋ ์คํฐ๋ธ ๊ฒฐํผ ์ง์ฐธ๊ธ๊ณผ ์ด์ผ๊ธฐ, ๊ทธ๋์ด ๋ฌธ์ ๊ฐ ์ค ์ ์์ต๋๋ค ์์ฌ : https://github.com/pandas-dev/pandas/blob/e8f206d8192b409bc39da1ba1b2c5bcd8b65cc9f/pandas/_libs/src/parser/io.c#L30
IIUC, Windows ํ์ผ ์์คํ API๋ ์ด๋ฌํ ๋ฐ์ดํธ๊ฐ MBCS์์์ ๊ฒ์ผ๋ก ์์ํ์ง๋ง ์ฐ๋ฆฌ๋ utf-8์ ์ฌ์ฉํ๊ณ ์์ต๋๋ค.
์ฌ์ฉ์ ์์ค์ ํด๊ฒฐ ๋ฐฉ๋ฒ์ pandas์ ๋ฐ์ดํธ ๋ฌธ์์ด์ ์ ๋ฌํ๊ธฐ ์ ์ ํ์ผ ์ด๋ฆ์ mbcs๋ก ๋ช ์ ์ ์ผ๋ก ์ธ์ฝ๋ฉํ๋ ๊ฒ์ ๋๋ค. https://www.python.org/dev/peps/pep-0529/#explicitly -using-mbcs
pd.read_csv(filename.encode('mbcs'))
๋๊ตฌ๋ ์ง ๊ทธ ํด๊ฒฐ ๋ฐฉ๋ฒ์ ํ ์คํธ ํ ์ ์์ต๋๊น?
์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๊ธฐ ์ํด ํ์ ์ฝ๋์ ์ฝ๊ฐ์ ๋ณ๊ฒฝ์ด ํ์ํ์ง๋ง (PR์ด์ด ์์ ์ ์ํํ์ต๋๋ค) ์ญ์ ๋์์ต๋๋ค.
์๋ํ์ง ์๋ @TomAugspurger . read_csv๋ bytes
๊ฐ์ด ์๋๋ผ str
์์ํฉ๋๋ค. ๊ทธ๊ฒ์ ์คํจํฉ๋๋ค
OSError: Expected file path name or file-like object, got <class 'bytes'> type
ํ์ธํด ์ฃผ์ ์ ๊ฐ์ฌํฉ๋๋ค.
2018 ๋
4 ์ 20 ์ผ ๊ธ์์ผ ์คํ 3:43, Joรฃo D. Ferreira [email protected]
์ผ๋ค :
@TomAugspurger https://github.com/TomAugspurger ์๋ํ์ง ์์ต๋๋ค.
read_csv๋ ๋ฐ์ดํธ ๊ฐ์ด ์๋ str์ ์์ํฉ๋๋ค. ๊ทธ๊ฒ์ ์คํจํฉ๋๋คOSError : ์์๋๋ ํ์ผ ๊ฒฝ๋ก ์ด๋ฆ ๋๋ ํ์ผ๊ณผ ์ ์ฌํ ๊ฐ์ฒด์ ๋๋ค.
์ ํ โ
๋น์ ์ด ์ธ๊ธ ๋์๊ธฐ ๋๋ฌธ์ ์ด๊ฒ์ ๋ฐ๊ณ ์์ต๋๋ค.
์ด ์ด๋ฉ์ผ์ ์ง์ ๋ต์ฅํ๊ณ GitHub์์ ํ์ธํ์ธ์.
https://github.com/pandas-dev/pandas/issues/15086#issuecomment-383217062 ,
๋๋ ์ค๋ ๋ ์์๊ฑฐ
https://github.com/notifications/unsubscribe-auth/ABQHIiOHyt3sT7B0pHJuY5lB-cJtT5JHks5tqkiEgaJpZM4LeTSB
.
ํ๋งํ์ธ์-๊ฐ์ ๋ฌธ์ ๊ฐ ์์ต๋๋ค. ํด๊ฒฐ ๋ฐฉ๋ฒ์ ์ฌ์ฉํ๊ณ ์์ง๋ง ํ์ํ์ง ์์ ๊ฒฝ์ฐ์๋ ์ข์ ๊ฒ์ ๋๋ค.
์ปค๋ฎค๋ํฐ ํจ์น๊ฐ ํ์ํฉ๋๋ค
์ด ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ต๋๋ค. ๋๋ patchc๋ฅผ ์๋ํ๊ณ ๊ธฐ์ฌํ๊ณ ์ถ๋ค ์ด๊ฒ์ ์์ ํ๋ ๋ฐฉ๋ฒ์ ๋ํ ํฌ์ธํฐ๊ฐ ์์ต๋๊น?
๋๋ ์ด๊ฒ์ ์ฌํ ํ ์์๋ ์์คํ ์ ์ ๊ทผ ํ ์์๋ ๊ด๋ฆฌ์๊ฐ ์๋ค๊ณ ์๊ฐํ๋ค.
์๋ง๋์ด ๋ฌธ์ ์ ๋ค๋ฅธ ์ผ๋ถ๋ ํด๊ฒฐ์ฑ ์ ๋ชจ์ผ๋ ๋ฐ ๋์์ด ๋ ์ ์์ต๋๋ค.
์๋
ํ์ธ์, ์ง๊ธ pandas 1.0.3
์์์ด ๋ฌธ์ ๊ฐ ๋ฐ์ํ์ผ๋ฉฐ sys._enablelegacywindowsfsencoding()
ํด๊ฒฐ ๋ฐฉ๋ฒ์ด ์๋์ ๋ฉ์ท์ต๋๋ค. ํ์ผ ๊ฒฝ๋ก์ ฤ
๋ฐ ลบ
๊ฐ ์์ต๋๋ค.
์ด ์ค๋ฅ๋ pandas 0.25.3
ํ์ง๋ง 0.23.4
๋ ํด๊ฒฐ ๋ฐฉ๋ฒ์ ์ฌ์ฉํ ๋ ์ ๋๋ก ์๋ํ๋ ๊ฒ ๊ฐ์ต๋๋ค (๋ค๋ฅธ ๋ฒ์ ์ ํ์ธํ์ง ์์์ต๋๋ค). ์ถ๊ฐ ์ ๋ณด๋ฅผ ์ ๊ณตํด ๋๋ฆฌ๊ฒ ์ต๋๋ค.
ํ์ผ์ด ํ์ผ๊ณผ ๋์ผํ ํด๋ ์ด๋ฆ์ ์ ์ฅ๋ ๊ฒฝ์ฐ, ๊ฐ์ ํด๋ ์ด๋ฆ์์ ํ์ผ์ ์ ๊ฑฐํ์ญ์์ค.
ํด๋น ํด๋์์ ํ์ผ์ ์ ๊ฑฐํ๊ธฐ ๋งํ๋ฉด๋ฉ๋๋ค.
๋์ผํ ํด๋ ์ด๋ฆ์ ํ์ผ์ ์ ์ฅํ์ง ๋ง์ญ์์ค.
๊ทธ๋ฌ๋ฉด ์๋ํฉ๋๋ค
@pranjulknit ๋ด๊ฐ ์ดํดํ๋ค๋ฉด ๊ฒฝ๋ก์ ์ด๋ฌํ ๋ฌธ์ ๊ฐ์๋ ๋ฌธ์๊ฐ์๋ ํด๋๋ก ํ์ผ์ ์ด๋ํ๋ ๊ฒ์ด ์ข์ต๋๋ค. ์ด๊ฒ์ด ํญ์ ๊ฐ๋ฅํ ๊ฒ์ ์๋๋๋ค. ํด๋ ์ด๋ฆ๊ณผ ํ์ผ ์ด๋ฆ์ด ๋ฌ๋ผ์ผํ๋ค๊ณ ์ ์ํ๋ ๊ฒฝ์ฐ-์ด๊ฒ์ ์ฌ๊ธฐ์ ์ค๋ช ๋ ๋ฌธ์ ๊ฐ ์๋๋ฏ๋ก ๋ฌธ์ ๊ฐ ์์์ต๋๋ค.
์ค์ ๋ก jupyter ๋ ธํธ๋ถ์์ csv ํ์ผ์ ์ฝ๋ ๋์์ด ๋ฌธ์ ๊ฐ ์์ต๋๋ค.
๊ฐ์ฅ ์ ์ฉํ ๋๊ธ
๋๊ตฐ๊ฐ๊ฐ ๊ฐ์ ๋ฌธ์ ๋ฅผ ๊ฒช์ ๊ธฐ ๋๋ฌธ์ ์ฌ๊ธฐ์ ์ค๋ฉด pandas๊ฐ pep 529์ ํจ๊ป ์๋ํ๋๋ก ์์ ๋ ๋๊น์ง ํด๊ฒฐ์ฑ ์ด ์์ต๋๋ค (๊ธฐ๋ณธ์ ์ผ๋ก ๋น ASCII ๋ฌธ์๋ ๊ฒฝ๋ก์ ์๊ฑฐ๋ ํ์ผ ์ด๋ฆ์ ์ค๋ฅ๊ฐ ๋ฐ์ํฉ๋๋ค)
์ฝ๋ ์์ ๋ถ๋ถ์ ๋ค์ ๋ ์ค์ ์ฝ์ ํ์ฌ ์ฐฝ์์ ๊ฒฝ๋ก๋ฅผ ์ฒ๋ฆฌํ๋ ์ด์ ๋ฐฉ์์ผ๋ก ๋๋๋ฆฝ๋๋ค.