when cleaning up missing datain some cases you will filter out data observations using dropnabut in others you may want to impute (fill inthe na values using fixed value or some value derived from the data fillna is the right tool to usefor example here fill in na values with the meanin [ ] series(np random randn( )in [ ] [:: np nan in [ ] out[ ] nan - nan - nan in [ ] fillna( mean()out[ ] - - - - - suppose you need the fill value to vary by group as you may guessyou need only group the data and use apply with function that calls fillna on each data chunk here is some sample data on some us states divided into eastern and western statesin [ ]states ['ohio''new york''vermont''florida''oregon''nevada''california''idaho'in [ ]group_key ['east' ['west' in [ ]data series(np random randn( )index=statesin [ ]data[['vermont''nevada''idaho']np nan in [ ]data out[ ]ohio new york - vermont nan florida - oregon nevada nan california idaho nan in [ ]data groupby(group_keymean(out[ ] data aggregation and group operations www it-ebooks info