PyDays Day-2 - Final
PyDays Day-2 - Final
NUMP
-2
Y
An initiative by Learning
Nexus
What is
Numpy?
• Numpy is a python library that allows numerical
computing
• Adds support to multi dimensional arrays
• Has high level math functions
• Efficient Array Structure
What makes • Fixed sizes and types
Numpy better • Contiguous memory
than stock allocation
python? • Multithreaded
Efficient Array Structure and fixed
types
• Lists in python store “objects” instead of the actual element
• Each variable stores multiple pieces of information related to the
data.
32 bit system (in 64 bit system (in
Parameters Data type
bytes) bytes)
size int 4 4
• Total size : 28 Bytes (in 64 Bit system for small integer value)
...
numpy a = np.array([1,2,3])
Creating an import numpy as np
#One dimensional array
numpy b = np.array([[1,2,3],[4,5,6]])
import numpy as np
#One dimensional array
Creating an
a = np.array([1,2,3])
#Two dimensional array
functions in
• np.full(dimension, value, dtype) ->
create an array of all values as specified
• np.min(matrix)
• np.max(matrix)
• A.reshape(order of the new matrix)
Panda
-2
s
An initiative by Learning
Nexus
What is Pandas?
Introduction :
Pandas is an open-source data analysis and
manipulation library for Python. It provides powerful,
flexible data structures that make it easy to work with
structured data, such as tables and time series. The
library is built on top of NumPy, enabling efficient
operations on large datasets.
Data Structures
Series:
A one-dimensional labeled array that can hold any data type
(similar to a list or a column in a spreadsheet).
DataFrame:
A two-dimensional labeled data structure with columns of
potentially different types (similar to a table or a
spreadsheet).
#Creating a Data Frame
import pandas and pd
Working Data = {
‘Name’ : [“Alan”, “Ian”, “Hammond”],
‘Age’ : [30, 39, 65], ‘Job’ :
with Pandas [“Paleontologist”, “Mathematician”,
“Entrepreneur”]
}
dataf = pd.DataFrame(Data)
Accessing data
• .head(number of rows) : returns the top n number
of rows
• .tail(number of rows) : returns the bottom n
number of rows
• .columns : returns the name of headers
• array[‘name of column’] : returns the data in
that column
• array.iloc[row_index, column_index]
• array.loc[array[‘column name’] == ‘value’]
More ways to use .loc() function
• Deleting a column
array.drop(columns =
[‘name_of_column’])
Working with CSV
• Reading CSV
• Writing CSV
• array.to_csv =(“saving_location\
file_name”)
Thank you
for Joining!
@tnn_vitap