How to change multiple lines to one line by Mysql
This article mainly introduces "Mysql how to achieve multi-line to one line". In daily operation, I believe many people have doubts about how to achieve multi-line change in Mysql. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubt of "how to achieve multi-line change to one line in Mysql". Next, please follow the editor to study!
Import pandas as pd
Df = pd.read_excel ('learn multiline strings grouped into one line .xlsx',)
The python method is merged into a list re = df.groupby (['company', 'responsible person']) ['mobile phone number'] .apply (list) .reset_index ()
# # or pd.DataFrame (df.groupby (['company', 'responsible person']) ['mobile phone number'] .apply (list))
Re
Python method 2 apply string average # df.groupby (['company', 'responsible person']) ['mobile phone number'] .apply (lambda x: '.join (x.to_string (index=False) .str.replace (' (\ n)','). Reset_index ()
Df ['mobile phone number'] = df ['mobile phone number'] .astype (str)
Df.groupby (['company', 'responsible person']) ['mobile phone number'] .apply (lambda x:', '.join (x)) .reset_index ()
The Mysql method: group_concat () is saved to the database import time
Import requests
Import json
Import os
Import pandas as pd
Import warnings
Import arrow
From sqlalchemy import create_engine
Import sys
From sqlalchemy import text
If sys.version_info.major