Geschreven door studenten die geslaagd zijn Direct beschikbaar na je betaling Online lezen of als PDF Verkeerd document? Gratis ruilen 4,6 TrustPilot
logo-home
College aantekeningen

Need inspiration

Beoordeling
-
Verkocht
-
Pagina's
19
Geüpload op
10-03-2025
Geschreven in
2024/2025

This module one of python for data science, a topic called numpy

Instelling
Vak

Voorbeeld van de inhoud

Module 1 - numpy 2024




numpy / Module 1




MODULE 1: NUMPY

Introduction to Numpy

Welcome to this session on introduction to Numpy. Numpy is a library in
python used for handling multidemensional arrays. It is a short form for
numerical python. Numpy array in a way are like the lists you were
introduced to in the introduction to python programming. As the arrays
grow bigger numpy array provide efficient ways and operations for
managing arrays. Arrays organize data into rows and columns

Numpy provides support for large multidimensional arrays and matrices,
with mathematical functions used for operating on this arrays.

To be able to use Numpy in your machine you will need to install it. If you
installed anacoda in your environment, it comes with Numpy installed. So
you will not need to install it. If you did not you can use


pip install numpy


Once you have Numpy installed in your machine, we can use it in our
notebooks by importing it using the followng code


import numpy as np


As np provides just an allias so that we do not have to type numpy all the
times. Lists as discussed earlier can contain elements of different
datatypes in contrast numpy arrays cointains only elements of one data
type. If the there are other datatypes in the array, numpy will try casting
them.




Module1 1

,Module 1 - numpy 2024




There are various ways we can create numpy array;

1. Creating numpy array from a list

We can convert a numpy array to a list as follows; lets say we have a list
of student marks we can convert it to numpy using the np.array()


1 import numpy as np
2 lis_marks=[40,67,89,45,67]
3 numpy_list=np.array(lis_marks)
4 print(numpy_list)




1 import numpy as np
2 lis_marks=[40,67,89,45,67]
3 numpy_list.dtype




You can specify the dtype of the created array by specifying the dtype
attribute in the the array function




Module1 2

, Module 1 - numpy 2024




1 import numpy as np
2 lis_marks=[40,67,89,45,67]
3 numpy_list_f=np.array(lis_marks, dtype=float)
4 print(numpy_list_f.dtype)




You can see from the result the numpy array has a float data type now.
The default one provided from the previous code is an integer.

Creating arrays from scratch We can also create numpy arrays from
scratch using the built in functions such as zeros, ones

The zeros() function

The numpy's zeros function return an array filled with zeros. The
parameters expected by the function include;

Shape: This specificy the dimension of the array. It is a tuple of two
values specifying the the number of rows and columns of the array.

dtype: The datatype expected of the array such as int8. The default
datatype if not specefied is float64




Module1 3

Geschreven voor

Instelling
Vak

Documentinformatie

Geüpload op
10 maart 2025
Aantal pagina's
19
Geschreven in
2024/2025
Type
College aantekeningen
Docent(en)
Selina ochukut
Bevat
Alle colleges

Onderwerpen

$7.99
Krijg toegang tot het volledige document:

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kun je een ander document kiezen. Je kunt het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF

Maak kennis met de verkoper
Seller avatar
kiplangatkirui

Maak kennis met de verkoper

Seller avatar
kiplangatkirui Open university of kenya
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
-
Lid sinds
1 jaar
Aantal volgers
0
Documenten
1
Laatst verkocht
-

0.0

0 beoordelingen

5
0
4
0
3
0
2
0
1
0

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Bezig met je bronvermelding?

Maak nauwkeurige citaten in APA, MLA en Harvard met onze gratis bronnengenerator.

Bezig met je bronvermelding?

Veelgestelde vragen