import pandas as pd
df1 = pd.DataFrame({'val1': [1, 2]}, index=['A', 'B'])
df2 = pd.DataFrame({'val2': [3, 4]}, index=['A', 'B'])
joined = df1.join(df2)
print(joined)
val1 val2
A 1 3
B 2 4
#59.
pd.get_dummies()Converts categorical variable into dummy/indicator variables (one-hot encoding).
import pandas as pd
s = pd.Series(list('abca'))
dummies = pd.get_dummies(s)
print(dummies)
a b c
0 1 0 0
1 0 1 0
2 0 0 1
3 1 0 0
#60.
df.nlargest()Returns the first n rows ordered by columns in descending order.
import pandas as pd
df = pd.DataFrame({'population': [100, 500, 200, 800]})
print(df.nlargest(2, 'population'))
population
3 800
1 500
---
#DataAnalysis #NumPy #Arrays
Part 6: NumPy - Array Creation & Manipulation
#61.
np.array()Creates a NumPy ndarray.
import numpy as np
arr = np.array([1, 2, 3])
print(arr)
[1 2 3]
#62.
np.arange()Returns an array with evenly spaced values within a given interval.
import numpy as np
arr = np.arange(0, 5)
print(arr)
[0 1 2 3 4]
#63.
np.linspace()Returns an array with evenly spaced numbers over a specified interval.
import numpy as np
arr = np.linspace(0, 10, 5)
print(arr)
[ 0. 2.5 5. 7.5 10. ]
#64.
np.zeros()Returns a new array of a given shape and type, filled with zeros.
import numpy as np
arr = np.zeros((2, 3))
print(arr)
[[0. 0. 0.]
[0. 0. 0.]]
#65.
np.ones()Returns a new array of a given shape and type, filled with ones.
import numpy as np
arr = np.ones((2, 3))
print(arr)
[[1. 1. 1.]
[1. 1. 1.]]
#66.
np.random.rand()Creates an array of the given shape and populates it with random samples from a uniform distribution over [0, 1).
import numpy as np
arr = np.random.rand(2, 2)
print(arr)
[[0.13949386 0.2921446 ]
[0.52273283 0.77122228]]
(Note: Output values will be random)
#67.
arr.reshape()Gives a new shape to an array without changing its data.
import numpy as np
arr = np.arange(6)
reshaped_arr = arr.reshape((2, 3))
print(reshaped_arr)
[[0 1 2]
[3 4 5]]
#68.
np.concatenate()Joins a sequence of arrays along an existing axis.
import numpy as np
a = np.array([[1, 2]])
b = np.array([[3, 4]])
print(np.concatenate((a, b), axis=0))
[[1 2]
[3 4]]
#69.
np.vstack()Stacks arrays in sequence vertically (row wise).
import numpy as np
a = np.array([1, 2])
b = np.array([3, 4])
print(np.vstack((a, b)))
[[1 2]
[3 4]]
#70.
np.hstack()Stacks arrays in sequence horizontally (column wise).
import numpy as np
a = np.array([1, 2])
b = np.array([3, 4])
print(np.hstack((a, b)))
[1 2 3 4]
---
#DataAnalysis #NumPy #Math #Statistics
Part 7: NumPy - Mathematical & Statistical Functions
#71.
np.mean()Computes the arithmetic mean along the specified axis.
import numpy as np
arr = np.array([1, 2, 3, 4, 5])
print(np.mean(arr))
3.0
#72.
np.median()Computes the median along the specified axis.
import numpy as np
arr = np.array([1, 2, 3, 4, 5])
print(np.median(arr))
3.0
#73.
np.std()Computes the standard deviation along the specified axis.
Amazing NumPy Cheat Sheet.pdf
259.7 KB
Amazing NumPy Cheat Sheet Snippet with 100 exercises for practicing the concept to get hands on to clear the coding round in the interviews
#NumPy #codingexams
https://xn--r1a.website/CodeProgrammer
#NumPy #codingexams
https://xn--r1a.website/CodeProgrammer
β€9π5π₯3π1
Numpy @CodeProgrammer.pdf
2.4 MB
π¨π»βπ» This is a long-term project to learn Python and NumPy from scratch. The main task is to handle numerical #data and #arrays in #Python using NumPy, and many other libraries are also used.
https://xn--r1a.website/CodeProgrammer
Please open Telegram to view this post
VIEW IN TELEGRAM
β€12π4π3
Forwarded from Machine Learning
A convenient cheat sheet for those who work with data analysis and ML.
Here are collected the main functions for:
βΆοΈ Creating and modifying arrays;βΆοΈ Mathematical operations;βΆοΈ Working with matrices and vectors;βΆοΈ Sorting and searching for values.
Save it for yourself β it will come in handy when working with NumPy.
tags: #NumPy #Python
Please open Telegram to view this post
VIEW IN TELEGRAM
β€10π2
Numpy_Cheat_Sheet.pdf
4.8 MB
NumPy Cheat Sheet: Data Analysis in Python
This #Python cheat sheet is a quick reference for #NumPy beginners.
Learn more:
https://www.datacamp.com/cheat-sheet/numpy-cheat-sheet-data-analysis-in-python
https://xn--r1a.website/DataAnalyticsX
This #Python cheat sheet is a quick reference for #NumPy beginners.
Learn more:
https://www.datacamp.com/cheat-sheet/numpy-cheat-sheet-data-analysis-in-python
https://xn--r1a.website/DataAnalyticsX
β€10π1π₯1π1
Pandas-Cheat-Sheet.pdf
2.7 MB
This cheat sheetβpart of our Complete Guide to #NumPy, #pandas, and #DataVisualizationβoffers a handy reference for essential pandas commands, focused on efficient #datamanipulation and analysis. Using examples from the Fortune 500 Companies #Dataset, it covers key pandas operations such as reading and writing data, selecting and filtering DataFrame values, and performing common transformations.
You'll find easy-to-follow examples for grouping, sorting, and aggregating data, as well as calculating statistics like mean, correlation, and summary statistics. Whether you're cleaning datasets, analyzing trends, or visualizing data, this cheat sheet provides concise instructions to help you navigate pandasβ powerful functionality.
Designed to be practical and actionable, this guide ensures you can quickly apply pandasβ versatile data manipulation tools in your workflow.
https://xn--r1a.website/CodeProgrammer
You'll find easy-to-follow examples for grouping, sorting, and aggregating data, as well as calculating statistics like mean, correlation, and summary statistics. Whether you're cleaning datasets, analyzing trends, or visualizing data, this cheat sheet provides concise instructions to help you navigate pandasβ powerful functionality.
Designed to be practical and actionable, this guide ensures you can quickly apply pandasβ versatile data manipulation tools in your workflow.
https://xn--r1a.website/CodeProgrammer
β€8π3π₯1π1πΎ1
π Demystifying Activation Functions! π§ β¨
Ever wondered why activation functions are so critical in neural networks? π€π€
Theyβre the secret sauce that allows models to capture complex, nonlinear relationships! π₯π
Do you want to learn how to implement an artificial neural network from scratch in Python using NumPy? ππ
Learn more in super-detailed guide: https://lnkd.in/e4CydTtB ππ
#NeuralNetworks #DeepLearning #ActivationFunctions #Python #NumPy #AI
Ever wondered why activation functions are so critical in neural networks? π€π€
Theyβre the secret sauce that allows models to capture complex, nonlinear relationships! π₯π
Do you want to learn how to implement an artificial neural network from scratch in Python using NumPy? ππ
Learn more in super-detailed guide: https://lnkd.in/e4CydTtB ππ
#NeuralNetworks #DeepLearning #ActivationFunctions #Python #NumPy #AI
β€6π₯2π1