【发布时间】:2018-03-13 13:57:26
【问题描述】:
我想做一些相当于
的事情Select x,y,z from data where f(x, Y);
而 f 是我自定义的函数,它查看一行中特定列的值并返回 True 或 False。我尝试了以下方法:
df = df.ix[_is_detection_in_window(df['Product'], df['CreatedDate'])== True]
但我明白了
TypeError: 'Series' objects are mutable, thus they cannot be hashed
我认为它不会遍历行。 我也试过了:
i = 0
for index, row in df.iterrows():
if _is_detection_in_window(row['Product'], row['CreatedDate']):
print 'in range '
new_df.iloc[i] = row
i+= 1
df = new_df
但我明白了:
IndexError: single positional indexer is out-of-bounds
【问题讨论】:
标签: python string pandas numpy dataframe