To substitute values for the number of rows and columns in a csv file

Asked 1 years ago, Updated 1 years ago, 285 views

There is a multi-line multi-column csv file called da_all (this time 12170), but it takes a lot of time because I manually re-shaped it every time after making it into a single column with label in the following program.Is there a way to substitute 12 or 170 using da_all?

da_all1=np.ravel(da_all)[None,:].T
sc=StandardScaler()
data_del_stand=sc.fit_transform(da_all1)
data=scaler.transform(data_del_stand)
data=data.T.reshape (12,170)

python python3 jupyter-notebook

2022-09-30 21:54

1 Answers

If you want to return to the same shape, why don't you use numpy.ndarray.shape to get the number of dimensions and elements and specify it when numpy.reshape before processing?

 Obtain and record orgshape=da_all.shape####shape

da_all1 = np.ravel(da_all) [None, :].T
sc=StandardScaler()
data_del_stand=sc.fit_transform(da_all1)
data=scaler.transform(data_del_stand)

specified at data=data.T.reshape(orgshape)####reshape


2022-09-30 21:54

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.