python –version – to check the python version in VS code
python -m venv my_env1 – to create a virtul environment where we will be
working
How to download Kaggle dataset ino VC code
kaggle datasets download -d najir0123/walmart-10k-sales-datasets
python -m pip install pandas – to install pandas through VS code terminal
else sometimes we can also write import pandas as pd in jypiter notebook,
but it may fail so the previous one is more stable
pip install jupyter
import pandas as pd
Jupiter notebook
df = pd.read_csv('[Link]', encoding_errors='ignore') – read the CSV
[Link] = a general count
[Link]() = we see first 5 rows of dataset
[Link]() = Gives statistical view of the dataset
[Link]() = Gives how the column information and the what type of data it is
and count details
[Link]().sum() = Gives the total count of duplicate entry
[Link]().sum() = Gives the null value count by summing
df.drop_duplicates(inplace=True) = This drops the duplicate entry and the
extra parameter help in ensuring it
after dropping duplicate we can again run to duplicate check function and
the result will show 0
then if we put the shape function we will see the shape has also reduced as
the duplicate has been removed
[Link](inplace=True) = Dropping all rows with missing records/null values
Now we if we again run [Link]().sum(), then that will show that there is no
null value
Again we can use [Link] = a general count to see the count of the values
[Link] = this shows the types of each column of data
df['unit_price'].astype(float) = this is changing the data type by typecasting
The below function is used for changing the unit price type of data, so here
the str function is replacing the $ to blank and then astype is changing the
type of data to float. Also then this change as to be assigned back to this
column of unit_price so we have used like this with =
df['unit_price'] =df['unit_price'].[Link]('$','').astype(float)
after this if we check [Link] again then we will see the type change
Alternate way of doing the same thing
if df['unit_price'].dtype == 'O':
df['unit_price'] = df['unit_price'].[Link]('$', '',
regex=False).astype(float)
else:
df['unit_price'] = df['unit_price'].astype(float)
[Link] = This shows all the column headers in the document
Creating a new column or total by multiplying quantity and unit price
df['Total'] = df['unit_price'] * df['quantity']
Now we need to install SQL adapter = pip install pymysql and the create
engine pip install sqlalchemy