0% found this document useful (0 votes)
4 views2 pages

1.basic Pandas Commands File

The document contains Python code snippets for data manipulation using the pandas library. It includes commands for reading a CSV file, checking the shape and content of the DataFrame, retrieving specific columns, creating subsets based on conditions, and performing statistical analysis. The code also demonstrates how to handle missing values and rename columns.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

1.basic Pandas Commands File

The document contains Python code snippets for data manipulation using the pandas library. It includes commands for reading a CSV file, checking the shape and content of the DataFrame, retrieving specific columns, creating subsets based on conditions, and performing statistical analysis. The code also demonstrates how to handle missing values and rename columns.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

#import pandas library

#import pandas as pd

#read the csv file


#df=pd.read_csv("Data_for_JNB.csv",header=0, encoding ='unicode_escape')

#verift file is loaded. Check number or rows and columns


#df.shape

# Display top 5 rows (default number)


#df.head()

# Display top 7 rows


#df.head(7)

# Display bottom 5 rows (default number)


#df.tail()

# Display bottom 7 rows


#df.tail(7)

# Display the column names


#df.columns

# Show the data types


#df.dtypes

# show info
#df.info()

# Display the Statistical properties of data usig describe() command


#df.describe()

# Display the statistical properties of object types using describe()


#df.describe(include=['object'])

# Display the statistical properties of all columns


#df.describe(include='all')

# Display the number of null valaues in allcoulumns


#df.isna().sum()

# Retrieve a single column


#data1=df['Name']
#data1

# To retrieve multiple columns we can use list to include the column names
#df[['Name','Age']]
# To retrieve multiple columns we can use list to include the column names
#data2=df[['ID','Name','Age']]

# Make a subset data30 containing first 35 records


#data30=df[0:35]
#data30

# Make a data set which contains first 25 records and selected columns only
#df[0:15][['ProductName','PricePerUnit']]

# Make a subset which contains data of all rows of Appliances


#df[(df['Category']=='Appliances')]

# Make a subset of data where category is Appliances and feedback is good


#datagood=df[(df.Category=='Appliances') & (df.Feedback=='Good')]
#datagood

# Make a subset of data where category is Appliances and priceperunit is less than 10000
#data10k=df[(df.Category=='Appliances') & (df.PricePerUnit<10000)]
#data10k

#Remove column (empy or with data) by column name


#df.drop(['EmptyCol'],axis=1,inplace=False)

#Rename column name


#df.rename(columns={'Feedback':'Opinion'})

You might also like