diff --git a/akshare/stock_feature/stock_ttm_lyr.py b/akshare/stock_feature/stock_ttm_lyr.py index cce86e301f1..3159ffd7fa2 100644 --- a/akshare/stock_feature/stock_ttm_lyr.py +++ b/akshare/stock_feature/stock_ttm_lyr.py @@ -5,6 +5,7 @@ Desc: 全部A股-等权重市盈率、中位数市盈率 https://www.legulegu.com/stockdata/a-ttm-lyr """ + import pandas as pd import requests @@ -26,15 +27,11 @@ def stock_a_ttm_lyr() -> pd.DataFrame: r = requests.get( url, params=params, - **get_cookie_csrf(url="https://www.legulegu.com/stockdata/a-ttm-lyr") + **get_cookie_csrf(url="https://www.legulegu.com/stockdata/a-ttm-lyr"), ) data_json = r.json() temp_df = pd.DataFrame(data_json["data"]) - temp_df["date"] = ( - pd.to_datetime(temp_df["date"], unit="ms", utc=True) - .dt.tz_convert("Asia/Shanghai") - .dt.date - ) + temp_df["date"] = pd.to_datetime(temp_df["date"], errors="coerce").dt.date return temp_df diff --git a/docs/data/stock/stock.md b/docs/data/stock/stock.md index d3ae3d96b9d..bf84f786eeb 100644 --- a/docs/data/stock/stock.md +++ b/docs/data/stock/stock.md @@ -15828,13 +15828,13 @@ print(stock_a_ttm_lyr_df) 2 2005-01-07 28.73 ... 0.66667 0.00 3 2005-01-10 28.84 ... 0.50000 0.00 4 2005-01-11 29.09 ... 1.00000 0.00 - ... ... ... ... ... -4680 2024-04-18 28.30 ... 0.03376 3569.80 -4681 2024-04-21 28.15 ... 0.03746 3541.66 -4682 2024-04-22 28.06 ... 0.03705 3530.90 -4683 2024-04-23 28.33 ... 0.04858 3506.22 -4684 2024-04-24 28.84 ... 0.06587 3521.62 -[4685 rows x 14 columns] +... ... ... ... ... ... +4795 2024-10-13 29.58 ... 0.15534 3887.17 +4796 2024-10-14 30.34 ... 0.20725 3961.34 +4797 2024-10-15 29.75 ... 0.18995 3855.99 +4798 2024-10-16 29.67 ... 0.20643 3831.59 +4799 2024-10-17 29.56 ... 0.20107 3788.22 +[4800 rows x 14 columns] ``` #### A 股等权重与中位数市净率