akshare 1.14.83__py3-none-any.whl → 1.14.84__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of akshare might be problematic. Click here for more details.

akshare/__init__.py CHANGED
@@ -2894,9 +2894,10 @@ amac_manager_cancelled_info # 中国证券投资基金业协会-信息公示-诚
2894
2894
  1.14.81 fix: fix stock_hsgt_hist_em interface
2895
2895
  1.14.82 fix: fix stock_comment_detail_scrd_desire_daily_em interface
2896
2896
  1.14.83 fix: fix stock_comment_detail_zhpj_lspf_em interface
2897
+ 1.14.84 fix: fix drewry_wci_index interface
2897
2898
  """
2898
2899
 
2899
- __version__ = "1.14.83"
2900
+ __version__ = "1.14.84"
2900
2901
  __author__ = "AKFamily"
2901
2902
 
2902
2903
  import sys
@@ -1,11 +1,12 @@
1
1
  #!/usr/bin/env python
2
2
  # -*- coding:utf-8 -*-
3
3
  """
4
- Date: 2023/9/30 15:30
4
+ Date: 2024/9/26 18:00
5
5
  Desc: Drewry 集装箱指数
6
6
  https://www.drewry.co.uk/supply-chain-advisors/supply-chain-expertise/world-container-index-assessed-by-drewry
7
7
  https://infogram.com/world-container-index-1h17493095xl4zj
8
8
  """
9
+
9
10
  import pandas as pd
10
11
  import requests
11
12
  from bs4 import BeautifulSoup
@@ -17,7 +18,8 @@ def drewry_wci_index(symbol: str = "composite") -> pd.DataFrame:
17
18
  """
18
19
  Drewry 集装箱指数
19
20
  https://infogram.com/world-container-index-1h17493095xl4zj
20
- :param symbol: choice of {"composite", "shanghai-rotterdam", "rotterdam-shanghai", "shanghai-los angeles", "los angeles-shanghai", "shanghai-genoa", "new york-rotterdam", "rotterdam-new york"}
21
+ :param symbol: choice of {"composite", "shanghai-rotterdam", "rotterdam-shanghai", "shanghai-los angeles",
22
+ "los angeles-shanghai", "shanghai-genoa", "new york-rotterdam", "rotterdam-new york"}
21
23
  :type symbol: str
22
24
  :return: Drewry 集装箱指数
23
25
  :rtype: pandas.DataFrame
@@ -34,24 +36,23 @@ def drewry_wci_index(symbol: str = "composite") -> pd.DataFrame:
34
36
  }
35
37
  url = "https://infogram.com/world-container-index-1h17493095xl4zj"
36
38
  r = requests.get(url)
37
- soup = BeautifulSoup(r.text, "lxml")
39
+ soup = BeautifulSoup(r.text, features="lxml")
38
40
  data_text = soup.find_all("script")[-4].string.strip("window.infographicData=")[:-1]
39
41
  data_json = demjson.decode(data_text)
40
- temp_df = pd.DataFrame(data_json["elements"][2]["data"][symbol_map[symbol]])
41
- temp_df = temp_df.iloc[1:, :]
42
+ data_json_need = data_json["elements"]["content"]["content"]["entities"][
43
+ "7a55585f-3fb3-44e6-9b54-beea1cd20b4d"
44
+ ]["data"][symbol_map[symbol]]
45
+ date_list = [item[0]["value"] for item in data_json_need[1:]]
46
+ try:
47
+ value_list = [item[1]["value"] for item in data_json_need[1:]]
48
+ except TypeError:
49
+ value_list = [item[1]["value"] for item in data_json_need[1:-1]]
50
+ temp_df = pd.DataFrame([date_list, value_list]).T
42
51
  temp_df.columns = ["date", "wci"]
43
- temp_df["date"] = [item["value"] for item in temp_df["date"]]
44
- temp_df["wci"] = [item["value"] for item in temp_df["wci"]]
45
- day = temp_df["date"].str.split("-", expand=True).iloc[:, 0].str.strip()
46
- month = temp_df["date"].str.split("-", expand=True).iloc[:, 1].str.strip()
47
- month = month.str.replace("July", "Jul")
48
- year = temp_df["date"].str.split("-", expand=True).iloc[:, 2].str.strip()
49
- temp_df["date"] = day + "-" + month + "-" + year
50
- # 修正数据源中日期格式的错误
51
- temp_df["date"] = temp_df["date"].str.replace("Sept", "Sep")
52
- temp_df["date"] = pd.to_datetime(temp_df["date"], format="%d-%b-%y").dt.date
52
+ temp_df["date"] = pd.to_datetime(
53
+ temp_df["date"], format="%d-%b-%y", errors="coerce"
54
+ ).dt.date
53
55
  temp_df["wci"] = pd.to_numeric(temp_df["wci"], errors="coerce")
