tsuji.tech
  • Posts
  • About
  • |
  • EN
  • |
LIGHT DARK
  • Home
  • /
  • Posts
  • /
  • Python

PythonのNumpyブーリアンインデックス

Dec 19, 2024
Table of Contents
  • ブーリアン配列インデックス
  • リファレンス

ブーリアン配列インデックス

import numpy as np

# Create a 2D array
array_2d = np.array([[0, -1, 2], [-3, 4, -5]])

# Replace elements less than or equal to 0 with 0
array_2d[array_2d <= 0] = 0

print(array_2d)
# [[0 0 2]
#  [0 4 0]]

リファレンス

  • Numpyユーザーガイド
 
About / 免責事項 / プライバシーポリシー / サイトマップ / コンタクト /
© 2024-2025 K. Tsuji