I have the following DataFrame
df = (
pd.DataFrame([
['source1', ['text...', 'text...', 'text...'], [12.0, 100.0, 24.0]],
['source2', ['text...', 'text...'], [12.0, 2.0]],
['source3', ['text...'], [48.0]]],
columns=['source_id', 'content', 'eng']))
To illustrate a bit more this DataFrame, each row represent a given source in "source_id" and has a list of content ("content") and engagement metric ("eng"). For "source1", the 1st element of the "content" list is the first content and the first element of "eng" is the engagement metric of this content. In other words, it's vital to keep this order.
What I'm looking to do is splitting these two lists in order to get a DataFrame like this.
unpacked_df = (
pd.DataFrame([
['source1', 'text...', 12.0],
['source1', 'text...', 100.0],
['source2', 'text...', 12.0],
['source1', 'text...', 24.0],
['source2', 'text...', 2.0],
['source3', 'text...', 48.0]],
columns=['source_id', 'content', 'eng']))
I'm reaaly stuck with this issue. I've been thinking about using zip() method but is it going to be efficient and keep the original order. Plus I don't know how to unpack in a DataFrame.