west - we can fill the na values using the group means like soin [ ]fill_mean lambda gg fillna( mean()in [ ]data groupby(group_keyapply(fill_meanout[ ]ohio new york - vermont - florida - oregon nevada california idaho in another caseyou might have pre-defined fill values in your code that vary by group since the groups have name attribute set internallywe can use thatin [ ]fill_values {'east' 'west'- in [ ]fill_func lambda gg fillna(fill_values[ name]in [ ]data groupby(group_keyapply(fill_funcout[ ]ohio new york - vermont florida - oregon nevada - california idaho - examplerandom sampling and permutation suppose you wanted to draw random sample (with or without replacementfrom large dataset for monte carlo simulation purposes or some other application there are number of ways to perform the "draws"some are much more efficient than others one way is to select the first elements of np random permutation( )where is the size of your complete dataset and the desired sample size as more fun examplehere' way to construct deck of english-style playing cardsheartsspadesclubsdiamonds suits [' '' '' '' 'card_val (range( [ base_names [' 'range( [' '' '' 'cards [for suit in [' '' '' '' ']cards extend(str(numsuit for num in base_namesdeck series(card_valindex=cardsgroup-wise operations and transformations www it-ebooks info