import pandas as pd
#構造資料
data=pd.dataframe()
#合併資料
合併前
合併後
import pandas as pd拆分前#構造資料
data=pd.dataframe()
#拆分資料
data_pinpai = data['品牌'].str.split(',', expand=true)
data_pinpai = data_pinpai.stack()
data_pinpai = data_pinpai.reset_index(level=1, drop=true)
data_pinpai=data_pinpai.to_frame().rename(,axis=1)
data_new = data.drop(['品牌'], axis=1).join(data_pinpai)
拆分後
如果對你有幫助,請點下讚,予人玫瑰手有餘香!
時時仰望天空,理想就會離現實越來越近!
mysql多行合併一行,一行拆分多行
資料 建表語句 drop table if exists 品牌 create table 品牌 id int 0 not null,品牌 varchar 255 character set utf8 collate utf8 general ci null default null engine i...
Oracle 多行合併一行 方法
引用自 ote 特別宣告一下內容 網路 假如有如下表,其中各個i值對應的行數是不定的 sql sql select from t i a d 1 b 2008 03 27 10 55 42 1 a 2008 03 27 10 55 46 1 d 2008 03 27 10 55 30 2 z 200...
oracle多行合併成一行
在mysql有關鍵字group concat提供了類似的功能,在oracle中類似功能關鍵字是wm concat.比如我有如下查詢資料 但是我希望能夠顯示成一行查詢出來,結果圖如下 關鍵sql 形如 select t.sglcheckid,wm concat t.salemodulename fro...