Introduction of Numpy NumPy is a Python package. It stands for 'Numerical Python', and Numpy is a linear algebra library to work with dimensional arrays, which contains useful linear algebra routines and random number capabilities.
Numpy arrange() method The arange() method in the Numpy module in Python is used to generate linear sequence of numbers. If does it on the basis of the pre-provide starting and ending points along with a constant step size.
Syntax
import numpy as np
start = 1 # default 0
stop = 21
step = 1 # default 1
none = int
np.arange(start, stop, step, dtype=none)
Output
Omit
data = np.arange(start, stop, step)
data
Output
Combination of reshape() method
data = np.arange(start, stop, step).reshape(4,5)
data
Output
Combination of array() method
title = np.array(['UserId', 'SomethingId', 'ProductName', 'Price', 'Ratings'])
df = pd.DataFrame(data, columns=title)
df
Output
Pick up (Slice) specific data
df_part = pd.DataFrame(data[:, 3:], columns=title[3:])
df_part
Output
df_part = pd.DataFrame(data[:, :3], columns=title[:3])
df_part
Output
concat() method
df12 = pd.concat([df_part2, df_part1], axis=1)
df12
Output
References: LINKS
-Numpy-Official -Pandas-Official -Active engineers explain how to use NumPy's arrange function in Python [for beginners] -GitHub : neural-style -GitHub : Fast Style Transfer in TensorFlow
Recommended Posts