Python错误总结
ImportError: cannot import name ‘Feature‘ from ‘setuptools
查阅相关文档发现是setuptool版本的问题,python3源中的setuptools已经升级到46以上,所以导致pip安装失败。
解决方案,更新setuptools版本
pip install --upgrade pip setuptools==45.2.0
ValueError: ZIP does not support timestamps before 1980
安装的库是“click-7.1.2",用的是python setup.py install命令安装
解决办法
用 pip 试试
pip install click==7.1.2
或用国内的镜像,速度比较快:
python -m pip install click==7.1.2 -i https://pypi.tuna.tsinghua.edu.cn/simple
Inconsistent use of tabs and spaces in indentation
写Python程序的时候遇到和tabs、indentation有关的错误十有八九是缩进出了问题。
有的解释器是会区分四个空格和一个tab的。有的时候从Git下载的代码常会出现这样的不匹配问题。
解决办法见:https://blog.csdn.net/hhy_csdn/article/details/82263757
No axis named 2 for object type DataFrame
错误原因,df.iloc[]是中括号,我错误使用了小括号,df.iloc()报错。
dtype: object' is not compatible with origin='1970-01-01 08:00:00'; it must be numeric with a unit specified
需要将日期转换为数字才能使用,代码如下
Dataframe['new_column']=pd.to_datetime(pd.to_numeric(Dataframe['column'],errors='coerce'),errors='coerce',origin='1899-12-30',unit='D')
答案来自:https://stackoverflow.com/questions/63753525/changing-a-column-to-datetime-format-with-specified-origin
ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().
解决方法:把条件表达式里面的 and和or改为&和|就行