Built-in Python Functions Used in the Notebooks
1. print(value) – Displays output to the console.
2. type(variable) – Returns the data type of a variable.
3. all(iterable) – Returns True if all elements in an iterable are True.
4. filter(function, iterable) – Filters elements based on a condition.
5. format(value, format_spec) – Formats a value according to a specified
format.
6. help(object) – Displays the documentation for a function or module.
7. object() – The base class for all Python objects.
8. display(value) – Displays rich outputs (used in Jupyter notebooks).
9. del variable – Deletes a variable from memory.
10. True / False – Boolean values used in logical operations.
NumPy Operations (Arrays & Matrices)
1. import numpy as np – Imports the NumPy library.
2. np.array([values]) – Creates a NumPy array.
3. np.arange(start, stop, step) – Generates a sequence of numbers as an array.
4. np.reshape(array, (rows, cols)) – Reshapes a 1D array into a 2D matrix.
5. array[row, col] – Accesses an element in a 2D array.
6. array[row, :] – Accesses an entire row.
7. array[:, col] – Accesses an entire column.
8. array[start_row:end_row, start_col:end_col] – Extracts a sub-matrix.
________________________________________
Pandas Operations (Data Handling)
9. import pandas as pd – Imports the Pandas library.
10. pd.Series([values]) – Creates a Pandas Series (1D data structure).
11. pd.DataFrame({'column': [values]}) – Creates a DataFrame from a dictionary.
12. df.head(n) – Displays the first n rows of the DataFrame.
13. df.tail(n) – Displays the last n rows of the DataFrame.
14. df.info() – Displays column names, data types, and missing values.
15. df.describe() – Provides summary statistics of numerical columns.
16. df.shape – Returns the number of rows and columns.
17. df.columns – Lists column names.
18. df.dtypes – Lists the data types of all columns.
19. df['column_name'] – Selects a single column.
20. df[['col1', 'col2']] – Selects multiple columns.
21. df.iloc[row_index, col_index] – Selects data using index positions.
22. df.loc[row_label, col_label] – Selects data using label names.
23. df.sort_values(by='column', ascending=True) – Sorts the DataFrame.
24. df['new_col'] = df['col1'] + df['col2'] – Creates a new column based on
existing ones.
25. df.drop(columns=['col1', 'col2']) – Removes columns.
26. df.drop(index=[row1, row2]) – Removes rows.
27. df.fillna(value) – Fills missing values with a specific value.
28. df.dropna() – Removes rows with missing values.
29. df.isnull().sum() – Counts missing values in each column.
30. df.duplicated() – Checks for duplicate rows.
31. df.drop_duplicates() – Removes duplicate rows.
32. df.groupby('column_name').agg({'col1': 'sum', 'col2': 'mean'}) – Groups data
and applies aggregations.
33. df.to_csv("file.csv", index=False) – Saves the DataFrame as a CSV file.
34. df.to_excel("file.xlsx", index=False) – Saves the DataFrame as an Excel file.
________________________________________
File Importing & Exporting
35. df = pd.read_csv("file.csv") – Reads a CSV file into a DataFrame.
36. df = pd.read_excel("file.xlsx") – Reads an Excel file into a DataFrame.
37. df = pd.read_json("file.json") – Reads a JSON file into a DataFrame.
38. df.to_json("file.json") – Saves a DataFrame as a JSON file.
39. df = pd.read_html("https://example.com") – Reads tables from a webpage into a
DataFrame.
40. df.to_html("file.html") – Saves a DataFrame as an HTML table.
________________________________________
Data Manipulation
41. df['column'].str.lower() – Converts text to lowercase.
42. df['column'].str.upper() – Converts text to uppercase.
43. df['column'].str.contains("word") – Checks if a column contains a specific
word.
44. df['date_column'] = pd.to_datetime(df['date_column']) – Converts a column to
datetime format.
45. df['year'] = df['date_column'].dt.year – Extracts the year from a datetime
column.
46. df['month'] = df['date_column'].dt.month – Extracts the month from a datetime
column.
47. df['day'] = df['date_column'].dt.day – Extracts the day from a datetime column.
________________________________________
Data Merging & Concatenation
48. pd.concat([df1, df2], axis=0) – Concatenates DataFrames vertically.
49. pd.concat([df1, df2], axis=1) – Concatenates DataFrames horizontally.
50. pd.merge(df1, df2, on='key', how='inner') – Merges two DataFrames with an inner
join.
51. pd.merge(df1, df2, on='key', how='left') – Left join, keeps all rows from df1.
52. pd.merge(df1, df2, on='key', how='right') – Right join, keeps all rows from
df2.
53. pd.merge(df1, df2, on='key', how='outer') – Outer join, keeps all rows from
both.
________________________________________
Matplotlib & Seaborn (Data Visualization)
54. import matplotlib.pyplot as plt – Imports Matplotlib for plotting.
55. import seaborn as sns – Imports Seaborn for statistical visualization.
56. plt.figure(figsize=(width, height)) – Creates a figure with a specific size.
57. sns.histplot(df['column'], bins=20) – Creates a histogram of a column.
58. sns.boxplot(x='col1', y='col2', data=df) – Creates a box plot.
59. sns.scatterplot(x='col1', y='col2', data=df) – Creates a scatter plot.
60. sns.countplot(x='column', data=df) – Creates a count plot for categorical data.
61. sns.heatmap(df.corr(), annot=True) – Plots a correlation heatmap.
62. plt.xlabel("X-axis Label") – Sets the x-axis label.
63. plt.ylabel("Y-axis Label") – Sets the y-axis label.
64. plt.title("Plot Title") – Sets the title of the plot.
65. plt.show() – Displays the plot.