You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -152,15 +152,16 @@ Let us now understand the functions under Descriptive Statistics in Python Panda
152
152
```python
153
153
154
154
155
-
The following table list down the important functions − S.No. Function Description
155
+
The following table list down the important functions
156
+
156
157
1. count() Number of non-null observations
157
158
2. sum() Sum of values
158
159
3. mean() Mean of Values
159
160
4. median() Median of Values
160
161
5. mode() Mode of values
161
162
6. std() Standard Deviation of the Values
162
-
7.min() Minimum Value
163
-
8. max() Maximum Value
163
+
7.min() Minimum Value
164
+
8. max() Maximum Value
164
165
9. abs() Absolute Value
165
166
10. prod() Product of Values
166
167
11. cumsum() Cumulative Sum
@@ -180,10 +181,16 @@ The ``describe()`` function computes a summary of statistics pertaining to the D
180
181
181
182
182
183
```python
183
-
import pandas as pd import numpy as np
184
-
#Create a Dictionary of series d = {'Name':pd.Series(['Tom','James','Ricky','Vin','Steve','Smith','Jack', 'Lee','David','Gasper','Betina','Andres']), 'Age':pd.Series([25,26,25,23,30,29,23,34,40,30,51,46]), 'Rating':pd.Series([4.23,3.24,3.98,2.56,3.20,4.6,3.8,3.78,2.98,4.80,4.10,3.65])}
185
-
#Create a DataFrame df = pd.DataFrame(d)
186
-
print df.describe()
184
+
import pandas as pd
185
+
import numpy as np
186
+
#Create a Dictionary of series
187
+
d = {'Name':pd.Series(['Tom','James','Ricky','Vin','Steve','Smith','Jack', 'Lee','David','Gasper','Betina','Andres']),
@@ -200,6 +207,11 @@ Takes the list of values; by default, 'number'. object − Summarizes String col
200
207
201
208
Now, use the following statement in the program and check the output − import pandas as pd import numpy as np
202
209
#Create a Dictionary of series
210
+
```
211
+
212
+
213
+
```python
214
+
203
215
d = {'Name':pd.Series(['Tom','James','Ricky','Vin','Steve','Smith','Jack', 'Lee','David','Gasper','Betina','Andres']), 'Age':pd.Series([25,26,25,23,30,29,23,34,40,30,51,46]), 'Rating':pd.Series([4.23,3.24,3.98,2.56,3.20,4.6,3.8,3.78,2.98,4.80,4.10,3.65])}
204
216
#Create a DataFrame df = pd.DataFrame(d) print df.describe(include=['object']) Its output is as follows − Name count 12 unique 12 top Ricky freq 1
205
217
@@ -217,10 +229,27 @@ Now, use the following statement and check the output −
217
229
218
230
import pandas as pd
219
231
import numpy as np
220
-
#Create a Dictionary of series d = {'Name':pd.Series(['Tom','James','Ricky','Vin','Steve','Smith','Jack', 'Lee','David','Gasper','Betina','Andres']), 'Age':pd.Series([25,26,25,23,30,29,23,34,40,30,51,46]), 'Rating':pd.Series([4.23,3.24,3.98,2.56,3.20,4.6,3.8,3.78,2.98,4.80,4.10,3.65])}
221
-
#Create a DataFrame df = pd.DataFrame(d)
222
-
print df. describe(include='all')
232
+
#Create a Dictionary of series
233
+
d = {'Name':pd.Series(['Tom','James','Ricky','Vin','Steve','Smith','Jack', 'Lee','David','Gasper','Betina','Andres']),
Its output isas follows − Age Name Rating count 12.0000001212.000000 unique NaN 12 NaN top NaN Ricky NaN freq NaN 1 NaN mean 31.833333 NaN 3.743333 std 9.232682 NaN 0.661628min23.000000 NaN 2.56000025%25.000000 NaN 3.23000050%29.500000 NaN 3.79000075%35.500000 NaN 4.132500max51.000000 NaN 4.800000
Note − Because iterrows() iterate over the rows, it doesn't preserve the data type across the row. 0,1,2 are the row indices and col1,col2,col3 are column indices.
122
126
123
-
```
124
127
125
128
126
129
```python
127
130
itertuples()
128
131
itertuples() method will return an iterator yielding a named tuplefor each row in the DataFrame. The first element of the tuple will be the row’s corresponding index value, while the remaining values are the row values.
Note − Do not try to modify any object while iterating. Iterating is meant for reading and the iterator returns a copy of the original object (a view), thus the changes will not reflect on the original object.
0 commit comments