Pandas

pandas 1.4.3 - pandas.read_pickle

Serieslearner 2022. 8. 29. 09:17
pandas.read_pickle(filepath_or_buffer, compression='infer', storage_options=None)

피클된 판다스 객체 (혹은 아무 객체)를 파일로부터 불러옵니다.

신뢰할 수 없는 피클 데이터를 불러오면 보안상 문제가 발생할 수 있습니다.

 

pickle — Python object serialization — Python 3.10.6 documentation

pickle — Python object serialization Source code: Lib/pickle.py The pickle module implements binary protocols for serializing and de-serializing a Python object structure. “Pickling” is the process whereby a Python object hierarchy is converted into

docs.python.org

파라미터

filepath_or_buffer: 문자열 및 경로 객체, 파일과 같은 객체가 들어갈 수 있습니다.

문자열 및 경로 객체에는 os.PathLike[str], 파일과 같은 객체는 이진 readlines() 함수를 활용할 수 있습니다.

 

compression: 문자열 혹은 딕셔너리 (기본값: infer)

on-the-fly 방식(프로그램을 재시작할 필요가 없는) 압축 해제에 사용됩니다. infer, filepath_or_buffer이 경로와 같다면 .gz, .bz2, .zip, .xz, .zst, (혹은 압축 없음) 확장자의 압축 형식을 감지합니다. .zip을 사용 중이라면 파일에는 읽어질 데이터 파일이 적어도 한 개 존재해야 합니다.

압축 해제를 할 필요가 없다면 None을 입력하세요.

해당 값은 또한 딕셔너리일 수도 있습니다. 이 딕셔너리의 키 값 method는 zip, gzip, bz2, zstd이어야만 합니다. 이들은 각자 zipfile.ZipFiile, gzip.GzipFile, bz2.BZ2File 혹은 zstandard.ZstdDecompressor로 전달됩니다. 예를 들어, compression={'method':'zstd', 'dict_data':my_comression_dict)은 직접 만든 압축의 딕셔너리를 사용한 Zstandard 압축 해제될 수 있습니다.

 

storage_options: 딕셔너리 (선택)

추가 옵션을 주어서 특별한 객체, 예를 들어 host, port, username, password를 다룰 수 있습니다.

HTTP(S) 주소의 키-값 쌍은 헤더 옵션으로 urllib로 전송됩니다. s3://, gcs://같은 주소들의 키-값 쌍은 fsspec로 전송됩니다. 이와 관련된 더 자세한 내용은 fsspec, urllib 문서에 있습니다.

'Pandas' 카테고리의 다른 글

pandas 1.4.3 - pandas.read_fwf  (0) 2022.08.29
pandas 1.4.3 - pandas.DataFrame.to_csv  (0) 2022.08.29
pandas 1.4.3 - pandas.read_csv  (0) 2022.08.29
pandas 1.4.3 - pandas.read_table  (0) 2022.08.29
pandas 1.4.3 - pandas.DataFrame.to_pickle  (0) 2022.08.29