54
- temp_df.reset_index(inplace=True, drop=True)
55
56
  return temp_df
56
57
 
57
58
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: akshare
3
- Version: 1.14.83
3
+ Version: 1.14.84
4
4
  Summary: AKShare is an elegant and simple financial data interface library for Python, built for human beings!
5
5
  Home-page: https://github.com/akfamily/akshare
6
6
  Author: AKFamily
@@ -1,4 +1,4 @@
1
- akshare/__init__.py,sha256=v1djGYu5jiEil9ma7vQW1ZEI5OGAzCvwScZtalakaEA,181980
1
+ akshare/__init__.py,sha256=siaAbZ64GnNdzkScy_hOfwhcG3zhBZGLWEgWtD90PLA,182024
2
2
  akshare/datasets.py,sha256=-qdwaQjgBlftX84uM74KJqCYJYkQ50PV416_neA4uls,995
3
3
  akshare/air/__init__.py,sha256=RMTf1bT5EOE3ttWpn3hGu1LtUmsVxDoa0W7W0gXHOy8,81
4
4
  akshare/air/air_hebei.py,sha256=xIXNGLK7IGYqrkteM9fxnHAwWqk6PCQs6D9-ggZ7byY,4442
@@ -158,7 +158,7 @@ akshare/index/index_cflp.py,sha256=iPn_0kePK74eScwC7rj0IhC-3w-kGQWtWlwsW-J0nbs,4
158
158
  akshare/index/index_cni.py,sha256=qravLXiETWlegIMV_EIUTDbGQfdC2zsj4LykWzC8Lko,8563
159
159
  akshare/index/index_cons.py,sha256=3jrDfdxhNr9c4NVsTVOyORZwKBFNUU8giERYoIKkUUY,7682
160
160
  akshare/index/index_cx.py,sha256=aAmsIKkswKFNOhAsW0QOhp-q6q1aFOSBtqcDaZhIh6A,16775
161
- akshare/index/index_drewry.py,sha256=PR38IXgKH5q_d5uli12Q_T4Y8cKlRO576uINehPWjgg,3175
161
+ akshare/index/index_drewry.py,sha256=BM7V6P8K4QUFQArsdaWRu5qJUZaCoyNz97_b8dmLeCw,2937
162
162
  akshare/index/index_eri.py,sha256=7X0KNDBntEkE_qSb2jb6IBv-S8PsevLFdxGT8nKT3W0,2111
163
163
  akshare/index/index_fear_greed_funddb.py,sha256=7Z6GqYkKPJHNHMEN-uZNu2KnNNLTWvJcVlYpfAShJJc,2378
164
164
  akshare/index/index_hog.py,sha256=kb867BVagt70_ycZMn22ks5Z9jlVbMiuTsvq5ygjeig,1657
@@ -380,8 +380,8 @@ akshare/utils/token_process.py,sha256=K4rGXjh_tgugbRcyOK2h2x0jP3PT65IIK7nxhUKhOe
380
380
  akshare/utils/tqdm.py,sha256=MuPNwcswkOGjwWQOMWXi9ZvQ_RmW4obCWRj2i7HM7FE,847
381
381
  tests/__init__.py,sha256=gNzhlO0UPjFq6Ieb38kaVIODXv4cTDByrdohAZnDYt4,82
382
382
  tests/test_func.py,sha256=j1MGYbZI2if2j_LY1S4FLsf4qfq4NwVqD5wmRlv5Log,832
383
- akshare-1.14.83.dist-info/LICENSE,sha256=mmSZCPgfHiVw34LXuFArd-SUgQtBJ_QsIlh-kWlDHfs,1073
384
- akshare-1.14.83.dist-info/METADATA,sha256=BgXgO3hfQV-aAfR1uj9vOtTJlQYU5OLr-4E7GKknYg4,14112
385
- akshare-1.14.83.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
386
- akshare-1.14.83.dist-info/top_level.txt,sha256=jsf9ZzZPmHaISTVumQPsAw7vv7Yv-PdEVW70SMEelQQ,14
387
- akshare-1.14.83.dist-info/RECORD,,
383
+ akshare-1.14.84.dist-info/LICENSE,sha256=mmSZCPgfHiVw34LXuFArd-SUgQtBJ_QsIlh-kWlDHfs,1073
384
+ akshare-1.14.84.dist-info/METADATA,sha256=dQ1bPRyg9ju6jfQG2hSJhIVA-I7jQLjs20dPBY1Jm0s,14112
385
+ akshare-1.14.84.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
386
+ akshare-1.14.84.dist-info/top_level.txt,sha256=jsf9ZzZPmHaISTVumQPsAw7vv7Yv-PdEVW70SMEelQQ,14
387
+ akshare-1.14.84.dist-info/RECORD,,