AttributeError:“内置函数”或“方法”对象没有属性“is_unique”

2024-10-01 15:30:31 发布

您现在位置:Python中文网/ 问答频道 /正文

我有以下数据帧:

df1

            NumOfTransactions  ComissionDeduction
2011-01-10                  2               19.90
2011-01-13                  2               19.90
2011-01-26                  1                9.95

df2

['2011-01-10']

我需要将这两个元素连接起来,这样当df1中的日期也在df2中时,我仍然保留该行。在

^{pr2}$

我正在尝试使用以下方法实现该功能:

impact = trades.index[trades.zero == total_columns].astype(str).tolist()
trades_impact = transactions.join(impact)

但是,我收到以下错误;AttributeError:'builtin_function_or_method'object has no attribute'is_unique'


Tags: columns数据方法功能元素indextradestotal
2条回答

df2似乎是一个日期列表,然后可以使用loc根据`df1的DateTimeIndex为行编制索引。在

r = transactions.loc[impact] 
print(r)

试试这个(用括号代替index的方括号):

impact = trades.index(trades.zero == total_columns).astype(str).tolist()
trades_impact = transactions.join(impact)

相关问题 更多 >

    热门问题