일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- single cell analysis
- scRNAseq analysis
- single cell rnaseq
- PYTHON
- 싱글셀 분석
- python matplotlib
- single cell
- DataFrame
- 비타민 C
- ChIPseq
- matplotlib
- js
- cellranger
- ngs
- CUTandRUN
- CSS
- Batch effect
- drug development
- CUT&RUN
- drug muggers
- EdgeR
- scRNAseq
- MACS2
- Git
- julia
- HTML
- Bioinformatics
- pandas
- github
- javascript
Archives
- Today
- Total
바이오 대표
[ Python ] NumPy Array 데이터 csv (ASCII) 로 저장하기 (to_csv( ), savetxt( )) 본문
Python/array (numpy)
[ Python ] NumPy Array 데이터 csv (ASCII) 로 저장하기 (to_csv( ), savetxt( ))
바이오 대표 2022. 2. 6. 13:51
- to .csv (ASCII)
- to .npy (binary)
- to .npz (compressed)
Numpy arrary 를 csv 형태로 저장할 수 있는 방법에는 두가지가 있다.
[1] pandas 이용해서 dataframe으로 변경 후 df.to_csv( )
[2] np.savetxt( )
[1] pandas 이용해서 dataframe으로 변경 후 df.to_csv( )
import pandas as pd
# numpy array
arr
# numpy array to pandas dataframe
df = pd.DataFrame(arr)
df.to_csv("myArray.csv", index=Fase)
[2] np.savetxt( )
import numpy as np
np.savetxt("myArray.txt", arr)
3D tensor 을 저장할 때는 일단 2D 로 reshape 을 해줘야 한다.
* 데이터들을 저장하였을때, np.savetxt 가 좀 더 computationally 빠르게 작용하였다.
'Python > array (numpy)' 카테고리의 다른 글
[ Python ] 두개의 array 비교하기 (np.array_equal, (A==B).all()) (0) | 2022.03.13 |
---|---|
[ Python ] 구조의 재배열 numpy.reshape (0) | 2022.02.15 |