Hello All,
I want to make a new dataframe for every unique value from a column.
For one specific column I can write it manually, but my script needs to be compatible with other columns as well.
So it should automatically detect the specific values of a column and than make new dataframes with the specific values.
I am still new to programming, but I cannot seem to find an answer to this problem, maybe someone on this forum knows how to do this
I want to make a new dataframe for every unique value from a column.
For one specific column I can write it manually, but my script needs to be compatible with other columns as well.
So it should automatically detect the specific values of a column and than make new dataframes with the specific values.
I am still new to programming, but I cannot seem to find an answer to this problem, maybe someone on this forum knows how to do this
print(df['ent_name'].unique()) ['DNS_8-WM2' 'DNS_8' 'DNS_8-WM1' 'DNS_8-WM5' 'DNS_8-LP1' 'DNS_8-LP2' 'DNS_8-LP5' 'DNS_8-LP6' 'DNS_8-ATM1'] #making new dataframes manually DNS_8 = df[df.ent_name == 'DNS_8'] DNS_8_WM1 = df[df.ent_name == 'DNS_8-WM1'] DNS_8_WM2 = df[df.ent_name == 'DNS_8-WM2'] DNS_8_WM5 = df[df.ent_name == 'DNS_8-WM5'] # Split data from Main tool and modules
Larz60+ write Mar-23-2021, 10:06 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use bbcode on future posts.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Fixed for you this time. Please use bbcode on future posts.