0% found this document useful (0 votes)
14 views32 pages

Python Data Science Cheat Sheet

The document is a cheat sheet covering essential commands and functionalities for three Python libraries: NumPy, Pandas, and Matplotlib. It includes sections on array creation, data manipulation, statistical operations, and data visualization techniques. Additionally, it promotes joining an AI community for networking and skill enhancement.

Uploaded by

uh.umarhayyat
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views32 pages

Python Data Science Cheat Sheet

The document is a cheat sheet covering essential commands and functionalities for three Python libraries: NumPy, Pandas, and Matplotlib. It includes sections on array creation, data manipulation, statistical operations, and data visualization techniques. Additionally, it promotes joining an AI community for networking and skill enhancement.

Uploaded by

uh.umarhayyat
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

ADVANCED

P Y T HON

[Link]/ARTIFICIALINTELLIGENCE
NUMPY
Cheat Sheet

[Link]/ARTIFICIALINTELLIGENCE
1 . Basi c Commands

Importing NumPy and checking


its version:

[Link]/ARTIFICIALINTELLIGENCE
2. Array Creat i on
Creating NumPy arrays from lists and with
initial placeholders:

[Link]/ARTIFICIALINTELLIGENCE
3. Array At t ri but es

Getti ng an array' s shape and data type:

[Link]/ARTIFICIALINTELLIGENCE
4. I ndexi ng and Sl i ci ng

Indexing and slicing one-dimensional and


multi-dimensional arrays:

[Link]/ARTIFICIALINTELLIGENCE
5. Array Mani pul at i on

Vari ous ways to mani pul ate arrays such as


reshapi ng, stacki ng, and spl i tti ng:

[Link]/ARTIFICIALINTELLIGENCE
6. Ari t hmet i c Operat i ons
Performing addition, subtraction, multiplication,
division, and dot product on arrays:

[Link]/ARTIFICIALINTELLIGENCE
7. St at i st i cal Operat i ons
Calculating the mean, median, and standard deviation of an array:

[Link]/ARTIFICIALINTELLIGENCE
PANDAS
Cheat Sheet

[Link]/ARTIFICIALINTELLIGENCE
1 . Basi c Commands
Pandas is a software library for Python that provides tools
for data manipulation and analysis. It' s important to ensure
that the correct version of pandas is installed for
compatibility with your code.

- Importing Pandas:

- Checking Pandas Version:

[Link]/ARTIFICIALINTELLIGENCE
2. Dataframe Creation
Dataframes are two-dimensional labeled data structures
with columns potentially of different types.
You can think of it like a spreadsheet or SQL table.

- From a list:

- From a Dictionary:

[Link]/ARTIFICIALINTELLIGENCE
3. Dat a Sel ect i on
Pandas provides different methods for data selection.

- Selecting a column:

- Selecting multiple columns:

[Link]/ARTIFICIALINTELLIGENCE
- Selecting rows:

- Selecting specific value:

[Link]/ARTIFICIALINTELLIGENCE
4. Dat a Mani pul at i on
P a n das p r o v i d e v a r i o u s w a ys to manipulate a dataset.

- A dding a c ol u m n :

- Deleting a column:

[Link]/ARTIFICIALINTELLIGENCE
- Renaming columns:

- Applying a function to a column:

[Link]/ARTIFICIALINTELLIGENCE
5. Dat a Cl eani ng
D a t a cle a n i n g i s d e t e c t i n g and correcting (or removing)
c o r rupt o r i n ac c u r a t e r e c o rds from a dataset.

- C hecki n g f or n u l l v a l u e s :

- D roppi n g n ul l v a l u e s :

[Link]/ARTIFICIALINTELLIGENCE
F i l ling n u l l v al u e s :

- Replacing values:

[Link]/ARTIFICIALINTELLIGENCE
6. Groupi ng & Aggregat i on
G r o upi n g i n v o l v e s c o m b i n i ng data based on some criteria,
w h i le ag g r e g at i o n i s t h e p rocess of turning the results of a
q u e ry in t o a si n g l e r o w .

- G roup b y :

- A ggreg a t i o n:

[Link]/ARTIFICIALINTELLIGENCE
7. Mergi ng, Joi ni ng, and
Concat enat i ng

Pandas provides various ways to combine DataFrames


including merge and join.

- Concatenating:

[Link]/ARTIFICIALINTELLIGENCE
- Merging:

- Joining:

[Link]/ARTIFICIALINTELLIGENCE
8. Worki ng wi t h Dat es
Pandas provides powerful functionalities for working with
dates.
- Convert to datetime:

- Extracting date parts:

[Link]/ARTIFICIALINTELLIGENCE
9. Fi l e I /O
Pandas can seamlessly read from and write to a variety
of file formats.

- Reading a CSV file:

- Writing to a CSV file:

- Similarly for other file formats like

[Link]/ARTIFICIALINTELLIGENCE
MATPL O T L I B
Cheat Sheet

[Link]/ARTIFICIALINTELLIGENCE
1 . Basi c Commands
Matplotlib is a plotting library for the Python programming
language and its numerical mathematics extension NumPy.

- Importing Matplotlib:

Checking Matplotlib version:

[Link]/ARTIFICIALINTELLIGENCE
2. Basi c Pl ot t i ng

Matplotlib provides functionalities for various types of


plots.

[Link]/ARTIFICIALINTELLIGENCE
3. Fi gure and Axes
A figure in matplotlib means the whole window in the user
interface. Axis are the number-line-like objects and they
take care of generating the graph limits.

- Creating Figure and Axes: - Setting Figure Size:

-Setting Axis Labels and Title:

[Link]/ARTIFICIALINTELLIGENCE
4. Cust omi zi ng Pl ot s
Matplotlib allows you to customize various aspects of
your plots.

- Changing Line Style and Color:

- Adding Grid: - Setting Axis Limits:

[Link]/ARTIFICIALINTELLIGENCE
5. Mul t i pl e Pl ot s
Matplotlib provides functionalities to create multiple
plots in a single figure.

- Subplots:

- Sharing Axis:

[Link]/ARTIFICIALINTELLIGENCE
6. Text and Annot at i ons
Matplotlib provides functionalities to add text and
annotations to the plots.

- Adding Text:

- Adding Annotations:

[Link]/ARTIFICIALINTELLIGENCE
7. Savi ng Fi gures
Matplotlib provides the savefig() function to save the
current figure to a file.

- Saving Figures as PNG, PDF, SVG, and more:

[Link]/ARTIFICIALINTELLIGENCE
Joi n Our AI Communi t y

Being part of an AI community like ours offers


multiple benefits. You can network with like-
minded individuals, learn from experienced
professionals, and stay up-to-date with the
latest AI trends and developments.

Whether you're a beginner looking to start your


journey in AI, or an experienced professional
looking to enhance your skills, our community
has something to offer.

Join us and be a part of this exciting journey.


Learn more, Grow more!

Click the link in the footer to join us today!

[Link]/ARTIFICIALINTELLIGENCE

You might also like