Pandas按行遍历DataFrame的3种方法
import pandas as pd
import numpy as np
import collections
df = pd.DataFrame(
np.random.random(size=(100000, 4)),
columns=list('ABCD')
)
df.head(3)
A | B | C | D | |
---|---|---|---|---|
0 | 0.329292 | 0.975468 | 0.133584 | 0.224582 |
1 | 0.535746 | 0.451585 | 0.713250 | 0.409770 |
2 | 0.735287 | 0.667472 | 0.950622 | 0.245938 |
df.shape
(100000, 4)