1
0

More than 3 years have passed since last update.

Python Basic - Pandas, Numpy -

Last updated at Posted at 2020-04-28

0. 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.

1. 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
image.png

Omit

data = np.arange(start, stop, step)
data

Output
image.png

Combination of reshape() method

data = np.arange(start, stop, step).reshape(4,5)
data

Output
image.png

Combination of array() method

title = np.array(['UserId', 'SomethingId', 'ProductName', 'Price', 'Ratings'])
df = pd.DataFrame(data, columns=title)
df

Output
image.png

Pick up (Slice) specific data

df_part = pd.DataFrame(data[:, 3:], columns=title[3:])
df_part

Output
image.png

df_part = pd.DataFrame(data[:, :3], columns=title[:3])
df_part

Output
image.png

2. Pandas

Pandas is a library providing fast, flexible, and expressive way to work with a relational or table of data, both easily and intuitive. It allows you to process your data in a way similar to SQL. Scikit-learn is a library of classic machine learning algorithms. It features various classification, regression, and clustering algorithms, including support virtual machines, random force, and a lot more.

concat() method

pandas.concat

df12 = pd.concat([df_part2, df_part1], axis=1)
df12

Output
image.png

References:

LINKS

-Numpy-Official
-Pandas-Official
-PythonでNumPyのarange関数を利用する方法を現役エンジニアが解説【初心者向け】
-GitHub : neural-style
-GitHub : Fast Style Transfer in TensorFlow

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0