### Install Development Dependencies with uv Source: https://github.com/songjian/cnstats/blob/main/README.md Use this command to install all necessary development dependencies for the project. ```bash uv sync ``` -------------------------------- ### Install cnstats with uv (Recommended) Source: https://github.com/songjian/cnstats/blob/main/README.md Install the cnstats package using uv, a fast Python package installer. This is the recommended method for installation. ```bash uv add cn-stats ``` -------------------------------- ### Get Help for Command-Line Usage Source: https://github.com/songjian/cnstats/blob/main/README.md Display the help message for the cnstats command-line interface to understand available options and arguments. Use 'uv run' for local development or direct 'python -m' invocation. ```bash # 如果是本地开发 uv run cnstats --help # 或者传统的直接调用 python -m cnstats --help ``` -------------------------------- ### Install cnstats with pip Source: https://github.com/songjian/cnstats/blob/main/README.md Install the cnstats package using pip. This is a standard way to add Python packages to your environment. ```bash pip install cn-stats ``` -------------------------------- ### Run Tests with uv Source: https://github.com/songjian/cnstats/blob/main/README.md Execute the project's tests using uv to manage the testing environment. ```bash uv run pytest ``` -------------------------------- ### Return Data as DataFrame in Python Source: https://github.com/songjian/cnstats/blob/main/README.md Fetch data and return it in a pandas DataFrame format by setting the as_df parameter to True. This allows for easy analysis with pandas. ```python from cnstats.stats import stats df = stats(zbcode='A010101', datestr='202201', as_df=True) # 这样可以直接使用 pandas 的功能进行后续分析和制图 print(df.head()) ``` -------------------------------- ### Query Multiple Months of Data via CLI Source: https://github.com/songjian/cnstats/blob/main/README.md Fetch data for multiple months by providing a comma-separated list of dates. The results will include entries for each specified month. ```bash $ uv run cnstats A0D01 202112,202201 +---------------------------------+----------+----------+------------+ | 指标名称 | 指标代码 | 查询日期 | 数值 | +---------------------------------+----------+----------+------------+ | 货币和准货币(M2)供应量_期末值 | A0D0101 | 202201 | 2431022.72 | | 货币和准货币(M2)供应量_期末值 | A010101 | 202112 | 2382899.56 | | 货币和准货币(M2)供应量_同比增长 | A010102 | 202201 | 9.8 | | 货币和准货币(M2)供应量_同比增长 | A010102 | 202112 | 9.0 | | 货币(M1)供应量_期末值 | A010103 | 202201 | 613859.35 | | 货币(M1)供应量_期末值 | A010103 | 202112 | 647443.35 | | 货币(M1)供应量_同比增长 | A010104 | 202201 | -1.9 | | 货币(M1)供应量_同比增长 | A010104 | 202112 | 3.5 | | 流通中现金(M0)供应量_期末值 | A010105 | 202201 | 106188.87 | | 流通中现金(M0)供应量_期末值 | A010105 | 202112 | 90825.15 | | 流通中现金(M0)供应量_同比增长 | A010106 | 202201 | 18.5 | | 流通中现金(M0)供应量_同比增长 | A010106 | 202112 | 7.7 | +---------------------------------+----------+----------+------------+ ``` -------------------------------- ### Query Multiple Months of City Data via CLI Source: https://github.com/songjian/cnstats/blob/main/README.md Fetch city-specific data for multiple months by providing the indicator code, date range, and region code. The output shows the indicator name, code, region, date, and value. ```bash $ uv run cnstats A010101 202201 --regcode 370200 +------------------------------------+----------+----------+----------+----------+-------+ | 指标名称 | 指标代码 | 地区名称 | 地区代码 | 查询日期 | 数值 | +------------------------------------+----------+----------+----------+----------+-------+ | 城市居民消费价格指数(上年同月=100) | A010101 | 青岛 | 370200 | 202201 | 101.3 | +------------------------------------+----------+----------+----------+----------+-------+ ``` -------------------------------- ### Explore Indicator Codes with --tree Source: https://github.com/songjian/cnstats/blob/main/README.md Use the --tree option to explore indicator codes and their sub-categories. This is useful for finding the correct codes, especially when categories change over time. ```bash # 查看分省月度数据库中 A0101 (居民消费价格指数) 下的子分类及其时间段说明 $ uv run cnstats A0101 --tree --dbcode fsyd ``` -------------------------------- ### Query Specific Data Point via CLI Source: https://github.com/songjian/cnstats/blob/main/README.md Use the command-line interface to fetch a specific data point by providing the indicator code and date. The output is displayed in a formatted table. ```bash $ uv run cnstats A0D01 202201 +---------------------------------+----------+----------+------------+ | 指标名称 | 指标代码 | 查询日期 | 数值 | +---------------------------------+----------+----------+------------+ | 货币和准货币(M2)供应量_期末值 | A0D0101 | 202201 | 2431022.72 | | 货币和准货币(M2)供应量_同比增长 | A010102 | 202201 | 9.8 | | 货币(M1)供应量_期末值 | A010103 | 202201 | 613859.35 | | 货币(M1)供应量_同比增长 | A010104 | 202201 | -1.9 | | 流通中现金(M0)供应量_期末值 | A010105 | 202201 | 106188.87 | | 流通中现金(M0)供应量_同比增长 | A010106 | 202201 | 18.5 | +---------------------------------+----------+----------+------------+ ``` -------------------------------- ### Query City Data in Python Source: https://github.com/songjian/cnstats/blob/main/README.md Query city-specific data by providing the indicator code, date string, region code (regcode), and database code (dbcode). ```python from cnstats.stats import stats result = stats(zbcode='A010101', datestr='202201', regcode='370200', dbcode='csyd') print(result) ``` -------------------------------- ### Query Multiple Months of Provincial Data via CLI Source: https://github.com/songjian/cnstats/blob/main/README.md Retrieve provincial data for multiple months by specifying the indicator code, date range, and region code. Note that for data from 2021 onwards, use the A01010B series codes. ```bash $ uv run cnstats A01010B01 202112,202201 --regcode 110000 +--------------------------------+-----------+----------+----------+----------+-------+ | 指标名称 | 指标代码 | 地区名称 | 地区代码 | 查询日期 | 数值 | +--------------------------------+-----------+----------+----------+----------+-------+ | 居民消费价格指数(上年同月=100) | A01010B01 | 北京市 | 110000 | 202201 | 101.3 | | 居民消费价格指数(上年同月=100) | A01010B01 | 北京市 | 110000 | 202112 | 101.8 | +--------------------------------+-----------+----------+----------+----------+-------+ ``` -------------------------------- ### Query Macroeconomic Data in Python Source: https://github.com/songjian/cnstats/blob/main/README.md Use the stats function to query macroeconomic data by specifying the indicator code (zbcode) and date string (datestr). ```python from cnstats.stats import stats result = stats(zbcode='A010101', datestr='202201') print(result) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.