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()
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
You are expected to comply with University policies and guidelines namely, Appropriate Use of Information Resources Policy, IT Usage Policy and Social Media Policy. Users will be personally liable for any infringement of Copyright and Licensing laws. Unless otherwise stated, all guide content is licensed by CC BY-NC 4.0.