Skip to content

Commit 8706d14

Browse files
committed
Statistics, CSV
1 parent f8bea86 commit 8706d14

File tree

1 file changed

+30
-4
lines changed

1 file changed

+30
-4
lines changed

README.md

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,11 @@ from math import inf, nan, isinf, isnan
412412
float('inf'), float('nan')
413413
```
414414

415+
### Statistics
416+
```python
417+
from statistics import mean, median, variance, pvariance, pstdev
418+
```
419+
415420
### Random
416421
```python
417422
from random import random, randint, choice, shuffle
@@ -1088,6 +1093,28 @@ Recursion Limit
10881093
```
10891094

10901095

1096+
CSV
1097+
---
1098+
```python
1099+
import csv
1100+
```
1101+
1102+
### Read Rows from CSV File
1103+
```python
1104+
def read_csv_file(filename):
1105+
with open(filename, encoding='utf-8') as file:
1106+
return csv.reader(file, delimiter=';')
1107+
```
1108+
1109+
### Write Rows to CSV File
1110+
```python
1111+
def write_to_csv_file(filename, rows):
1112+
with open(filename, 'w', encoding='utf-8') as file:
1113+
writer = csv.writer(file, delimiter=';')
1114+
writer.writerows(rows)
1115+
```
1116+
1117+
10911118
JSON
10921119
----
10931120
```python
@@ -1366,8 +1393,8 @@ from itertools import *
13661393
>>> chain([1, 2], range(3, 5))
13671394
[1, 2, 3, 4]
13681395

1369-
>>> compress('abc', [True, 0, 1])
1370-
['a', 'c']
1396+
>>> compress([1, 2, 3, 4], [True, False, 1, 0])
1397+
[1, 3]
13711398

13721399
>>> # islice(<collection>, from_inclusive, to_exclusive)
13731400
>>> islice([1, 2, 3], 1, None)
@@ -1468,8 +1495,7 @@ class MyMetaClass(type):
14681495

14691496
```python
14701497
class MyClass(metaclass=MyMetaClass):
1471-
def __init__(self):
1472-
self.b = 12345
1498+
b = 12345
14731499
```
14741500

14751501

0 commit comments

Comments
 (0)