Pandas also allows for assignment of data through simple call methods. This allows for the creation of new columns and for some changes to the data. We can do this assigning a constant or iterable of variables.
We can make the whole net_sales column to zero through this simple code:
df['net_sales']=0
Try obtaining these outputs!
1. Change the entire order_fufilled column to True
2. Create a new column in the data frame which ranks the rows in decreasing order
Answers for Activity: Assigning Data
import pandas as pd df=pd.read_csv("Retail dataset.csv") #1. Change the entire order_fufilled column to True df['order_fufilled']=True #2. Create a new column in the data frame which ranks the rows in decreasing order df['new_column']=range(len(df), 0, -1)
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.