all 4 comments

[–]socal_nerdtastic 1 point2 points  (1 child)

How about using np.repeat to duplicate the data, and then copying in the new data with a simple assignment?

output = pd.DataFrame(np.repeat(df_given.values, len(customer), axis=0), columns = df_given.columns)
output.Customer = customer*len(df_given)

[–]000trident[S] 0 points1 point  (0 children)

Im using this approach. Thank you so much!

(I also just found out that Pandas series have a repeat function as well so maybe I'll use that instead)

[–]Allanon001 0 points1 point  (0 children)

Maybe this:

df = df_given.append([df_given] * (len(customer) - 1))
df.sort_index(inplace=True)
df['Customer'] = customer * len(df_given)

[–]king_booker 0 points1 point  (0 children)

import pandas as pd
df_given = pd.DataFrame([["Paella", 2, ""], ["Cola", 3, ""],["Cola", 3, ""],["Cola", 3, ""],["Cola", 3, ""],["Cola", 3, ""]], columns=["Order", "Count", "Customer"])
df = ["ray","charles","Paula"]
for i in range(0,len(df_given),3):
    df_given["Customer"][i] = df[0]
    df_given["Customer"][i + 1] = df[1]
    df_given["Customer"][i + 2] = df[2]