Unit-5
Modules
• In programming, a module is a piece of software that has a specific
functionality.
• Modules refer to the Python file.
• In Python, large code is divided into small modules
• contains Python code like Python statements, classes, functions,
variables, etc.
• A file with Python code is defined with extension.py
• For example: In Test.py, where the test is the module name.
Types of modules
• Built-in modules
• Built-in modules come with default Python installation
• Most significant advantages is its rich library support that contains lots of
built-in modules.
Ex: datetime, os, math, sys, random, etc.
• User-defined modules
• user defines or create modules
• We can create our own module, which contains classes, functions, variables, etc., as per our
requirements.
Import Modules
• import statement is used to import the whole module
• Syntax: import module name
• import keyword imports both built-in and user-defined modules.
• Example: module-math
Import multiple modules
• To use more than one module, then we can import multiple modules.
• Syntax: import module1,module2,.. moduleN
Import specific classes or functions from a module
• To import particular classes or functions, we can use the
from...import statement.
• Imports individual attributes and methods directly into the program.
• Syntax:
• from <module_name> import <name(s)>
Output:
120
Import with renaming a module
• To use the module with a different name, we can use
from..import…as statement.
• Syntax
• Example: random.randrange(start, stop, step)
Output: 41
Random Module Functions
https://pynative.com/python/random/
Import All Names
• Python Math Module Functions:
https://www.w3schools.com/python/module_math.asp
https://docs.python.org/3/library/math.html
Create Module
• Creating a module in python is similar to writing a simple python
script using the .py extension.
• Example:
• To make a program for a calculator. There will be operations like
addition, subtraction, multiplication, division, etc.
Example on creating module
• Calc.py
Use Python Modules created
• import keyword to incorporate the module into our program.
• from keyword is used to get only a few or specific function
import all the functions using the
asterisk(*) and we can simply mention the
function name to get the results.
Pandas
• Pandas is a powerful Python library that is specifically designed to
work on data frames that have "relational" or "labeled" data.
• Its aim aligns with doing real-world data analysis using Python.
• Hence, this Python package works well for data manipulation,
operating a dataset, exploring a data frame, data analysis, and
machine learning-related tasks
• it simplifies the task related to data frames
• Import datasets - available in the form of spreadsheets, comma-separated values (CSV) files, and
more.
• Data cleansing - dealing with missing values and representing them as NaN, NA, or NaT.
• Size mutability - columns can be added and removed from DataFrame and higher-dimensional
objects.
• Data normalization – normalize the data into a suitable format for analysis.
• Data alignment - objects can be explicitly aligned to a set of labels.
Intuitive merging and joining data sets – we can merge and join datasets.
• Reshaping and pivoting of datasets – datasets can be reshaped and pivoted as per the need.
• Efficient manipulation and extraction - manipulation and extraction of specific parts of extensive
datasets using intelligent label-based slicing, indexing, and subsetting techniques.
• Statistical analysis - to perform statistical operations on datasets.
• Data visualization - Visualize datasets and uncover insights.
Applications
The most common applications of Pandas are as follows:
• Data Cleaning: Pandas provides functionalities to clean messy data, deal with incomplete or inconsistent data, handle missing values,
remove duplicates, and standardise formats to do effective data analysis.
• Data Exploration: Pandas easily summarise statistics, find trends, and visualise data using built-in plotting functions, Matplotlib, or Seaborn
integration.
• Data Preparation: Pandas may pivot, melt, convert variables, and merge datasets based on common columns to prepare data for analysis.
• Data Analysis: Pandas supports descriptive statistics, time series analysis, group-by operations, and custom functions.
• Data Visualisation: Pandas itself has basic plotting capabilities; it integrates and supports data visualisation libraries like Matplotlib,
Seaborn, and Plotly to create innovative visualisations.
• Time Series Analysis: Pandas supports date/time indexing, resampling, frequency conversion, and rolling statistics for time series data.
• Data Aggregation and Grouping: Pandas groupby() function lets you aggregate data and compute group-wise summary statistics or apply
functions to groups.
• Data Input/Output: Pandas makes data input and export easy by reading and writing CSV, Excel, JSON, SQL databases, and more.
• Machine Learning: Pandas works well with Scikit-learn for data preparation, feature engineering, and model input data.
• Web Scraping: Pandas may be used with BeautifulSoup or Scrapy to parse and analyse structured web data for web scraping and data
extraction.
• Financial Analysis: Pandas is commonly used in finance for stock market data analysis, financial indicator calculation, and portfolio
optimisation.
• Text Data Analysis: Pandas' string manipulation, regular expressions, and text mining functions help analyse textual data.
• Experimental Data Analysis: Pandas makes manipulating and analysing large datasets, performing statistical tests, and visualising results

