Tushare Day3——了解stock_company并与stock_basic数据规模进行比较

本文通过Tushare库分别导入并分析了stock_company和stock_basic的数据,发现股票总数存在差异。经过对比和异常值检查,发现数据差异主要源于额外的行和可能的列信息不一致。分析过程包括分交易所导入数据、数据合并及异常情况的详细探讨。
摘要由CSDN通过智能技术生成

了解stock_company

1 stock_company的基本信息

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

2 由于导入限制,把股票分成上交所和深交所分别导入

# username = 'root'
# password = '000000'

import pandas as pd
import tushare as ts
# from sqlalchemy import create_engine 
# import pymysql
# pymysql.install_as_MySQLdb()

2.1 设置fields为交易所以外的信息

fields_list = ["ts_code", # 0 股票代码
          "exchange", # 1 交易所代码 SSE上交所 SZSE深交所
          "chairman", # 2 法人代表
          "manager", # 3 总经理
          "secretary", # 4 董秘
          "reg_capital", # 5 注册资本
          "setup_date", # 6 注册日期
          "province", # 7 所在省份
          "city", # 8 所在城市
          "introduction", # 9 公司介绍
          "website", # 10 公司主页
          "email", # 11 电子邮件
          "office", # 12 办公室
          "employees", # 13 员工人数
          "main_business", # 14 主要业务及产品
          "business_scope", # 15 经营范围
         ]
fields = 'ts_code,exchange,chairman,manager,secretary,reg_capital,setup_date,province,city,introduction,website,email,office,employees,main_business,business_scope'

2.2 导入股票信息

pro = ts.pro_api()

2.3 分别取出上交所和深交所的信息并以dataframe的形式保存

# 一次只能取4000条,所以根据交易所分批提取
df_SZSE = pro.stock_company(exchange='SZSE' # 交易所代码 SZSE深交所
                            ,fields=fields  # 如果这个fields不写会出错
                           )
df_SZSE.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 2437 entries, 0 to 2436
Data columns (total 16 columns):
 #   Column          Non-Null Count  Dtype  
---  ------          --------------  -----  
 0   ts_code         2437 non-null   object 
 1   exchange        2437 non-null   object 
 2   chairman        2436 non-null   object 
 3   manager         2408 non-null   object 
 4   secretary       2435 non-null   object 
 5   reg_capital     2437 non-null   float64
 6   setup_date      2437 non-null   object 
 7   province        2437 non-null   object 
 8   city            2437 non-null   object 
 9   introduction    2433 non-null   object 
 10  website         2401 non-null   object 
 11  email           2432 non-null   object 
 12  office          2437 non-null   object 
 13  business_scope  2437 non-null   object 
 14  employees       2434 non-null   float64
 15  main_business   2428 non-null   object 
dtypes: float64(2), object(14)
memory usage: 304.8+ KB
df_SSE = pro.stock_company(exchange='SSE' # 交易所代码 ,SSE上交所
#                            , fields=fields
                          )
df_SSE.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 1871 entries, 0 to 1870
Data columns (total 12 columns):
 #   Column       Non-Null Count  Dtype  
---  ------       --------------  -----  
 0   ts_code      1871 non-null   object 
 1   exchange     1871 non-null   object 
 2   chairman     1871 non-null   object 
 3   manager      1830 non-null   object 
 4   secretary    1868 non-null   object 
 5   reg_capital  1871 non-null   float64
 6   setup_date   1871 non-null   o
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值