The exact value cannot be found in pandas.agg (['mean']).

Asked 1 years ago, Updated 1 years ago, 351 views

実行 Execution Environment
Windows 10 Python 3.X
pandas

This is the continuation of the question on this link.
Pandas cannot retrieve data under certain conditions.
リンクLinked Questions
In the link above, we were able to use pandas to ask which "classification" each id belongs to in the column, and we were able to use groupby to get the classification and numbers for each id.

質問Contents of questions
I was able to get the following dfx from the above question:

ddfx (csv format for easy separation)

 id, numeric, classification
aaa, 3141, type 2
bbb, 5926, type 1
ccc,5358, type 3
ddd,9793,type1
eee, 2384, type 3
fff, 6264, type 2
ggg, 3383, type 2
hhh,2795,type1
iii, 288, type 3
jjj, 4197, type 1
kkk,1693,type3
lll,9937,type2
mmm, 5105, type 2
nnn, 8209, type 1

"From this data, we would like to find the maximum, minimum, and average values for each of the three elements of the column ""classification."""
I was able to find the maximum and minimum values from the following sources, but the numbers were larger than the average and clearly strange.

The minimum and maximum values were required, so I don't think the data values are incorrect.
Is there anything wrong?

# Find the average value
dfx_mean=dfx.groupby('classification').agg(['mean'])

出力 Output value
''
mean
Classification
type 18886377.5
type22.76252E+86
type31.85807E+15
''

python pandas

2023-01-04 19:41

1 Answers

If only the result of agg([mean']) is suspicious, you may have rewritten the action (for some reason).
If dfx content is saved in a CSV format (for example) and agg([mean']) is read in a different environment with the correct value, the cause is probably "process replaced."
(If it fails in a different environment, try adding instructions to the question.)


2023-01-04 21:28

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.