鱼C论坛

 找回密码
 立即注册
查看: 3216|回复: 7

将数据类型为时间time 06:00:00的数据变成可计算的6

[复制链接]
发表于 2021-11-7 04:33:04 | 显示全部楼层 |阅读模式
3鱼币
我想要将数据类型为时间time 06:00:00的数据变成可计算的6怎么弄啊?

大概这样 我想要计算它的mean
同时和前面的年份groupby一下

time                                                url  
0     06:00:00  http://en.wikipedia.org/wiki/2009_Australian_G...  
1     09:00:00  http://en.wikipedia.org/wiki/2009_Malaysian_Gr...  
2     07:00:00  http://en.wikipedia.org/wiki/2009_Chinese_Gran...  
3     12:00:00  http://en.wikipedia.org/wiki/2009_Bahrain_Gran...  
4     12:00:00  http://en.wikipedia.org/wiki/2009_Spanish_Gran...  
...        ...                                                ...  
1053  19:00:00  http://en.wikipedia.org/wiki/2021_United_State...  
1054  19:00:00  http://en.wikipedia.org/wiki/2021_Mexican_Gran...  
1055  17:00:00  http://en.wikipedia.org/wiki/2021_Brazilian_Gr...  
1056  16:00:00  http://en.wikipedia.org/wiki/2021_Saudi_Arabia...  
1057  13:00:00  http://en.wikipedia.org/wiki/2021_Abu_Dhabi_Gr...  

想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2021-11-7 04:33:59 | 显示全部楼层
  raceId  year  round  circuitId                      name        date  \
0          1  2009      1          1     Australian Grand Prix  2009-03-29   
1          2  2009      2          2      Malaysian Grand Prix  2009-04-05   
2          3  2009      3         17        Chinese Grand Prix  2009-04-19   
3          4  2009      4          3        Bahrain Grand Prix  2009-04-26   
4          5  2009      5          4        Spanish Grand Prix  2009-05-10   
...      ...   ...    ...        ...                       ...         ...   
1053    1069  2021     18         69  United States Grand Prix  2021-10-24   
1054    1070  2021     19         32    Mexico City Grand Prix  2021-10-31   
1055    1071  2021     20         18      Brazilian Grand Prix  2021-11-07   
1056    1072  2021     22         77  Saudi Arabian Grand Prix  2021-12-05   
1057    1073  2021     23         24      Abu Dhabi Grand Prix  2021-12-12   
前面是这样 我需要做一个 area plot 求助
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2021-11-7 13:30:58 | 显示全部楼层
你这是电子表格还是数据库 看一下字段类型是字符串吗  
电子表格公式不够用的话内置vb处理
数据库SQL server mysql Oracle之间差别很大要对应的方言去处理时间
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2021-11-7 14:12:53 | 显示全部楼层
kogawananari 发表于 2021-11-7 13:30
你这是电子表格还是数据库 看一下字段类型是字符串吗  
电子表格公式不够用的话内置vb处理
数据库SQL ser ...

文字类型是字符object,
数据是电子表格csv格式
运用的jupyter notebook的python
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2021-11-7 14:14:18 | 显示全部楼层
raceId  year  round  circuitId                      name        date  \
0          1  2009      1          1     Australian Grand Prix  2009-03-29   
1          2  2009      2          2      Malaysian Grand Prix  2009-04-05   
2          3  2009      3         17        Chinese Grand Prix  2009-04-19   
3          4  2009      4          3        Bahrain Grand Prix  2009-04-26   
4          5  2009      5          4        Spanish Grand Prix  2009-05-10   
...      ...   ...    ...        ...                       ...         ...   
1053    1069  2021     18         69  United States Grand Prix  2021-10-24   
1054    1070  2021     19         32    Mexico City Grand Prix  2021-10-31   
1055    1071  2021     20         18      Brazilian Grand Prix  2021-11-07   
1056    1072  2021     22         77  Saudi Arabian Grand Prix  2021-12-05   
1057    1073  2021     23         24      Abu Dhabi Grand Prix  2021-12-12   

          time                                                url  
0     06:00:00  http://en.wikipedia.org/wiki/2009_Australian_G...  
1     09:00:00  http://en.wikipedia.org/wiki/2009_Malaysian_Gr...  
2     07:00:00  http://en.wikipedia.org/wiki/2009_Chinese_Gran...  
3     12:00:00  http://en.wikipedia.org/wiki/2009_Bahrain_Gran...  
4     12:00:00  http://en.wikipedia.org/wiki/2009_Spanish_Gran...  
...        ...                                                ...  
1053  19:00:00  http://en.wikipedia.org/wiki/2021_United_State...  
1054  19:00:00  http://en.wikipedia.org/wiki/2021_Mexican_Gran...  
1055  17:00:00  http://en.wikipedia.org/wiki/2021_Brazilian_Gr...  
1056  16:00:00  http://en.wikipedia.org/wiki/2021_Saudi_Arabia...  
1057  13:00:00  http://en.wikipedia.org/wiki/2021_Abu_Dhabi_Gr...  

[1058 rows x 8 columns]
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2021-11-7 14:15:01 | 显示全部楼层
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 1058 entries, 0 to 1057
Data columns (total 8 columns):
#   Column     Non-Null Count  Dtype
---  ------     --------------  -----
0   raceId     1058 non-null   int64
1   year       1058 non-null   int64
2   round      1058 non-null   int64
3   circuitId  1058 non-null   int64
4   name       1058 non-null   object
5   date       1058 non-null   object
6   time       1058 non-null   object
7   url        1058 non-null   object
dtypes: int64(4), object(4)
memory usage: 66.2+ KB
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

发表于 2021-11-7 14:38:05 | 显示全部楼层
说groupby我还以为是sql数据库  pandas没玩过
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

 楼主| 发表于 2021-11-7 15:20:11 | 显示全部楼层
kogawananari 发表于 2021-11-7 14:38
说groupby我还以为是sql数据库  pandas没玩过

太难了 学不来5555
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-6-27 03:57

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表