LoginSignup
0
1

More than 3 years have passed since last update.

【データ・サイエンティストPython 小ネタ帳】メモ

Last updated at Posted at 2019-10-14

データ・サイエンティストで必須となる技術で、これを知ってるとちょっと便利という小ネタを集めてみます。

Numpy

np.arange(10)
# array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])

np.arange(0,20,2)
# array([0, 2, 4, 6, 8, 10, 12, 14, 16, 18])

np.arange(1,10).reshape((3,3))
# array([[1, 2, 3],
#        [4, 5, 6],
#        [7, 8, 9]])

これは1次元リスト(list)から配列(array)へ変更の常套手段。

リスト内包表記

base = [1,2,3,4]
new = [i*2 for i in base]
print(new)

[2, 4, 6, 8]

Ref.

https://note.nkmk.me/python-list-array-numpy-ndarray/
https://tanuhack.com/create-ndarray/
https://qiita.com/kaeruair/items/e7f1c08915839ce3c9b4
https://qiita.com/okkn/items/54e81346d8f35733ab5e
Pandas; drop();
https://note.nkmk.me/python-pandas-drop/

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