Home > database >  Saving just the value from a Pandas DataFrame row
Saving just the value from a Pandas DataFrame row

Time:06-06

I'm looking up a certain row in my Pandas DataFrame by using the index - the row information is stored in variable p. As you can see p gives me a normal Pandas DataFrame. Now I want to save just the integer in in_reply_to_status_id as variable y but, in my code below, it gives me an object. Does anyone know if and how it would be possible to just store the integer (1243885949697888263 in this case) as y? enter image description here

CodePudding user response:

y is a series, you can try as follow to pick second (1243885949697888263) value

print(y.array[0])

CodePudding user response:

Did you try this?

y = df.at[i, 'in_reply_to_status_id']

That way you don't have to create p.

If you want to do it with p:

y = p.iloc[0].at['in_reply_to_status_id']

Or:

y = p.iat[0,1]

Or:

y = p.at[i, 'in_reply_to_status_id']
  • Related