我有以下数据帧
teamId matchId matchPeriod eventSec eventId eventName
190 8516 5237840 1H 721.2 5 Interruption
191 8516 5237840 1H 723.4 3 Free Kick
192 8516 5237840 1H 725.7 8 Pass
193 8516 5237840 1H 727.2 8 Pass
194 8516 5237840 1H 728.5 10 Shot
这种情况持续了大约1000行
我想识别“Shot”的所有实例,然后切掉该行和前面的4行,创建一个序列,以便处理数据
有人能帮忙吗
请尝试以下代码: dta#您的数据帧
首先,它选择值为
'Shot'
的行的索引作为其列'eventName'
。然后,我们创建一个集合并迭代操作,以获得所选行之前的4行最后,我们将选择收集索引的行
似乎要在显示“Shot”的前四行中进行切片。您可以使用索引值查找“Shot”出现的位置,然后根据索引值对数据帧进行切片
将数据添加到数据帧:
然后切片数据并执行任务
相关问题 更多 >
编程相关推荐