Pandas Notes

  • When using an arbitrary index through set_index function,
    • df.loc[number, :], number will need to be part of the arbitrary index set
    • df.iloc[0, :] will return the first row regardless of the index set
      • the catch here is that you cannot specify the column by the column name, but only by the column number
    • [not preferred] df.ix[number, :], number will need to be part of the arbitrary index set
    • For more details:
      http://www.shanelynn.ie/select-pandas-dataframe-rows-and-columns-using-iloc-loc-and-ix/
  • When two dataframes share the same index (one is the subset of another), we can just assign columns to one another like below and the corresponding subset rows will be filled and the remaining will be NaN

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s