I have df going like
pd.DataFrame([["A1" "B1", "C1", "P"],
["A2" "B2", "C2", "P"],
["A3" "B3", "C3", "P"]], columns=["col_a" "col_b", "col_c", "col_d"])
col_a col_b col_c col_d
A1 B1 C1 P
A2 B2 C2 P
A3 B3 C3 P
...
the result I need is basically repeat and ensure that columns have P Q R extension in col_d for every unique row occurence
col_a col_b col_c col_d
A1 B1 C1 P
A1 B1 C1 Q
A1 B1 C1 R
A2 B2 C2 P
A2 B2 C2 Q
A2 B2 C2 R
A3 B3 C3 P
A3 B3 C3 Q
A3 B3 C3 R
...
All I have so far is:
new_df = pd.DataFrame(np.repeat(df.values, 3, axis=0), columns=df.columns)
Which result in duplication of those values, but col_d is unchanged
EDIT:
Now I stumbled upon another need, where for every unique col_a and col_b I need to add "S" to col_d
Resulting for instance in this:
col_a col_b col_c col_d
A1 B1 C1 P
A1 B1 C1 Q
A1 B1 C1 R
A1 B1 T S
A2 B2 C2 P
A2 B2 C2 Q
A2 B2 C2 R
A2 B2 T S
Thank you very much for help!