我的<div>
<h1>view2</h1>
The value set in view1 is: <b ng-bind="vm.data"></b>
<input type="button"
class="btn btn-default"
value="Go to view1"
ui-sref="view1">
</div>
看起来像这样:
pd.DataFrame
我希望找到一种方法:
所需的输出如下所示:
In [30]: df
Out[30]:
DATES UID A
0 2014-01-01 1 False
1 2014-01-02 2 False
2 2014-01-03 3 True
3 2014-01-04 4 True
4 2014-01-05 5 False
5 2014-01-06 6 True
6 2014-01-07 1 False
7 2014-01-08 2 False
8 2014-01-09 3 False
9 2014-01-10 2 False
10 2014-01-11 3 False
11 2014-01-12 4 False
12 2014-01-13 5 False
13 2014-01-14 3 False
14 2014-01-15 1 False
非常感谢任何想法,谢谢!
答案 0 :(得分:1)
看起来需要先sort_values
然后filter
:
df.sort_values(by='DATES', inplace=True)
df = df.groupby('UID', sort=False).filter(lambda x: x.A.iloc[0] == True)
print (df)
DATES UID A
2 2014-01-03 3 True
3 2014-01-04 4 True
5 2014-01-06 6 True
8 2014-01-09 3 False
10 2014-01-11 3 False
11 2014-01-12 4 False
13 2014-01-14 3 False