How to change from one line to multiple lines in Mysql
This article introduces the relevant knowledge of "how to turn Mysql into multiple lines". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Read data # data read
Import pandas as pd
Df= pd.read_excel ('. / excel one line turns to multiple lines .xlsx')
# # split
Df ['sales details (products and quantities)'] .str.split (';', expand = True)
Df ['sales details (products and quantities)'] .str.split (';', expand = True). Stack (). Reset_index (level = 1, drop = True) .rename ('sales details')
Df.drop ('sales details (products and quantities)', axis = 1) .join (df ['sales details (products and quantities)'] .str.split (';', expand = True). Stack ()\
.reset _ index (level = 1, drop = True)\
.rename ('sales details')
If you find a duplicate line, how to fix it?
The length of the Chinese seal is 3, so it needs to be divided by 3.
From sqlalchemy import create_engine
Import pandas as pd
From sqlalchemy import text
From warnings import filterwarnings
# since create table if not exists always throws warning, use filterwarnings to eliminate
Filterwarnings ('ignore') #, category = MySQLdb.Warning
Engine=create_engine ('mysql+pymysql://root:root@localhost:3306/cda')
Sql_1 = 'SELECT a
SUBSTRING_INDEX (
SUBSTRING_INDEX (b,';', mh.help_topic_id + 1)
';',-1)
FROM row2
LEFT JOIN mysql.help_topic mh ON mh.help_topic_id