- 用法:- pandas.read_pickle(filepath_or_buffer, compression='infer', storage_options=None)
- 从文件中加载 pickle 的 Pandas 对象(或任何对象)。 - 警告 - 加载从不受信任的来源收到的 pickle 数据可能是不安全的。见这里。 - filepath_or_buffer:str、路径对象或 file-like 对象
- 字符串、路径对象(实现 - os.PathLike[str])或 file-like 对象实现二进制- readlines()函数。
- compression:str 或 dict,默认 ‘infer’
- 用于on-disk 数据的即时解压缩。如果 ‘infer’ 和 ‘filepath_or_buffer’ 是 path-like,则从以下扩展名检测压缩:“.gz”、“.bz2”、“.zip”、“.xz”或“.zst”(否则不压缩)。如果使用‘zip’,ZIP 文件必须只包含一个要读入的数据文件。设置为 - None不解压缩。也可以是键- 'method'设置为 {- 'zip',- 'gzip',- 'bz2',- 'zstd'} 之一的字典,其他键值对分别转发到- zipfile.ZipFile,- gzip.GzipFile,- bz2.BZ2File或- zstandard.ZstdDecompressor。例如,可以使用自定义压缩字典为 Zstandard 解压缩传递以下内容:- compression={'method': 'zstd', 'dict_data': my_compression_dict}。
- storage_options:字典,可选
- 对特定存储连接有意义的额外选项,例如主机、端口、用户名、密码等。对于 HTTP(S) URL,键值对作为标头选项转发到 - urllib。对于其他 URL(例如以 “s3://” 和 “gcs://” 开头),键值对被转发到- fsspec。有关详细信息,请参阅- fsspec和- urllib。
 
- unpickled:与存储在文件中的对象相同的类型
 
 - 参数:- 返回:- 注意:- read_pickle 仅保证向后兼容 pandas 0.20.3。 - 例子:- >>> original_df = pd.DataFrame({"foo": range(5), "bar": range(5, 10)}) >>> original_df foo bar 0 0 5 1 1 6 2 2 7 3 3 8 4 4 9 >>> pd.to_pickle(original_df, "./dummy.pkl")- >>> unpickled_df = pd.read_pickle("./dummy.pkl") >>> unpickled_df foo bar 0 0 5 1 1 6 2 2 7 3 3 8 4 4 9
相关用法
- Python pandas.read_hdf用法及代码示例
- Python pandas.read_xml用法及代码示例
- Python pandas.read_table用法及代码示例
- Python pandas.read_sql_table用法及代码示例
- Python pandas.read_excel用法及代码示例
- Python pandas.read_fwf用法及代码示例
- Python pandas.read_stata用法及代码示例
- Python pandas.read_sql用法及代码示例
- Python pandas.read_csv用法及代码示例
- Python pandas.read_html用法及代码示例
- Python pandas.read_json用法及代码示例
- Python pandas.arrays.IntervalArray.is_empty用法及代码示例
- Python pandas.DataFrame.ewm用法及代码示例
- Python pandas.api.types.is_timedelta64_ns_dtype用法及代码示例
- Python pandas.DataFrame.dot用法及代码示例
- Python pandas.DataFrame.apply用法及代码示例
- Python pandas.DataFrame.combine_first用法及代码示例
- Python pandas.Index.value_counts用法及代码示例
- Python pandas.DatetimeTZDtype用法及代码示例
- Python pandas.DataFrame.cumsum用法及代码示例
注:本文由纯净天空筛选整理自pandas.pydata.org大神的英文原创作品 pandas.read_pickle。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
