2017-10-16 160 views
0

我有以下的數據幀:AttributeError的: 'builtin_function_or_method' 對象沒有屬性 'is_unique'

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中。

NumOfTransactions ComissionDeduction 
    2011-01-10     2    19.90 

我試圖使用來實現該功能:

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

不過,我收到以下錯誤; AttributeError的:「builtin_function_or_method」對象有沒有屬性「is_unique」

+0

在你的情況下,使用'transactions.loc [影響]' –

回答

1

df2好像日期的列表,那麼你可以只使用loc根據`df1的DateTimeIndex索引行。

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

試試這個(括號而不是方括號中爲index):

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

FFR,嘗試把你的錯誤在谷歌。它無論如何給了我堆棧溢出問題,並且我在第三個結果中得到了這個答案:https://stackoverflow.com/a/27703120/5555637。 – combinatorist

+0

謝謝,我感謝你的幫助。我將在未來的場合記住這一點。 –

相關問題