我的数据框来自于PostgreSQL数据库。dynamic_col的类型会从表格变成其他类型。我想要删除这个区域,所以我写了下面的代码,但是我得到了以下错误:
E TypeError: 'tzinfo' is an invalid keyword argument for this function
数据:
2019-09-21,
2012-10-09,
None,
2012-10-23
我的代码在这里
df[str(self.dynamic_col)] = df[str(self.dynamic_col)].apply(lambda x: x.replace(tzinfo=None) if isinstance(x, datetime.date) and x != 'None' else x)