0

I'm not sure how to phrase my search in order to find it so this is probably a duplicate. Please feel free to point me in the right direction.

In pandas, I know that I can use iloc to grab particular pieces of a dataframe.
I'm curious to know if there is a way to Read or Write particular items from said dataframe.
In one case, I could get item08 by using (1, 1) and then reading it
Or perhaps I want item28 I could use (2, 4)

Maybe I'd like to change item22 on (2, 3)

  +--------------------------------------------+
0 | item01 | item07 | item13 | item19 | item26 |
  +--------------------------------------------+
1 | item02 | item08 | item14 | item21 | item27 |
  +--------------------------------------------+
2 | item03 | item09 | item15 | item22 | item28 |
  +--------------------------------------------+
3 | ...    | ...    | ...    | ...    | ...    |
  +--------------------------------------------+
      0         1        2        3        4

How can this be done?

tisaconundrum
  • 2,156
  • 2
  • 22
  • 37
  • By push or pull, do you mean read/write, I'm not quite sure I follow your terminology – DJK Nov 04 '17 at 16:04
  • I think that's what I mean. I'm still new to Pandas, so please forgive me if I use bad terminology – tisaconundrum Nov 04 '17 at 16:05
  • Maybe [this](https://stackoverflow.com/questions/13842088/set-value-for-particular-cell-in-pandas-dataframe#13842286) answers your question? – jjj Nov 04 '17 at 16:06

1 Answers1

1

Read

in[1]: df.iloc[0,0]
out[1]: item01

write

in[2]: df.iloc[0,0] = item99
in[3]: df.iloc[0,0]
out[3]: item99
DJK
  • 8,924
  • 4
  • 24
  • 40
  • When writing, is this the fastest way to do this. The answer that @jjj had provided mentioned something about `.set_value`. Is there a right or wrong way of doing this? – tisaconundrum Nov 04 '17 at 16:16
  • That answer hasn't been updated in a year, `set_value` is depreciated as stated in the answer, `ix` is also depreciated. The pandas doc say that `.at` is similar to `.loc` – DJK Nov 04 '17 at 16:20