I am trying to run python script in which I am using explode() to split row into multiple rows but the condition is this we can use explode() in the higher version of pandas means pandas version should be greater than or equal to '0.25.0'
So in higher version of pandas explode() is working fine. I used below code:
columns = ['rule_id', 'applied_sql_function1', 'input_condition', 'input_value', 'and_or_not_oprtor', 'output_condition', 'priority_order','comb_fld_order']
df_main1 = (df_main1.set_index(['rule_id', 'applied_sql_function1', 'input_condition', 'input_value', 'and_or_not_oprtor', 'output_condition', 'priority_order']).apply(lambda x: x.astype(str).str.split(',').explode()).reset_index())
I am splitting comb_fld_order column.
I need some alternative solution so that new logic can give the same result like explode() in the lower version of pandas. Can someone please help me how to do this?
df1:
rule_id priority_order comb_fld_order
R162 2.3 1
R162 2.3.1 1
R162 2.6 2
R162 2.6.1 2
R162 3.0.4 3.2,3.1,3
Expected Output:
df1:
rule_id priority_order comb_fld_order
R162 2.3 1
R162 2.3.1 1
R162 2.6 2
R162 2.6.1 2
R162 3.0.4 3.2
R162 3.0.4 3.1
R162 3.0.4 3