samedi 21 février 2015

splitting string of dynamic length pandas

I have a dataframe with the following string format.



data.description[4000]=['Conduit, PVC Utility Type DB 60 TC-6, 1-1/2" LF .050 $.86 $1.90 $2.76']


the string varies in size but I would like be broken up splitting the string at the ' LF ' substring. The desired output would be



data2=['Conduit, PVC Utility Type DB 60 TC-6,1 -1/2"','LF',.050,'$.86','$1.90','$2.76]


If I were to have a list of units



units=['CLF','LF','EA']


How could I search the dataframe string and break the string in the aforementioned format? It seems splitting with unit delimiter would kinda work but I would lose the units. This gives me 2 strings which can be further split but it seems that it would require a row by row function.


Is there a better way to do this?


Aucun commentaire:

Enregistrer un commentaire