One way to divide a row in a Pandas DataFrame by another is by using label-based indexing. Here is an example code block:
main.py236 chars11 lines
In this example, we first create a sample DataFrame df with two columns A and B. We then use label-based indexing to select row2 and row1 using df.loc['row2'] and df.loc['row1'] respectively. We then divide row2 by row1 using the "/" operator.
The output of this code block will be a new Series which shows the result of dividing row2 by row1 as follows:
main.py43 chars4 lines
gistlibby LogSnag