-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExplanation of code.txt
More file actions
28 lines (22 loc) · 944 Bytes
/
Copy pathExplanation of code.txt
File metadata and controls
28 lines (22 loc) · 944 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#importing necessary packages
import kaggle
import pandas as pd
#used to download zipfile - dataset which are available in kaggle
!kaggle datasets download ankitbansal06/retail-orders -f orders.csv
#extract file from zip file
import zipfile
zip = zipfile.ZipFile('orders.csv.zip')
zip.extractall()
zip.close()
#read a csv and handle null values present in the dataset
df = pd.read_csv('orders.csv', na_values=['Not Available', 'unknown'])
#checking how much values available inside the ship mode column
df['Ship Mode'].unique()
#rename column names - make all into lower case & replace with underscore
#high time complexity, because takes time to change all columns
df.rename(columns = {'Order Id' : 'order_id'})
#instead change into str and use lower()
df.columns = df.columns.str.lower()
#replace all spaces with underscore
df.columns = df.columns.str.replace(' ', '_')
df.head(5)