I have dataframe like this:
x = pd.DataFrame({
'audio': ['audio1', 'audio1', 'audio2', 'audio2', 'audio3', 'audio3'],
'text': ['text1', 'text2', 'text3', 'text4', 'text5', 'text6'],
'login': ['operator1', 'operator2', 'operator3', 'operator4', 'operator5', 'operator6']
})
i'm trying to aggregate it like this:
x1 = x.groupby('audio')['text'].agg(
[
('text1', lambda x : x.iat[0]),
('text2', lambda x : x.iat[1]),
('leven', lambda x: Levenshtein.distance(x.iat[0], x.iat[1])) #some function works with grouped text
]
).reset_index()
and it works but i also need to add grouped logins to row, to make row like this:
audio, text1, text2, leven, login1, login2
I tried something like lambda x : x.ait[0, 1]
but it doesnt work
from Pandas group by result to columns
No comments:
Post a Comment