如何在没有查询字符串的情况下,按url对Pandas DataFrame进行分组?

问题描述 投票:0回答:1

我有一个Pandas DataFrame,结构是这样的。

+-------+------------+------------------------------------+----------+
| index |    Date    |                path                |  Count   |
+-------+------------+------------------------------------+----------+
|     0 | 2020-06-10 | about/v1/                          |    10865 |
|     1 | 2020-06-10 | about/v1/?status=active            |     2893 |
|     2 | 2020-06-10 | about/v1/?status=active?name=craig |      264 |
|     3 | 2020-06-09 | about/v1/?status=active?name=craig |      182 |
+-------+------------+------------------------------------+----------+

我如何按路径和日期分组,而不使用查询字符串,使表格看起来像这样?

+-------+------------+-------------------------+----------+
| index |    Date    |           path          |  Count   |
+-------+------------+-------------------------+----------+
|     0 | 2020-06-10 | about/v1/               |    10865 |
|     1 | 2020-06-10 | about/v1/?status=active |     3157 |
|     3 | 2020-06-09 | about/v1/?status=active |      182 |
+-------+------------+-------------------------+----------+
python pandas dataframe google-analytics-api
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.