- Example of Numpy data i/o
import numpy as np
# load txt
txt = np.loadtxt("./populations.txt")
txt[:10]
# Convert the imported txt to int type and load up to the 3rd index
txt_int = txt.astype(int)
txt_int[:3]
# save txt
np.savetxt('int_data.csv', txt_int, delimiter=",")
- numpy object - npy
import numpy as np
np.save("npy_test", arr=txt_int)
# Load up to the 3rd index of the file
npy_array = np.load(file="npy_test.npy")
npy_array[:3]
'CS > Python' 카테고리의 다른 글
Pandas | Selection, index Change, Reindex, Data drop (0) | 2021.02.28 |
---|---|
Pandas (0) | 2021.02.27 |
Numerical Python - Numpy(3) (0) | 2021.02.20 |
Numerical Python - Numpy(2) (0) | 2021.02.20 |
Numerical Python - Numpy(1) (0) | 2021.02.18 |