Title: Fill the data frame from the list of strings with split condition
Tags: python;pandas;dataframe
Question: I have a list like this:
l=['-1.1430054,5.9142456,8.293411','-0.42156982,6.976654,8.832993','-0.024368286,5.3268127,10.694611',
'-0.09136963,3.1469574,13.665298']
Now I want to create a data frame form this list in a way that the first element splitted by comma, so that the data frame should look like
col1         col2         col3
-1.1430054   5.9142456    8.293411
-0.42156982  6.976654     8.832993
-0.024368286 5.3268127    10.694611
-0.09136963  3.1469574    13.665298
I have tried this code to do this,
df=pd.DataFrame(columns=['col1','col2','col3'])
for i in range(0,len(l)):
temp_df=pd.DataFrame(columns=['col1','col2','col3'])
temp_x=l[i].split(',')[0]
temp_y=l[i].split(',')[1]
temp_z=l[i].split(',')[2]
temp_df['col1']=[temp_x]
temp_df['col2']=[temp_y]
temp_df['col3']=[temp_z]
df=df.append(temp_df)
This gives the perfect result as I want, But I want to reduce the execution time,
Looking for any shortcut or pythonic way to reduce the execution time.

Here is the accepted answer: Split the strings and construct the dataframe as:
pd.DataFrame(i.split(',') for i in l).add_prefix('col')
col0       col1       col2
0    -1.1430054  5.9142456   8.293411
1   -0.42156982   6.976654   8.832993
2  -0.024368286  5.3268127  10.694611
3   -0.09136963  3.1469574  13.665298

Here is another answer: one more solution,
df=pd.DataFrame({"col":l})
print(df.col.str.split(',', expand=True))
0          1          2
0    -1.1430054  5.9142456   8.293411
1   -0.42156982   6.976654   8.832993
2  -0.024368286  5.3268127  10.694611
3   -0.09136963  3.1469574  13.665298

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2019:00:10/15/19', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<python><pandas><dataframe>', 'Title': 'Fill the data frame from the list of strings with split condition', 'ViewCount': 40, 'id': 58396593, 'user_AboutMe': None, 'user_AccountId': 11464692.0, 'user_DisplayName': 'Kallol', 'user_Reputation': 1885.0, 'user_Views': 173.0, 'user_id': 11629296.0}}