1
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【随時更新】データ分析によく使うPythonメモ【N分割等】

Last updated at Posted at 2020-06-23

#リストのデータをN分割する

from matplotlib import pyplot as plt
import numpy as np
import random

#任意の数の分割する(分割数, データリスト)
def division_datas(division_length, datas):
    sort_data = sorted(datas)
    datas = [sort_data[i:i+division_length] for i in range(0, len(datas), division_length)]
    return datas

#0~100のランダムな数値を100個生成する
my_data = [random.randint(0, 100) for i in range(100)]

#データを15分割してみる
division_data_ls = division_datas(15, my_data)
print(division_data_ls)
1
2
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
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?