Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
74 views
in Technique[技术] by (71.8m points)

python - Decrease in data count when copying data from dataframe

I'm currently trying to pass in a bunch of activity ID values from my accelerometer dataset, however when I copied my data from the original data frame to a separate array, the count value decreases instead. Here is a picture of the data count from my original data frame: Balanced_input containing accelerometer data

So from the picture you can see that I should have 110856 counts of 6g hand XYZ accelerometer data and also 110856 counts of activity ID data (used to dictate what activity each patient is doing at an instance of time)

Below is my Python code:

# Standardize data
balanced_X = balanced_input[['Hand X 6g', 'Hand Y 6g', 'Hand Z 6g']]
balanced_Y = balanced_input['Activity ID']

scaler = StandardScaler()
balanced_X = scaler.fit_transform(balanced_X)

scaled_X = pd.DataFrame(data = balanced_X, columns = ['X', 'Y', 'Z'])
scaled_X['Activity ID'] = balanced_Y.to_numpy()
scaled_X['Activity ID'] = balanced_Y.values

scaled_X.count()

But the output I got was: output from Jupyter

Since I copied the 6g hand xyz data values to my new array, I should be getting 110856 counts of data, however that isn't the case.

I originally thought that the issue was caused by the ambiguity of the name (I had 2 different hand XYZ data, one was the 2g accelerometer data which has a different value count, and the other was 6g, which was the one I wanted), but I already made sure to name the array I wanted correctly when I copied my data from my original input data. Anyone know why is the code acting like this?

question from:https://stackoverflow.com/questions/65942760/decrease-in-data-count-when-copying-data-from-dataframe

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...