Python
Python_EX-003. how to extract a condition dataset
X25WLK
2025. 1. 21. 10:23
import numpy as np
# INPUT : SCORE
ClassA = [10, 50, 70, 30]
ClassB = [30, 40, 50, 60]
ClassC = [76, 78, 92, 30]
ClassD = [32, 45, 64, 42]
A = np.array(ClassA).reshape(1,4)
B = np.array(ClassB).reshape(1,4)
C = np.array(ClassC).reshape(1,4)
D = np.array(ClassD).reshape(1,4)
Score = np.concatenate( (A, B, C, D), axis=0)
print("""Score :
""", Score)
#path = ''
#data = np.loadtxt(path, delimiter=',')
cond = Score[:,0] > 55
out = Score[cond, :] #Extract Data that can meet the given condition
print("""
First Score > 55:
""", out)
RESULT
Score :
[[10 50 70 30]
[30 40 50 60]
[76 78 92 30]
[32 45 64 42]]
First Score > 55:
[[76 78 92 30]]
반응형