Hi,
I've created regular expressions to extract information regarding 'player', 'ballon d'or', and 'car' from a string. The output is arranged in lines but I want to arrange it in columns, so that player names are shown under the header 'player', number of 'ballon d'or' under 'ballon d'or' and so on. I'm a beginner and not sure in what direction to go from here; I understand that learning pandas is probably the best way to tackle this? Any suggestions welcome. Thanks!
I've created regular expressions to extract information regarding 'player', 'ballon d'or', and 'car' from a string. The output is arranged in lines but I want to arrange it in columns, so that player names are shown under the header 'player', number of 'ballon d'or' under 'ballon d'or' and so on. I'm a beginner and not sure in what direction to go from here; I understand that learning pandas is probably the best way to tackle this? Any suggestions welcome. Thanks!
import re
Text = '''
vfbojrgbjgbjnike k k] fd gbp adidas4fknpumaonobentleyfnvofvVW fobks]bpfporschevfnesfnb opfopve5dfvdsyamaha vdvdfvhondavd
lvpdnronaldovvf dvemessivdef
'''
player = re.compile(r'ronaldo|messi')
plrmatches = player.findall(Text)
for match in plrmatches:
print(match)
bdor = re.compile(r'[\d]|[\d]')
bdormatches = bdor.findall(Text)
for match in bdormatches:
print(match)
car = re.compile(r'bentley|porsche')
carmatches = car.findall(Text)
for match in carmatches:
print(match)Output:ronaldo
messi
4
5
bentley
porsche
