I have a dataframe cut from a much larger dataframe:
import pandas as pd
data = {'Name': [5, 5, 6, 6, 7, 7],
'Value': [1, 2, 1, 2, 1, 2]
}
df = pd.DataFrame(data)
Name Value
0 5 1
1 5 2
2 6 1
3 6 2
4 7 1
5 7 2
Ideal Output:
Name Value Value2
0 5 1 2
1 6 1 2
2 7 1 2
I need a way to split the dataframe into 2 separate dataframes based on the "Value" column. The rows with '1' in the Value column and the rows with '2' in the Value column need to be split up.
The best/end goal solution is to have one Name with the 1 and 2 be separate columns in the same dataframe. My idea so far is to split the two and combine them so the data is side by side all tracing back to a single Name.