Python Pandas little tips with the Lambda Function

Python Pandas little tips with the Lambda Function

Pandas

Pandas is a useful tool for data science because we can use this tool to analyze, visualize & manipulate data stored within data sets, or in coding terms, within data frames.

Python Lambda

  • A lambda function is a small anonymous function.
  • A lambda function can take any number of arguments, but can only have one expression.
  • Here’s a little tips that we can using lambda to do some easy data process on dataframe:
x = [176, 166, 156, 186] 
df = pd.DataFrame({'height' : x}) 
df['inch'] = df['height'].apply(lambda x: x/2.54) 
df 

Reference

Comments

Popular posts from this blog

Convert a shell script into an executable binary

Understanding htop value

Mac terminal environment setup - zsh + Powerline + tmux