NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

# -*- coding: utf-8 -*-
"""
Spyder Editor

This is a temporary script file.
"""

import pandas as pd;

#1. Read the data from Data.csv to DataFrame “dataset”.
df = pd.read_csv('D:Projects_sem9MachineLearningData.csv')
print(df.to_string())

#2. Display total number of rows and columns of datase.
row, col = df.shape
print("n,Toatl row:",row)
print("n,Toatl columns:",col)

#3.Display first 5 record from dataset.
print("n",df.head(5))

#4. Display all values of column “City” by accessing column name as attribute of dataset.
print("n",df[["City"]])

#5. Display all values of column “City” by using indexing ( [ ] ) operator.
demo = pd.DataFrame(df[["City"]], index = [1,2,3,4,5,6,7,8,9,10])
print("n",demo)

#6. Display “City” value from the first record.
demo1 = pd.DataFrame(df[["City"]], index = [1])
print("n",demo1)

#7. Display first record using iloc( ).
demo2 = df.iloc[0]
print("n",demo2)

#8. Display all values of first column using iloc( ).
demo3 = df.iloc[:]
print("n",demo3)

#9. Display “City” value from 2nd and 3rd records using iloc().
demo4 = pd.DataFrame(df.iloc[[2,3],[0]])
print("n",demo4)

#10. Display “City” value from 2nd and 4th records using iloc( ).
demo4 = pd.DataFrame(df.iloc[[2,4],[0]])
print("n",demo4)

#11. Display last 3 records from the dataset using iloc( ).
demo5 = df.tail(3)
print("n",demo5)

#12. Display all records using loc( ) where “City” value is “Bardoli”.
print("n",df.loc[df['City'] == "Bardoli"])

#13. Display all “City” values with number of records having that value using groupby( ).
print("n",df.groupby('City')['City'].count())

#14. Display all records where “Age” is NULL.
print("n",df[df['Age'].isna()==True])

#15. Delete all rows with missing values
print("n",df.dropna())

#16. Delete all columns with missing values.
print("n",df.dropna(axis=1))

#17. Replace missing categorical values with most frequent values
result = df.fillna(df.mode().iloc[0])
print(result)

#18. Replace missing “City” name with value “Bardoli”, if any
print("n",df['City'].fillna(value="Barodoli"))
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.