Skip to Main Content

Python for Basic Data Analysis

Start your data science journey with Python. Learn practical Python programming skills for basic data manipulation and analysis.

Applying functions and modules

Now that we are familiarized with Panda's basic functionality and syntax, let's explore how we can combine this with other popular mods that are commonly used in python to create more robust data structures appropriate for data analysis. To apply a function to the dataframe, you may simply apply it to the data frame variable as you would apply it on a normal variable. Try out these examples!

1. Applying numpy functions

import numpy as np
df.apply(np.max)

2. Applying lambda functions

df['net_sales']=df['net_sales'].apply(lambda x: 1000 * x)
df['net_sales'].head()

3. Renaming values according to specific values using the map function

d = {False : 'No', True : 'Yes'}
df['order_fufilled'] = df['order_fufilled'].map(d)
df.head()

4. Renaming values with the replace function

a =  {'Yes':True,'No':False}
df = df.replace({'order_fufilled': a})
df.head()

 

Video Guides

Activity: Self-exporation

Pandas works with most other modules and functions as it does with any normal variable in python, do some research and explore what other modules you commonly use can work well with data analysis on data frames with Pandas

Downloads