Skip to content

Tag: pandas

Pandas extract previous row on value change

I have two columns of data ‘Part & Qty’ where some part numbers are repeated across multiple rows. The quantity value I need to retrieve is contained in the final row before the part number changes. My code (below) adds a True/False column to flag when the part number changes. I had thought wh…

How to convert dtype from ‘0’ to ‘int64’?

I started working with a dataset, which is a collection of murder reports.There is a column “Perpetrator Age” in which there are simple integers. But when I looked at his type, it turned out that he was dtype(‘O’). In order to work with this column further, I want to change its type to…

Splitting a column into 2 in a csv file using python

I have a .csv file with 100 rows of data displayed like this “Jim 1234” “Sam 1235” “Mary 1236” “John 1237” What I’m trying to achieve is splitting the numbers from the names into 2 columns in python edit* Using, I managed to get it to display like this in …