Nov-28-2023, 10:36 PM
(This post was last modified: Nov-28-2023, 10:36 PM by deanhystad.)
It is doing exactly what I would expect. What were you expecting?
Maybe this will help explain.
The result of this operation that uses multiple Series is a new Series.
Maybe this will help explain.
import pandas as pd df = pd.DataFrame( {"context": list("ABC"), "target": list("DEF"), "anchor": list("GHI")} ) new_series = "TEXT1: " + df.context + " TEXT2: " + df.target + " TEXT3: " + df.anchor print("target", df.target, "", sep="\n") print("new_series", new_series, "", sep="\n")
Output:target
0 D
1 E
2 F
Name: target, dtype: object
new_series
0 TEXT1: A TEXT2: D TEXT3: G
1 TEXT1: B TEXT2: E TEXT3: H
2 TEXT1: C TEXT2: F TEXT3: I
dtype: object
df.target is a Series, an array like object that is the "target" row the df dataframe.The result of this operation that uses multiple Series is a new Series.
new_series = "TEXT1: " + df.context + " TEXT2: " + df.target + " TEXT3: " + df.anchor