Suppose I have a dataframe with columns with Strings, Series and Integers that I would like to combine into a new dataframe with the String and the Integer combined with every entry in the Series. How could I go about it?
Given this example:
data = {'fruits': ['banana', 'apple', 'pear'],
'source' : (['brazil', 'algeria', 'nigera'], ['brazil', 'morocco', 'iran', 'france'], ['china', 'india', 'mexico']),
'prices' : [2, 3, 7]}
df = pd.DataFrame(data, columns = ['fruits', 'source', 'prices'])
I would like to get a 3x10 dataframe with;
['banana', 'banana', 'banana', 'apple', 'apple', 'apple', 'apple', 'pear', 'pear', 'pear'],
['brazil', 'algeria', 'nigera', 'brazil', 'morocco', 'iran', 'france', 'china', 'india', 'mexico'],
['2', '2', '2', '3', '3', '3', '3', '7', '7', '7'],
I guess it shouldn't be too complex but I can't find a neat solutions.