Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
ak-quant committed Feb 8, 2022
2 parents 5514e21 + a26530a commit 4f3bdbc
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 21 deletions.
8 changes: 7 additions & 1 deletion akshare/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1828,9 +1828,10 @@
1.4.5 add: add index_pmi_com_cx interface
1.4.6 add: add index_pmi_man_cx interface
1.4.7 add: add index_pmi_ser_cx interface
1.4.8 add: add sport_olympic_winter_hist interface
"""

__version__ = "1.4.7"
__version__ = "1.4.8"
__author__ = "Albert King"

import sys
Expand All @@ -1841,6 +1842,11 @@

del sys

"""
冬奥会历届奖牌榜
"""
from akshare.sport.sport_olympic_winter import sport_olympic_winter_hist

"""
财新指数
"""
Expand Down
39 changes: 39 additions & 0 deletions akshare/sport/sport_olympic_winter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env python
# -*- coding:utf-8 -*-
"""
Date: 2022/2/8 17:14
Desc: 腾讯运动-冬奥会-历届奖牌榜
https://m.sports.qq.com/g/sv3/winter-oly22/winter-olympic-rank.htm?type=0
"""
import requests
import pandas as pd


def sport_olympic_winter_hist() -> pd.DataFrame:
"""
腾讯运动-冬奥会-历届奖牌榜
:return: 历届奖牌榜
:rtype: pandas.DataFrame
"""
url = "https://app.sports.qq.com/m/oly/historyMedal"
r = requests.get(url)
data_json = r.json()
temp_df = pd.DataFrame(data_json["data"]["list"])
temp_df = temp_df.explode("list")
temp_df["国家及地区"] = temp_df["list"].apply(lambda x: (x["noc"]))
temp_df["金牌数"] = temp_df["list"].apply(lambda x: (int(x["gold"])))
temp_df["总奖牌数"] = temp_df["list"].apply(lambda x: (int(x["total"])))
temp_df["举办年份"] = temp_df["year"].astype("str")
temp_df["届数"] = temp_df["no"].astype("str")
temp_df["举办地点"] = temp_df["country"]
temp_df = temp_df[["举办年份", "届数", "举办地点", "国家及地区", "金牌数", "总奖牌数"]]
temp_df = temp_df.replace("俄罗斯奥委会", "俄罗斯")
temp_df.reset_index(inplace=True)
temp_df["index"] = range(1, len(temp_df) + 1)
temp_df.rename(columns={"index": "序号"}, inplace=True)
return temp_df


if __name__ == "__main__":
sport_olympic_winter_hist_df = sport_olympic_winter_hist()
print(sport_olympic_winter_hist_df)
2 changes: 2 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -3069,4 +3069,6 @@ amac_manager_cancelled_info # 中国证券投资基金业协会-信息公示-诚
1.4.6 add: add index_pmi_man_cx interface
1.4.7 add: add index_pmi_ser_cx interface
1.4.8 add: add sport_olympic_winter_hist interface
```
95 changes: 75 additions & 20 deletions docs/data/others/others.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,34 +12,35 @@

输入参数

| 名称 | 类型 | 必选 | 描述 |
| -------- | ---- | ---- | --- |
| - | - | - | - |
| 名称 | 类型 | 描述 |
|-----|-----|-----|
| - | - | - |

输出参数-品牌

| 名称 | 类型 | 描述 |
| --------------- | ----- | ---------------- |
| id | int64 | 每个运动员的唯一ID |
| name | object | 运动员名字 |
| sex | object | 性别 |
| age | float64 | 年龄 |
| height | float64 | 身高 |
| weight | float64 | 体重 |
| team | object | 所代表的国家队 |
| noc | object | 国家奥委会3个字母的代码 |
| games | object | 年份与季节 |
| year | int64 | 比赛年份 |
| season | object | 比赛季节 |
| city | object | 举办城市 |
| sport | object | 运动类别 |
| event | object | 比赛项目 |
| medal | object | 奖牌 |
| 名称 | 类型 | 描述 |
|--------|---------|--------------|
| id | int64 | 每个运动员的唯一ID |
| name | object | 运动员名字 |
| sex | object | 性别 |
| age | float64 | 年龄 |
| height | float64 | 身高 |
| weight | float64 | 体重 |
| team | object | 所代表的国家队 |
| noc | object | 国家奥委会3个字母的代码 |
| games | object | 年份与季节 |
| year | int64 | 比赛年份 |
| season | object | 比赛季节 |
| city | object | 举办城市 |
| sport | object | 运动类别 |
| event | object | 比赛项目 |
| medal | object | 奖牌 |

接口示例

```python
import akshare as ak

sport_olympic_hist_df = ak.sport_olympic_hist()
print(sport_olympic_hist_df)
```
Expand Down Expand Up @@ -85,6 +86,60 @@ print(sport_olympic_hist_df)
271115 Bobsleigh Men's Four NaN
```

### 冬奥会历届奖牌榜

接口: sport_olympic_winter_hist

目标地址: https://m.sports.qq.com/g/sv3/winter-oly22/winter-olympic-rank.htm?type=0

描述: 腾讯运动-冬奥会-历届奖牌榜

限量: 单次返回 1924-2018 年度的冬奥会历届奖牌榜数据

输入参数

| 名称 | 类型 | 描述 |
|-----|-----|-----|
| - | - | - |

输出参数-品牌

| 名称 | 类型 | 描述 |
|-------|--------|-----|
| 序号 | int64 | - |
| 举办年份 | object | - |
| 届数 | object | - |
| 举办地点 | object | - |
| 国家及地区 | object | - |
| 金牌数 | int64 | - |
| 总奖牌数 | int64 | - |

接口示例

```python
import akshare as ak

sport_olympic_winter_hist_df = ak.sport_olympic_winter_hist()
print(sport_olympic_winter_hist_df)
```

数据示例

```
序号 举办年份 届数 举办地点 国家及地区 金牌数 总奖牌数
0 1 2018 23 平昌 挪威 14 39
1 2 2018 23 平昌 德国 14 31
2 3 2018 23 平昌 加拿大 11 29
3 4 2018 23 平昌 美国 9 23
4 5 2018 23 平昌 荷兰 8 20
.. ... ... .. ... ... ... ...
404 405 1924 1 霞慕尼 英国 1 4
405 406 1924 1 霞慕尼 瑞典 1 2
406 407 1924 1 霞慕尼 加拿大 1 1
407 408 1924 1 霞慕尼 法国 0 3
408 409 1924 1 霞慕尼 比利时 0 1
```

### 汽车销量排行

#### 乘联会-新能源细分市场
Expand Down
2 changes: 2 additions & 0 deletions docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -1014,6 +1014,8 @@
"index_neaw_cx" # 财新数据-指数报告-新经济行业入职平均工资水平
"index_awpr_cx" # 财新数据-指数报告-新经济入职工资溢价水平
"index_cci_cx" # 财新数据-指数报告-大宗商品指数
# 冬奥会
"sport_olympic_winter_hist" # 冬奥会-历届奖牌榜
```

## 案例演示
Expand Down

0 comments on commit 4f3bdbc

Please sign in to comment.