我创建了如下数据帧:
+---------+--------+-----+-------------+
| VideoID | long | lat | viewerCount |
+---------+--------+-----+-------------+
| 123 | -1.1 | 1.1 | 25 |
+---------+--------+-----+-------------+
| 123 | -1.1 | 1.1 | 20 |
+---------+--------+-----+-------------+
videoIDs
是facebook视频直播的IDs
。而viewerCount
是观看它们的观众数量。
我每30秒添加一次刷新值。videoIDs
大部分是重复的,但是viewerCount
可以改变。
所以我尝试的是存储新的viewerCount
,但不复制videoid
(即:viewerCount现在不是一列,而是一个字典或序列)。像这样:
所以,在我回答你的问题之前,我有一个评论。除非您处理的是“大数据”(内存中连接操作的成本超过存储空间和可能的更新成本),否则建议您将表分成两部分。
-第一个将包含视频详细信息
Video_id*, longitude, latitude, location
-第二个表将包含
Video_id, refreshes and Views
是的。你知道吗
话虽如此,但要达成这一最终代表权,还有几个选择。我使用self的解决方案是将
Viewers_count
存储为列表。列表将是有益的,因为可以一起删除Num_refresh
,因为它可以从元素索引中重新计算。 在这种情况下,使用dict将是不必要的昂贵和复杂,但我也将添加语法。你知道吗更新:
您在注释中提到了迭代过程中嵌套列表的问题。可以用
np.hstack
替换list
。你知道吗相关问题 更多 >
编程相关推荐