I have a pandas series like so:
df = pd.Series(
[['abc', 'xyz1'],
['abc', 'xyz1'],
['def', 'xyz1'],
['def', 'xyz1']]
)
I'd like to convert so that there are no more lists, and only the first entry from each list:
df = pd.Series('abc', 'abc', 'def', 'def')
Any ideas?
Actually this was the result of a dataframe:
temp = df_original["Col1"].str.split("/", n=1)
I wanted in this line to already split and extract the first string (I tried [0]
at the end - didn't work). Then I tried:
temp_1 = temp.map(lambda x: x[0])
But still didn't work.