Python Forum
How to calculate variance(standard deviation) by column
Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to calculate variance(standard deviation) by column
#1
Hi,
I have below data (DataFrame), and want to calculate variance(standard deviation) by column & and by name

Name    V1    V2    V3   V4
AABB    1.23  1.56  2.6  7.3
ABAB    5.23  3.56  2.6  7.8
AABB    2.23  6.56  4.6  5.8
AABC    2.23  1.56  2.6  5.8
ABAB    5.43  3.66  1.9  6.8
AABC    0.23  7.56  7.1  8.3
AABB    2.23  1.56  2.6  5.8


Desired output(Standard deviation):

Name	V1	    V2	      V3	V4
AABB	0.577 	2.887 	1.155 	0.866 
AABC	1.414 	4.243 	3.182 	1.768 
ABAB	0.141 	0.071 	0.495 	0.707 
DataFrame.var() is only giving me the overall(not by name), I Want by name.
Reply
#2
what have you tried so far?
show code
Reply
#3
Tried code is below, but it can not give me the output by group

DataFrame.var()
Desired output(Standard deviation):
 
Name    V1      V2        V3    V4
AABB    0.577   2.887   1.155   0.866 
AABC    1.414   4.243   3.182   1.768 
ABAB    0.141   0.071   0.495   0.707 
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Calculate column with cumulative return tgottsc1 1 1,849 Jan-25-2021, 12:52 PM
Last Post: buran
  Monthly sales, standard deviation Lyle 3 2,457 Aug-07-2020, 10:33 PM
Last Post: Lyle
  Winsorized Mean and Standard Deviation Wheeliam 0 1,812 Jul-11-2020, 05:27 PM
Last Post: Wheeliam
  standard library modules chpyel 4 2,805 May-10-2020, 02:58 PM
Last Post: snippsat
  How to calculate column mean and row skip non numeric and na Mekala 5 4,910 May-06-2020, 10:52 AM
Last Post: anbu23
  How to calculate unique rows column sum and percentage SriRajesh 4 3,453 Feb-12-2020, 02:21 PM
Last Post: SriRajesh
  Is there a standard for autocommit In PEP 249 zatlas1 10 5,201 Feb-06-2019, 04:56 PM
Last Post: buran
  Graphics and standard deviation rocioaraneda 3 2,702 Jan-09-2019, 10:53 PM
Last Post: micseydel
  standard data types rombertus 3 59,394 Dec-23-2018, 08:52 PM
Last Post: rombertus
  Realized variance and daily probability distribution petergarylee 1 2,436 Jul-06-2018, 02:21 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020