dataframe - Find sentence and paragraph with Python -
i have following format of data:
[1956, jon's story, sold soul in 1987, 200] [1960, mary's story, "she liked soul, decided sold anyway.", 250] [1963, "alice , peter story, twist", "peter said "your soul mine!" , tried sold it, alice had no soul , killed him.", 500] i want split
[1956, 1960, 1963] ['jon's story', 'mary's story','alice , peter story, twist'] ['he sold soul in 1987','she liked soul, decided sold anyway.','peter said "your soul mine!" , tried sold it, alice had no soul , killed him.'] [200,250,500] so far i've done this
import re data = [[1956, "jon's story", "he sold soul in 1987", 200], [1960, "mary's story", "she liked soul, decided sold anyway.", 250], [1963, "alice , peter story, twist", "peter said 'your soul mine!' , tried sold it, alice had no soul , killed him.", 500]] row in data: line = str(row) sentence = re.split(r',', line) but way takes account comma separation inside " ". how can avoid it?
so can solved using zip instead of re, below @ code , see how works. m4,m3,m2,m1 lists values needed
data = [[1956, "jon's story", "he sold soul in 1987", 200], [1960, "mary's story", "she liked soul, decided sold anyway.", 250], [1963, "alice , peter story, twist", "peter said 'your soul mine!' , tried sold it, alice had no soul , killed him.", 500]] m4, m3 ,m2,m1 = map(list, zip(*data))
Comments
Post a Comment