def split_dataframe_rows(df,column_selectors):
# we need to keep track of the ordering of the columns
def _split_list_to_rows(row,row_accumulator,column_selector):
split_rows = {}
max_split = 0
for column_selector in column_selectors:
split_row = row[column_selector]
split_rows[column_selector] = split_row
if len(split_row) > max_split:
max_split = len(split_row)
for i in range(max_split):
new_row = row.to_dict()
for column_selector in column_selectors:
try:
new_row[column_selector] = split_rows[column_selector].pop(0)
except IndexError:
new_row[column_selector] = ''
row_accumulator.append(new_row)
new_rows = []
df.apply(_split_list_to_rows,axis=1,args = (new_rows,column_selectors))
new_df = pd.DataFrame(new_rows, columns=df.columns)
return new_df
df = pd.DataFrame(df.Raw_info.values.reshape(-1, 3),
columns=['Function_name', 'prop1', 'prop2'])
print(df)
Function_name prop1 prop2
0 Function_1 internal_prop_1 external_prop_1
1 Function_2 internal_prop_2 external_prop_2
2 Function_3 internal_prop_3 external_prop_3