I am querying a single value from my data frame which seems to be \'dtype: object\'. I simply want to print the value as it is with out printing the index or other information a
it should work simply..
>>> df
Host Port
0 a b
>>> df[df['Host'] == 'a']['Port'][0] # will choose the first index simply which is 'b'
'b'
OR, use with print which will strip off the surrounded single ticks.
>>> print(df[df['Host'] == 'a']['Port'][0])
b
This will easier because you have just choose the desired Index even if you have Multiple values across Port
columns
Example:
>>> df
Host Port
0 a b
1 c c
Looking for distinct a
& c
based on Index:
>>> df[df['Host'] == 'a']['Port'][0]
'b'
>>> df[df['Host'] == 'c']['Port'][1]
'c'