Python Forum

Full Version: Duplicating Rows And Put Them In Certain Index Position Query
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi there,

I use the following lines of Code in a full Code, to append Rows, based on a Column Value, to a DataFrame I have :-

is_dux = display['LOCATION'] == 'Podington'
display_try = display[is_dux]
display=display.append(display_try)
It appends the Rows who's Row Data I want to duplicate, to the output DataFrame in Pandas.

It does to the end of the DataFrame, but I want the two Rows duplicated, to be inserted at Index Numbers 2 and 3, i.e. directly underneath the source Rows.

And the 'LOCATION' Column values, in the duplicated Rows, to say 'Duxford' instead of 'Podington'.

Could someone here, tell me how to do this ?

Any help would be much appreciated

Regards

Eddie Winch Smile