Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
648 views
in Technique[技术] by (71.8m points)

pandas - Split String in Dataframe several special characters and orden in one column

I've a big trouble with a string in DF, I've one row and column with this data:

C/ZEúS, 16 -> [C/ZEúS, 16] ATP-176MA-111A(183435418) #10@[]@#10 (183190203)LKJ-176BN-001 [MADT-28083-173549-28-C01] <-> [MADT-28083-173549-42-C01] OKM-345LN(183330441) #4@[MADT-28083-173549-28-C01]@#10 (183190203)VRD-OPR-0026 [TDMA-28083-173549-15-C01] <-> [PDI MECO PK 41.099] SAD-147ML(172249661) #4@[MADT-28083-173549-42-C01]@#4 (183330441)REC-906OR [MADT-28083-173549-28-C01] <-> [MADT-28083-173549-42-C01] DER-007AA(172249661) #4@[TTRH MONTH PK 41.099]@#4 (183218951)CABLE TRONC FF94-MM [TTRRE MICO] <-> [TRMT SITE ONE SITE TyE] CABLE TRONC FF95-MM(183219448) #52@[TDI MICO PK 42/128]@#4 (183219076)CABLE TRONC FF96-MM [TRPT MARK] <-> [PK 30/634] CABLE TRONC FF97-MM(147190405) #52@[PK 31/755]@#52 (11554805)CABLE TRONC FF98-MM [TRONC PERT TyE] <-> [E0088] TRE-132VL(212840512) #509@[E0001]@#509 (212839915)TRE-345VL [AT MASASSA (4611004)] <- end here -

I want to split a string with special characters, but keeping the order it has, and placing each part of the string in a different row of the same column.

I have tried many options with .assigment or .replace, but it doesn't work due to structure; As you can see, the structure is quite special and complex, and I don't want all the data, for example the square brackets which are empty, I don't need them, but if the ones that contain something, I must also keep a structure of the string in which after a few characters as these (# number @) are stuck to the previous string, and if it is like this (# @ number) the later string is placed like this LKJ-176BN-001 (183190203) 10. The end result should be like this in DF.

enter image description here

Thanks a lot.

question from:https://stackoverflow.com/questions/65841693/split-string-in-dataframe-several-special-characters-and-orden-in-one-column

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share

2.1m questions

2.1m answers

62 comments

56.6k users

...