More Related Content

PPTX
Python-Libraries,Numpy,Pandas,Matplotlib.pptx
PPTX
Introduction_to_Python.pptx
PPTX
overview of python programming language.pptx
PPTX
Python Mastery: A Comprehensive Guide to Setting Up Your Development Environment
PPTX
the roadmap of python for developer beginner
PDF
From Basics to Advanced: A Comprehensive Python Programming Guide
PDF
Introduction to Analytics with Azure Notebooks and Python
PDF
class 12 Libraries in dfbdsbsdbdfbdfdfdf.pdf
Python-Libraries,Numpy,Pandas,Matplotlib.pptx
Introduction_to_Python.pptx
overview of python programming language.pptx
Python Mastery: A Comprehensive Guide to Setting Up Your Development Environment
the roadmap of python for developer beginner
From Basics to Advanced: A Comprehensive Python Programming Guide
Introduction to Analytics with Azure Notebooks and Python
class 12 Libraries in dfbdsbsdbdfbdfdfdf.pdf

Similar to this includes basics about python modules and packages introduction (20)

PDF
Advance Programming Slides lect.pptx.pdf
PPTX
Data analysis using python in Jupyter notebook.pptx
PDF
Python for Data Science: A Comprehensive Guide
PPTX
Complete Core Python with IPT Excel School
PPTX
Data Science With Python | Python For Data Science | Python Data Science Cour...
PPTX
DATA ANALYSIS AND VISUALISATION using python
PDF
Migrating from matlab to python
PPTX
Data Science Using Python.pptx
PDF
summer training report on python
PPTX
Python for Data Analytics and ML examples
PPTX
python-pandas-For-Data-Analysis-Manipulate.pptx
PDF
Using Python Libraries.pdf
PPTX
python programming unit 1 wala ppt .pptx
PDF
Data Wrangling and Visualization Using Python
PPTX
Lecture1_introduction to python.pptx
PPTX
Data Analysis packages
PPTX
Python.pptx
PDF
Introduction to python
PPTX
Introduction to Python External Course !!!
PPTX
Q-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptx
Advance Programming Slides lect.pptx.pdf
Data analysis using python in Jupyter notebook.pptx
Python for Data Science: A Comprehensive Guide
Complete Core Python with IPT Excel School
Data Science With Python | Python For Data Science | Python Data Science Cour...
DATA ANALYSIS AND VISUALISATION using python
Migrating from matlab to python
Data Science Using Python.pptx
summer training report on python
Python for Data Analytics and ML examples
python-pandas-For-Data-Analysis-Manipulate.pptx
Using Python Libraries.pdf
python programming unit 1 wala ppt .pptx
Data Wrangling and Visualization Using Python
Lecture1_introduction to python.pptx
Data Analysis packages
Python.pptx
Introduction to python
Introduction to Python External Course !!!
Q-Step_WS_06112019_Data_Analysis_and_visualisation_with_Python.pptx
Ad

More from ssuseree48e0 (6)

