My data frame looks like this:
P Q L
1 2 3
2 3
4 5 6,7
The goal is to check if there is any value in L, if so, extract the value in the columns Land P:
P L
1 3
4,6
4,7
Please note that there Lmay be several values, in the case of more than 1 value I will need two lines.
Below is my script, it cannot give the expected result.
df2 = []
ego
other
newrow = []
for item in data_DF.iterrows():
if item[1]["L"] is not None:
ego = item[1]['P']
other = item[1]['L']
newrow = ego + other + "\n"
df2.append(newrow)
data_DF2 = pd.DataFrame(df2)
source
share