Skip to content

Commit

Permalink
0.3.2
Browse files Browse the repository at this point in the history
  • Loading branch information
justinzm committed Feb 6, 2021
1 parent 23fc245 commit 4484ba2
Show file tree
Hide file tree
Showing 6 changed files with 316 additions and 65 deletions.
268 changes: 223 additions & 45 deletions .idea/workspace.xml

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ print(df)
- 货币供应量数据
- 外汇储备数据
- 货币汇率数据
- 工业增加值增长
- 财政收入
- 社会消费品零售总额
- 信贷数据
- 外商直接投资数据(FDI)
- 利率数据
- Shibor数据
- Shibor报价数据
Expand Down Expand Up @@ -102,7 +107,11 @@ print(df)


#### 版本更新


0.3.2
中国宏观数据: 工业增加值增长、财政收入、社会消费品零售总额、信贷数据、外商直接投资数据(FDI)
迭代百度迁入与迁出地详情

0.3.1
迭代微博数据采集

Expand Down
7 changes: 6 additions & 1 deletion gopup/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,12 @@
get_pmi,
get_rrr,
get_money_supply,
get_gold_and_foreign_reserves
get_gold_and_foreign_reserves,
get_industrial_growth,
get_fiscal_revenue,
get_consumer_total,
get_credit_data,
get_fdi_data
)


Expand Down
Binary file modified gopup/event/__pycache__/area_baidu.cpython-37.pyc
Binary file not shown.
35 changes: 17 additions & 18 deletions gopup/event/area_baidu.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def migration_area_baidu(area="武汉市", indicator="move_in", date="20200201")
return pd.DataFrame(json_data["data"]["list"])


def migration_scale_baidu(area="武汉市", indicator="move_out", start_date="20190112", end_date="20200201"):
def migration_scale_baidu(area="武汉市", indicator="move_out", date="20210112"):
"""
百度地图慧眼-百度迁徙-迁徙规模
* 迁徙规模指数:反映迁入或迁出人口规模,城市间可横向对比
Expand All @@ -65,9 +65,7 @@ def migration_scale_baidu(area="武汉市", indicator="move_out", start_date="20
:type area: str
:param indicator: move_in 迁入 move_out 迁出
:type indicator: str
:param start_date: 开始查询的日期 默认就可以
:type start_date: str
:param end_date: 结束查询的日期 20200101 以后的时间
:param date: 结束查询的日期 20200101 以后的时间
:type end_date: str
:return: 时间序列的迁徙规模指数
:rtype: pandas.DataFrame
Expand All @@ -77,24 +75,25 @@ def migration_scale_baidu(area="武汉市", indicator="move_out", start_date="20
"dt": "country",
"id": 0,
"type": indicator,
"startDate": start_date,
"endDate": end_date,
"date": date
}
else:
city_dict.update(province_dict)
inner_dict = dict(zip(city_dict.values(), city_dict.keys()))
if inner_dict[area] in province_dict.keys():
dt_flag = "province"
else:
dt_flag = "city"
try:
if inner_dict[area] in province_dict.keys():
dt_flag = "province"
else:
dt_flag = "city"

payload = {
"dt": dt_flag,
"id": inner_dict[area],
"type": indicator,
"startDate": start_date,
"endDate": end_date,
}
payload = {
"dt": dt_flag,
"id": inner_dict[area],
"type": indicator,
"date": date
}
except Exception as e:
return "省份 或者 具体城市名 错误"
url = "https://huiyan.baidu.com/migration/historycurve.jsonp"
r = requests.get(url, params=payload)
json_data = json.loads(r.text[r.text.find("({") + 1 : r.text.rfind(");")])
Expand All @@ -105,7 +104,7 @@ def migration_scale_baidu(area="武汉市", indicator="move_out", start_date="20


if __name__ == "__main__":
tmp = migration_scale_baidu(area="全国", indicator="move_in", start_date="20190112", end_date="20200201")
tmp = migration_scale_baidu(area="武汉", indicator="move_out")
print(tmp)


60 changes: 60 additions & 0 deletions gopup/life/train.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2021/2/5 0005
# @Author : justin.郑 [email protected]
# @File : train.py
# @Desc : 12306车站、车次数据

import json
import pandas as pd
import requests


def station_name():
"""
获取12306车站信息
Returns
-------
DataFrame
"拼音码、站名、电报码、拼音、首字母、ID""
"""
url = "https://kyfw.12306.cn/otn/resources/js/framework/station_name.js"
r = requests.get(url=url)
data_text = r.text
tmp_str = data_text[data_text.find("='")+3: -2]
tmp_list = tmp_str.split('@')
res_list = []
for li in tmp_list:
res_list.append(li.split('|'))
columns = ["拼音码", "站名", "电报码", "拼音", "首字母", "ID"]
data_df = pd.DataFrame(res_list, columns=columns)
data_df.set_index("ID", inplace=True)
return data_df


def train_list():
"""
获取12306车次信息
Returns
-------
DataFrame
"拼音码、站名、电报码、拼音、首字母、ID""
"""
url = "https://kyfw.12306.cn/otn/resources/js/query/train_list.js"
r = requests.get(url=url)
data_text = r.text
tmp_str = data_text[data_text.find("={")+1:]
tmp_dict = json.loads(tmp_str)['2019-07-16']
tmp_list = tmp_str.split('@')
res_list = []
for li in tmp_list:
res_list.append(li.split('|'))
columns = ["拼音码", "站名", "电报码", "拼音", "首字母", "ID"]
data_df = pd.DataFrame(res_list, columns=columns)
data_df.set_index("ID", inplace=True)
return data_df


if __name__ == '__main__':
tmp = train_list()
print(tmp)

0 comments on commit 4484ba2

Please sign in to comment.