【问题标题】:Cannot import name Label from pandas._typing无法从 pandas._typing 导入名称标签
【发布时间】:2021-10-29 23:51:04
【问题描述】:

我在尝试将数据框导出到 csv 文件时遇到了这个问题。 关于这个问题,我在网上找不到任何类似的问题。任何帮助将不胜感激。

我正在使用 pandas 1.3 和 python 3.7.1。


ImportError                               Traceback (most recent call last)
<timed exec> in <module>

/tmp/ipykernel_30888/2657956500.py in image_viewer(chunk_num, img_dir, chunk_size, zoom)
     89     df = df[~df.img_name.duplicated(keep='last')]
     90 
---> 91     df.to_csv(output_name, index=False)
     92 
     93     return df

~/.local/share/virtualenvs/labelvalidation-cagv8R9l/lib/python3.7/site-packages/pandas/core/generic.py in to_csv(self, path_or_buf, sep, na_rep, float_format, columns, header, index, index_label, mode, encoding, compression, quoting, quotechar, line_terminator, chunksize, date_format, doublequote, escapechar, decimal, errors, storage_options)
   3480             self._check_setitem_copy(stacklevel=5, t="referent")
   3481 
-> 3482         if clear:
   3483             self._clear_item_cache()
   3484 

~/.local/share/virtualenvs/labelvalidation-cagv8R9l/lib/python3.7/site-packages/pandas/io/formats/format.py in to_csv(self, path_or_buf, encoding, sep, columns, index_label, mode, compression, quoting, quotechar, line_terminator, chunksize, date_format, doublequote, escapechar, errors, storage_options)
   1076             quotechar=quotechar,
   1077             date_format=date_format,
-> 1078             doublequote=doublequote,
   1079             escapechar=escapechar,
   1080             storage_options=storage_options,

~/.local/share/virtualenvs/labelvalidation-cagv8R9l/lib/python3.7/site-packages/pandas/io/formats/csvs.py in <module>
     10 
     11 from pandas._libs import writers as libwriters
---> 12 from pandas._typing import (
     13     CompressionOptions,
     14     FilePathOrBuffer,

ImportError: cannot import name 'Label' from 'pandas._typing'

【问题讨论】:

  • 请显示您的代码,而不仅仅是错误
  • 或许可以快速重新安装? ImportError: cannot import ... 的类似错误似乎都暗示重新安装或升级或可能降级。示例:stackoverflow.com/questions/14422976/…

标签: pandas dataframe


【解决方案1】:

我已降级到 pandas 0.20.3,问题现在消失了!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-06-13
    • 2016-03-31
    • 2021-09-28
    • 2021-09-30
    • 2022-08-14
    • 2022-06-19
    • 2020-05-30
    • 1970-01-01
    相关资源
    最近更新 更多