1

I'm trying to extract objects from a dataframe via the .iloc function and convert those to int to perform some operations on them. Specifically, I want to subtract two values V3 = V1 - V2.

d = {'col1': [1, 2], 'col2': [3, 4]}
df = pd.DataFrame(data=d)

V1 = df.iloc[[0],[0]]
V2 = df.iloc[[1],[1]]

I've tried some solutions that convert the whole column but they don't seem to be working.

Cleb
  • 25,102
  • 20
  • 116
  • 151
F.D
  • 767
  • 2
  • 10
  • 23

1 Answers1

0

I guess you are looking for

v3 = df.iloc[0, 0] - df.iloc[1, 1]

which will return -3.

Cleb
  • 25,102
  • 20
  • 116
  • 151