擅长:python、mysql、java
<p>您可以解决:</p>
<ol>
<li>按门店代码、周/小时排序</li>
<li>按0筛选</li>
<li>按门店代码分组</li>
<li>找到连续的</li>
</ol>
<p>代码:</p>
<pre><code>t1 = df.sort_values(['store_code', 'week_hr'])
t2 = t1[t1['baskets'] == 0]
grouped = t2.groupby('store_code')['week_hr'].apply(lambda x: x.tolist())
for store_code, week_hrs in grouped.iteritems():
print(store_code, week_hrs)
# do something
</code></pre>