How to split two columns in a data frame

So, in my data frame, I have 2 columns. And I would like to separate these 2 columns (a and b), value by value and show it.

import pandas as pd csv1=pd.read_csv('auto$0$0.csv') csv2=pd.read_csv('auto$0$8.csv') df1 = pd.DataFrame(csv1, columns = ['Column A','Column B']) df2 = pd.DataFrame(csv2, columns = ['Column A','Column B']) dfnew = pd.concat([df1, df2]) 

Columns:

 Column A | Column B | 12-------|--2-------| 14-------|--7-------| 16-------|--8-------| 20-------|--5-------| 

and expected result

 Result 6 2 2 4 

Please help me find a way.

+5
source share
1 answer

Just split the columns:

 In [158]: df['Result'] = df['Column A']/df['Column B'] df Out[158]: Column A Column B Result 0 12 2 6.0 1 14 7 2.0 2 16 8 2.0 3 20 5 4.0 
+9
source

Source: https://habr.com/ru/post/1247112/


All Articles