Data Analytics Tutorial for Beginners: A Step-By-Step Guide

How to Start with Data Analytics?

First install Python compiler Spyder in your PC

Loading a simple delimited data file from the source : Click here

import numpy as np
import pandas as pd
import matplotlib.pyplot as plt           

df = pd.read_csv("C:\\python\\100 Sales Records.csv")   # Dataset Path   # df is varibale name that store the dataser value

  1. I want to access or print only first five row use method – head()
#head method shows above 5 rows
print(df.head())

Output :

head() - output

2. Next, want to know how many rows and columns existing in this Data frame :

#shape method shows rows and columns of dataset
print(df.shape)

Output : (100, 14)

3. How to identify the column name use – columns

#print colums of dataset
print(df.columns)

Output :

Index([‘Region’, ‘Country’, ‘Item Type’, ‘Sales Channel’, ‘Order Priority’,
‘Order Date’, ‘Order ID’, ‘Ship Date’, ‘Units Sold’, ‘Unit Price’,
‘Unit Cost’, ‘Total Revenue’, ‘Total Cost’, ‘Total Profit’],
dtype=’object’)

4. How to know data type of each column :

# get the data type
print(df.dtypes)

Output :

5. How to print a specific column detail :


country_df = df['Country']
print(country_df.head() )            #country column star5 data print

Output :

6. how to print last five row of the specific column :

print(country_df.tail() )            #print last 5 rows 'country' column data

Output :

output of tail

7. How to get more than one column data : use subset()


subset = df[['Region', 'Country', 'Total Profit']]
print(subset.head())

Output :

output of head

For basic python concept read/write file Click here

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top