答案 0 :(得分:0)
如果我没有误解您的要求,那么您可以尝试这种方式-
import pandas as pd
data = {'Hour': [1,1,1,1,2,1,3,3.5],'Revenue': ['£50','£45','£101','£98','£175','£10','£123','£95']}
df = pd.DataFrame(data)
df['Revenue'] = df['Revenue'].str[1:].astype(int)
hour_group = df.groupby('Hour').sum().reset_index()
res = hour_group[hour_group['Hour'] < 5.0]
#print(hour_group)
print(res)