####将结果存excel
1 | writer=pd.ExcelWriter(r'C://user/desktop') |
从excel读取数据
1 | pd.read_excel(r'C:\users\adminstrator\desktop',sheet_name='Sheet1') |
####从mysql读取数据
1 | conn=pymysql.connect(host='localhost',user='root',password='123456',databse='comp,port=3306) |
将DataFrame存入mysql
1 | from sqlalchemy import create_engine |
一条一条存入mysql
1 | db = pymysql.connect(host='localhost',port=3306,user='root',database='ceshi',password='123456',charset='utf8mb4') |
批量插入mysql
1 | db = pymysql.connect(host='localhost',port=3306,user='root',database='ceshi',password='123456',charset='utf8mb4') |
进程池代码
1 | pool = Pool(30) |
将一对多转换成多对多
1 | con2 = pymysql.connect(host="192.168.0.222", port=3306, user="user_r", password='1q2w3e4r', db='industry_cn_test',charset="utf8") |
####将df中某两列互换
1 | df = pd.DataFrame([[5,6],[4,3],[7,8]]) |
es返回不符合条件的个数
1 | es.search(index=['patent_cn_v71'],body={ |
连接250数据(读)
1 | conn1 = pymysql.connect(host='192.168.0.250',user='user_r',password='1q2w3e4r',database='pre_formal_2') |
####连接250高权限
1 | conn1=pymysql.connect(host='192.168.0.250',user='user_rwd_2',password='5d6f7g8h',database='pre_formal_2') |