0

I have a CSV file that includes 2 columns and 28 rows. how can I find a specific value in the second column based on the opposite value in the first column? I write below code but it doesn't work.

import numpy as np
import pandas as pd

pipe_dict = pd.read_csv("/Users/hossein.hooshmand/Desktop/PIPE GEOMETRY FINDER - Copy.csv")

x = int(input ("pipe size: "))

row_num = pipe_dict [pipe_dict["PipeSize"] == x].index

print (pipe_dict.at[row_num,"OD"])
mozway
  • 194,879
  • 13
  • 39
  • 75
  • 1
    What do you mean by "*the opposite value*"? Can you provide an explicit example? Do you just want: `pipe_dict[pipe_dict["PipeSize"] == x, 'OD']` or maybe `pipe_dict[pipe_dict["PipeSize"] == x, 'OD'].iloc[0]`/`pipe_dict[pipe_dict["PipeSize"] == x, 'OD'].squeeze()`? – mozway Apr 14 '23 at 09:33
  • the opposite value: the data which is in the same row but in the next column. – Mohammad Hossein Apr 14 '23 at 09:44
  • OK, then use my above suggestion(s). Should you have any issue, please provide a reproducible example. – mozway Apr 14 '23 at 09:45

0 Answers0