PPT
Machine Learning introduction and types.ppt
PDF
journal on wavelet transform technique.pdf
PDF
Code of Conduct for Suppliers -signed.pdf
PDF
patter journals using wavelet approaches
PDF
Lecture Notes for computer networks subject
PPTX
Python short notes on modules and applications
Machine Learning introduction and types.ppt
journal on wavelet transform technique.pdf
Code of Conduct for Suppliers -signed.pdf
patter journals using wavelet approaches
Lecture Notes for computer networks subject
Python short notes on modules and applications
Ad

Recently uploaded (20)

PPTX
Unit 1- Introduction to Corporate Etiquettes
PPTX
E-commerce Security and Fraud Issues and Protection
PPT
2- CELL INJURY L1 Medical (2) gggggggggg
PDF
iTop VPN Crack Latest Version 2025 Free Download With Keygen
PDF
Branding_RAMP-ML........................
PPTX
Session 4 of vibale oldin sink about vola
PPT
notes_Lecture2 23l3j2 dfjl dfdlkj d 2.ppt
PPTX
Coordination Compuch flasks didiinds.pptx
PDF
Career Overview of John Munro of Hilton Head
PPTX
Final Second DC Messeting PPT-Pradeep.M final.pptx
PDF
Beyond the Lab Coat - Perjalanan Karier di Dunia Pasca-Fisika S1
PPTX
ChandigarhUniversityinformationcareer.pptx
PPTX
Opioid_Analgesics_Presentation (1).pptxp
PPTX
Unit 3 Presentation Etiquette Business and Corporate Etiquette
PPT
444174684-Welding-Presentatiohhhn-ppt.ppt
PPTX
Core Characteristics and Abilities of an Effective Teacher_0.pptx
DOCX
GIZ Capacity Building Requirements for ICT Department.docx
PPT
ppt-of-extraction-of-metals-12th-1.pptb9
PDF
Sheri Ann Lowe Compliance Strategist Resume
PPTX
formulation and evaluation of polyherbal antiageing cream
Unit 1- Introduction to Corporate Etiquettes
E-commerce Security and Fraud Issues and Protection
2- CELL INJURY L1 Medical (2) gggggggggg
iTop VPN Crack Latest Version 2025 Free Download With Keygen
Branding_RAMP-ML........................
Session 4 of vibale oldin sink about vola
notes_Lecture2 23l3j2 dfjl dfdlkj d 2.ppt
Coordination Compuch flasks didiinds.pptx
Career Overview of John Munro of Hilton Head
Final Second DC Messeting PPT-Pradeep.M final.pptx
Beyond the Lab Coat - Perjalanan Karier di Dunia Pasca-Fisika S1
ChandigarhUniversityinformationcareer.pptx
Opioid_Analgesics_Presentation (1).pptxp
Unit 3 Presentation Etiquette Business and Corporate Etiquette
444174684-Welding-Presentatiohhhn-ppt.ppt
Core Characteristics and Abilities of an Effective Teacher_0.pptx
GIZ Capacity Building Requirements for ICT Department.docx
ppt-of-extraction-of-metals-12th-1.pptb9
Sheri Ann Lowe Compliance Strategist Resume
formulation and evaluation of polyherbal antiageing cream

