Python Forum
Duplicating Rows And Put Them In Certain Index Position Query
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Duplicating Rows And Put Them In Certain Index Position Query
#1
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Duplicating values 007sonic 2 491 Jul-15-2023, 07:36 PM
Last Post: 007sonic
  Turtle.setpos() vs text position on screen query ElectronWrangler 0 1,511 Nov-26-2022, 02:39 AM
Last Post: ElectronWrangler
  Replace for loop to search index position illmattic 5 1,228 Sep-03-2022, 04:04 PM
Last Post: illmattic
  The code I have written removes the desired number of rows, but wrong rows Jdesi1983 0 1,602 Dec-08-2021, 04:42 AM
Last Post: Jdesi1983
  rows from sql query need to write to a file as columns sjcsvatt 6 2,335 Oct-09-2021, 12:45 AM
Last Post: snippsat
  Partial Matching Rows In Pandas DataFrame Query eddywinch82 1 2,338 Jul-08-2021, 06:32 PM
Last Post: eddywinch82
  Pandas DataFrame combine rows by column value, where Date Rows are NULL rhat398 0 2,082 May-04-2021, 10:51 PM
Last Post: rhat398
  Indexing [::-1] to Reverse ALL 2D Array Rows, ALL 3D, 4D Array Columns & Rows Python Jeremy7 8 6,962 Mar-02-2021, 01:54 AM
Last Post: Jeremy7
  write mariadb table rows query to each file? shams 1 1,842 Feb-02-2021, 04:10 PM
Last Post: buran
  item = index position - list of list RavCOder 9 4,031 Dec-02-2019, 05:24 PM
Last Post: ThomasL

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020