cff_copy['weekday_received']=cff_copy['Date_received'].apply(lambda x:x.isoweekday())报错了:'float' object has no attribute 'isoweekday',如何解决?
时间: 2023-06-10 20:05:51 浏览: 57
这个报错是因为 'Date_received' 列中含有 NaN 值,导致 lambda 函数返回的是 float 类型,并且 float 类型没有 'isoweekday' 方法。可以使用 pd.to_datetime() 函数将 ‘Date_received’ 列中的时间格式化,并将 NaN 值填充为 pd.NaT(pandas 中的 NaT 表示缺失值),如下所示:
```
import pandas as pd
import numpy as np
cff_copy['Date_received'] = pd.to_datetime(cff_copy['Date_received'], errors='coerce')
cff_copy['weekday_received'] = cff_copy['Date_received'].apply(lambda x: x.isoweekday() if not pd.isna(x) else np.nan)
```
这样就可以避免 NaN 值导致的报错了。
相关问题
<generator object Tag._all_strings at 0x0000021CFF4F6970>
This error message is not very informative and it's hard to determine the context in which it occurred. However, it seems to be related to the use of a generator object named `Tag._all_strings`.
A generator object is an iterable that generates a sequence of values on-the-fly, as opposed to generating them all at once and storing them in memory. In this case, it seems that the `Tag` class has a method or attribute named `_all_strings` that returns a generator object.
Without more context, it's difficult to say what might be causing the error. It could be that the generator object is being used improperly, or that there is a bug in the implementation of the `Tag` class that is causing the generator to fail.
freetype-2.8-14.el7.x86_64.rpm
freetype-2.8-14.el7.x86_64.rpm 是一个Linux下的软件包,用于安装 FreeType 字体渲染引擎的版本为2.8-14。
FreeType 是一个广泛使用的开源字体渲染引擎,被用于许多操作系统和应用程序中,包括Linux。它可以将字体数据转化为位图和轮廓描述,用于显示字体在屏幕上。它支持多种字体格式,包括TrueType、OpenType、Type 1、CID-keyed、CFF和PFR字体。通过使用FreeType,开发人员可以在应用程序中进行高质量的字体渲染,增强用户界面的美观性和显示效果。
通过安装这个rpm软件包,您可以在您的Linux系统上安装最新版本的 FreeType 字体渲染引擎。这将使得您的系统能够更好地渲染和显示各种字体,包括不同字体格式和特殊效果。这对于那些需要对字体进行详细控制并提升用户体验的开发人员和设计师来说非常有用。
如果您对字体渲染感兴趣,或者希望改善您的Linux系统的字体显示效果,您可以考虑安装这个rpm软件包。安装方法可以参考您所使用的Linux发行版的文档或者在终端命令行中使用适当的命令进行安装。
总之,freetype-2.8-14.el7.x86_64.rpm 是一个提供最新版本 FreeType 字体渲染引擎的rpm软件包,它可以在Linux系统上帮助您改善字体的显示效果,提升用户体验和界面美观性。