this includes basics about python modules and packages introduction

  • 2. Modules • In programming, a module is a piece of software that has a specific functionality. • Modules refer to the Python file. • In Python, large code is divided into small modules • contains Python code like Python statements, classes, functions, variables, etc. • A file with Python code is defined with extension.py • For example: In Test.py, where the test is the module name.
  • 3. Types of modules • Built-in modules • Built-in modules come with default Python installation • Most significant advantages is its rich library support that contains lots of built-in modules. Ex: datetime, os, math, sys, random, etc. • User-defined modules • user defines or create modules • We can create our own module, which contains classes, functions, variables, etc., as per our requirements.
  • 4. Import Modules • import statement is used to import the whole module • Syntax: import module name • import keyword imports both built-in and user-defined modules. • Example: module-math
  • 5. Import multiple modules • To use more than one module, then we can import multiple modules. • Syntax: import module1,module2,.. moduleN
  • 6. Import specific classes or functions from a module • To import particular classes or functions, we can use the from...import statement. • Imports individual attributes and methods directly into the program. • Syntax: • from <module_name> import <name(s)> Output: 120
  • 7. Import with renaming a module • To use the module with a different name, we can use from..import…as statement. • Syntax • Example: random.randrange(start, stop, step)
  • 8. Output: 41 Random Module Functions https://pynative.com/python/random/
  • 9. Import All Names • Python Math Module Functions: https://www.w3schools.com/python/module_math.asp https://docs.python.org/3/library/math.html
  • 10. Create Module • Creating a module in python is similar to writing a simple python script using the .py extension. • Example: • To make a program for a calculator. There will be operations like addition, subtraction, multiplication, division, etc.
  • 11. Example on creating module • Calc.py
  • 12. Use Python Modules created • import keyword to incorporate the module into our program. • from keyword is used to get only a few or specific function import all the functions using the asterisk(*) and we can simply mention the function name to get the results.
  • 13. Pandas • Pandas is a powerful Python library that is specifically designed to work on data frames that have "relational" or "labeled" data. • Its aim aligns with doing real-world data analysis using Python. • Hence, this Python package works well for data manipulation, operating a dataset, exploring a data frame, data analysis, and machine learning-related tasks • it simplifies the task related to data frames
  • 14. • Import datasets - available in the form of spreadsheets, comma-separated values (CSV) files, and more. • Data cleansing - dealing with missing values and representing them as NaN, NA, or NaT. • Size mutability - columns can be added and removed from DataFrame and higher-dimensional objects. • Data normalization – normalize the data into a suitable format for analysis. • Data alignment - objects can be explicitly aligned to a set of labels. Intuitive merging and joining data sets – we can merge and join datasets. • Reshaping and pivoting of datasets – datasets can be reshaped and pivoted as per the need. • Efficient manipulation and extraction - manipulation and extraction of specific parts of extensive datasets using intelligent label-based slicing, indexing, and subsetting techniques. • Statistical analysis - to perform statistical operations on datasets. • Data visualization - Visualize datasets and uncover insights.
  • 15. Applications The most common applications of Pandas are as follows: • Data Cleaning: Pandas provides functionalities to clean messy data, deal with incomplete or inconsistent data, handle missing values, remove duplicates, and standardise formats to do effective data analysis. • Data Exploration: Pandas easily summarise statistics, find trends, and visualise data using built-in plotting functions, Matplotlib, or Seaborn integration. • Data Preparation: Pandas may pivot, melt, convert variables, and merge datasets based on common columns to prepare data for analysis. • Data Analysis: Pandas supports descriptive statistics, time series analysis, group-by operations, and custom functions. • Data Visualisation: Pandas itself has basic plotting capabilities; it integrates and supports data visualisation libraries like Matplotlib, Seaborn, and Plotly to create innovative visualisations. • Time Series Analysis: Pandas supports date/time indexing, resampling, frequency conversion, and rolling statistics for time series data. • Data Aggregation and Grouping: Pandas groupby() function lets you aggregate data and compute group-wise summary statistics or apply functions to groups. • Data Input/Output: Pandas makes data input and export easy by reading and writing CSV, Excel, JSON, SQL databases, and more. • Machine Learning: Pandas works well with Scikit-learn for data preparation, feature engineering, and model input data. • Web Scraping: Pandas may be used with BeautifulSoup or Scrapy to parse and analyse structured web data for web scraping and data extraction. • Financial Analysis: Pandas is commonly used in finance for stock market data analysis, financial indicator calculation, and portfolio optimisation. • Text Data Analysis: Pandas' string manipulation, regular expressions, and text mining functions help analyse textual data. • Experimental Data Analysis: Pandas makes manipulating and analysing large datasets, performing statistical tests, and visualising results