How can I find and replace value in a code block on jupyter in vs code

Viewed 65

I am coding python jupyter on vs code. I am finding the way to find and replace in current selected code block

For example

bl[(bl.uom_pallet == 0) & (bl.UOM == 'BG')]['uom_pallet'] = bl[(bl.uom_pallet > 0) & (bl.UOM == 'BG')]['uom_pallet'].mean()
bl[(bl.uom_pallet == 0) & (bl.UOM == 'BO')]['uom_pallet'] = bl[(bl.uom_pallet > 0) & (bl.UOM == 'BO')]['uom_pallet'].mean()
bl[(bl.uom_pallet == 0) & (bl.UOM == 'BOX')]['uom_pallet'] = bl[(bl.uom_pallet > 0) & (bl.UOM == 'BOX')]['uom_pallet'].mean()

I would like to replace 'uom_pallet' to 'quantities' but typing ctrl+H will search for the whole document starting the first code block. Is there a way that I can find and replace on current selected code block? thank you for your help

1 Answers

Here is my suggestion:

  1. Use the mouse to select the area you want to replace

    enter image description here

  2. Then use CTRL+F to find or CTRL+H to replace

  3. Select Find in Selection on the Replacement panel

    enter image description here

  4. Enter uom_pallet in the input box above, Enter quantities in the input box below

    enter image description here

  5. select Replace All

    enter image description here

Result after replacement:

enter image description here

Related