python - In-Place Update of Values in Pandas Dataframe -


i'm new pandas. i've built dataframe values lists [year, datapoint] (e.g. [2013, 37722.322] or [1998, 32323.232). how rid of year value , replace list in each cell in dataframe float datapoint?

thanks much.

you mean this?

in [16]:  import operator in [17]:  df=pd.dataframe({'val':[[2013, 37722.322],[1998, 32323.232]]}) in [18]:  print df                  val 0  [2013, 37722.322] 1  [1998, 32323.232]  [2 rows x 1 columns] in [19]:  df['val2']=df.val.apply(operator.itemgetter(-1), axis=1) in [20]:  print df                  val       val2 0  [2013, 37722.322]  37722.322 1  [1998, 32323.232]  32323.232  [2 rows x 2 columns] 

to columns: df.applymap(operator.itemgetter(-1)) per @dsm's suggestion.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -