Skip to content

Tag: pandas

Pandas groupby filter only last two rows

I am working on pandas manipulation and want to select only the last two rows for each column “B”. How to do without reset_index and filter (do inside groupby) My attempt Required output Answer Try: Output:

How to find and calculate common letters between words in pandas

I have a dataset with some words in it and I want to compare 2 columns and count common letters between them. For e.g I have: And I want to have smth like that: Answer You can use a list comprehension with help of itertools.takewhile: output: NB. the logic was no fully clear, so here this stops as soon as