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

Python Tutorial

The document provides examples of using the OS and Pandas modules in Python. It includes commands for getting and changing the working directory, terminating processes, and handling file operations with OS, as well as reading and saving CSV and Excel files with Pandas. Each code snippet demonstrates specific functionalities of the respective modules.

Uploaded by

sketchshadow111
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)
10 views2 pages

Python Tutorial

The document provides examples of using the OS and Pandas modules in Python. It includes commands for getting and changing the working directory, terminating processes, and handling file operations with OS, as well as reading and saving CSV and Excel files with Pandas. Each code snippet demonstrates specific functionalities of the respective modules.

Uploaded by

sketchshadow111
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

==============================================

===========================

OS Module

To get the working directory

import os

os.getcwd()

To change working directory

import os
os.chdir('E:\\1.Active Projects\\MCR_Match')

To Terminates a running process immediately


import os
os.abort()

To Closes the specified file descriptor

import os

os.close()

To Returns the number of CPUs present in the system

import os
os.cpu_count()

Pandas Module

 To read a csv file


import pandas as pd

data_csv = pd.read_csv("MHI_Sample_data.csv")

 To read a xlsx file

import pandas as pd

person_tbl = pd.read_excel("person table.xlsx")

or

import pandas as pd

df = pd.read_excel(r'D:\Pathkind_Miss Call Lead_November 2022.xlsx')

 To save file as csv

import pandas as pd

MHI_data.to_csv("test.csv")

 To save file as xlsx

import pandas as pd

MHI_data.to_excel("data2.xlsx")

You might also like