Вы можете использовать split (), а некоторые циклы for помещают ваши данные в словарь, а затем передают словарь в фрейм данных.
import pandas as pd
# First create the list containing your entries.
entries = [
'RequestId: , Datetime: 5/28/2020 12:00:00 AM, High: 323.44, Low: 315.63,' \
' Open: 316.77, Close: 318.25, PeriodVolume: 33449103, OpenInterest: 0',
'RequestId: , Datetime: 5/27/2020 12:00:00 AM, High: 318.71, Low: 313.09,' \
' Open: 316.14, Close: 318.11, PeriodVolume: 28236274, OpenInterest: 0',
'RequestId: , Datetime: 5/26/2020 12:00:00 AM, High: 324.24, Low: 316.5,' \
' Open: 323.5, Close: 316.73, PeriodVolume: 31380454, OpenInterest: 0',
'RequestId: , Datetime: 5/22/2020 12:00:00 AM, High: 319.23, Low: 315.35,' \
' Open: 315.77, Close: 318.89, PeriodVolume: 20450754, OpenInterest: 0'
]
# Next create a dictionary in which we will store the data after processing.
data = {
'Datetime': [], 'Open': [], 'High': [], 'Low': [],
'Close': [], 'PeriodVolume': [], 'OpenInterest': []
}
# Now split your entries by ','
split_entries = [entry.split(',') for entry in entries]
# Loop over the list
for entry in split_entries:
# and loop over each of the inner lists
for ent in entry:
# Split by ': ' to get the 'key'
# I have added the [1:] as there is a space before each
# column name which needs to be cut out for this to work.
key = ent.split(': ')[0][1:]
# Now we check if the key is in the keys of the dictionary
# we created earlier and append the value to the list
# associated with that key if so.
if key in data.keys():
data[key].append(ent.split(': ')[1])
# Now we can pass the data into panda's DataFrame class
dataframe = pd.DataFrame(data)
# Then call one more method to set the index
dataframe = dataframe.set_index('Datetime')