pandas: powerful Python data analysis toolkit - 0.25NaN 1 2.0 NaN 2 4.0 3.0 3 NaN 4.0 4 3.0 6.0 5 7.0 8.0 In [75]: df1.combine_first(df2) Out[75]: A B 0 1.0 NaN 1 2.0 2.0 2 3.0 3.0 3 5.0 4.0 4 3.0 6.0 5 7.0 8.0 General DataFrame combine The combine_first() Out[194]: a six b seven c six d seven e six dtype: object In [195]: s.map(t) Out[195]: a 6.0 b 7.0 c 6.0 d 7.0 e 6.0 dtype: float64 3.3. Essential basic functionality 69 pandas: powerful Python data analysis [357]: dft1 = dft1.astype({'a': np.bool, 'c': np.float64}) In [358]: dft1 Out[358]: a b c 0 True 4 7.0 1 False 5 8.0 2 True 6 9.0 In [359]: dft1.dtypes Out[359]: a bool b int64 c float64 dtype: object0 码力 | 698 页 | 4.91 MB | 1 年前3
pandas: powerful Python data analysis toolkit - 1.4.2"by2"]) In [11]: g[["v1", "v2"]].mean() Out[11]: v1 v2 by1 by2 1 95 5.0 55.0 99 5.0 55.0 2 95 7.0 77.0 99 NaN NaN big damp 3.0 33.0 blue dry 3.0 33.0 red red 4.0 44.0 wet 1.0 11.0 For more details DataFrame( ....: { ....: "x": np.random.uniform(1.0, 168.0, 120), ....: "y": np.random.uniform(7.0, 334.0, 120), ....: "z": np.random.uniform(1.7, 20.7, 120), ....: "month": [5, 6, 7, 8] * 30, . pd.DataFrame( ....: { ....: "x": np.random.uniform(1.0, 168.0, 12), ....: "y": np.random.uniform(7.0, 334.0, 12), ....: "z": np.random.uniform(1.7, 20.7, 12), ....: "month": [5, 6, 7] * 4, ....: "week":0 码力 | 3739 页 | 15.24 MB | 1 年前3
pandas: powerful Python data analysis toolkit - 1.4.4"by2"]) In [11]: g[["v1", "v2"]].mean() Out[11]: v1 v2 by1 by2 1 95 5.0 55.0 99 5.0 55.0 2 95 7.0 77.0 99 NaN NaN big damp 3.0 33.0 blue dry 3.0 33.0 red red 4.0 44.0 wet 1.0 11.0 For more details DataFrame( ....: { ....: "x": np.random.uniform(1.0, 168.0, 120), ....: "y": np.random.uniform(7.0, 334.0, 120), ....: "z": np.random.uniform(1.7, 20.7, 120), ....: "month": [5, 6, 7, 8] * 30, . pd.DataFrame( ....: { ....: "x": np.random.uniform(1.0, 168.0, 12), ....: "y": np.random.uniform(7.0, 334.0, 12), ....: "z": np.random.uniform(1.7, 20.7, 12), ....: "month": [5, 6, 7] * 4, ....: "week":0 码力 | 3743 页 | 15.26 MB | 1 年前3
pandas: powerful Python data analysis toolkit - 1.3.2"by2"]) In [11]: g[["v1", "v2"]].mean() Out[11]: v1 v2 by1 by2 1 95 5.0 55.0 99 5.0 55.0 2 95 7.0 77.0 99 NaN NaN big damp 3.0 33.0 blue dry 3.0 33.0 red red 4.0 44.0 wet 1.0 11.0 For more details DataFrame( ....: { ....: "x": np.random.uniform(1.0, 168.0, 120), ....: "y": np.random.uniform(7.0, 334.0, 120), ....: "z": np.random.uniform(1.7, 20.7, 120), ....: "month": [5, 6, 7, 8] * 30, . pd.DataFrame( ....: { ....: "x": np.random.uniform(1.0, 168.0, 12), ....: "y": np.random.uniform(7.0, 334.0, 12), ....: "z": np.random.uniform(1.7, 20.7, 12), ....: "month": [5, 6, 7] * 4, ....: "week":0 码力 | 3509 页 | 14.01 MB | 1 年前3
pandas: powerful Python data analysis toolkit - 1.3.3"by2"]) In [11]: g[["v1", "v2"]].mean() Out[11]: v1 v2 by1 by2 1 95 5.0 55.0 99 5.0 55.0 2 95 7.0 77.0 99 NaN NaN big damp 3.0 33.0 blue dry 3.0 33.0 red red 4.0 44.0 wet 1.0 11.0 For more details DataFrame( ....: { ....: "x": np.random.uniform(1.0, 168.0, 120), ....: "y": np.random.uniform(7.0, 334.0, 120), ....: "z": np.random.uniform(1.7, 20.7, 120), ....: "month": [5, 6, 7, 8] * 30, . pd.DataFrame( ....: { ....: "x": np.random.uniform(1.0, 168.0, 12), ....: "y": np.random.uniform(7.0, 334.0, 12), ....: "z": np.random.uniform(1.7, 20.7, 12), ....: "month": [5, 6, 7] * 4, ....: "week":0 码力 | 3603 页 | 14.65 MB | 1 年前3
pandas: powerful Python data analysis toolkit - 1.3.4"by2"]) In [11]: g[["v1", "v2"]].mean() Out[11]: v1 v2 by1 by2 1 95 5.0 55.0 99 5.0 55.0 2 95 7.0 77.0 99 NaN NaN big damp 3.0 33.0 blue dry 3.0 33.0 red red 4.0 44.0 wet 1.0 11.0 For more details DataFrame( ....: { ....: "x": np.random.uniform(1.0, 168.0, 120), ....: "y": np.random.uniform(7.0, 334.0, 120), ....: "z": np.random.uniform(1.7, 20.7, 120), ....: "month": [5, 6, 7, 8] * 30, . pd.DataFrame( ....: { ....: "x": np.random.uniform(1.0, 168.0, 12), ....: "y": np.random.uniform(7.0, 334.0, 12), ....: "z": np.random.uniform(1.7, 20.7, 12), ....: "month": [5, 6, 7] * 4, ....: "week":0 码力 | 3605 页 | 14.68 MB | 1 年前3
pandas: powerful Python data analysis toolkit - 1.2.3"by2"]) In [11]: g[["v1", "v2"]].mean() Out[11]: v1 v2 by1 by2 1 95 5.0 55.0 99 5.0 55.0 2 95 7.0 77.0 99 NaN NaN big damp 3.0 33.0 blue dry 3.0 33.0 red red 4.0 44.0 wet 1.0 11.0 For more details DataFrame( ....: { ....: "x": np.random.uniform(1.0, 168.0, 120), ....: "y": np.random.uniform(7.0, 334.0, 120), ....: "z": np.random.uniform(1.7, 20.7, 120), ....: "month": [5, 6, 7, 8] * 30, . pd.DataFrame( ....: { ....: "x": np.random.uniform(1.0, 168.0, 12), ....: "y": np.random.uniform(7.0, 334.0, 12), ....: "z": np.random.uniform(1.7, 20.7, 12), ....: "month": [5, 6, 7] * 4, ....: "week":0 码力 | 3323 页 | 12.74 MB | 1 年前3
pandas: powerful Python data analysis toolkit - 1.2.0"by2"]) In [11]: g[["v1", "v2"]].mean() Out[11]: v1 v2 by1 by2 1 95 5.0 55.0 99 5.0 55.0 2 95 7.0 77.0 99 NaN NaN big damp 3.0 33.0 blue dry 3.0 33.0 red red 4.0 44.0 wet 1.0 11.0 For more details DataFrame( ....: { ....: "x": np.random.uniform(1.0, 168.0, 120), ....: "y": np.random.uniform(7.0, 334.0, 120), ....: "z": np.random.uniform(1.7, 20.7, 120), ....: "month": [5, 6, 7, 8] * 30, . pd.DataFrame( ....: { ....: "x": np.random.uniform(1.0, 168.0, 12), ....: "y": np.random.uniform(7.0, 334.0, 12), ....: "z": np.random.uniform(1.7, 20.7, 12), ....: "month": [5, 6, 7] * 4, ....: "week":0 码力 | 3313 页 | 10.91 MB | 1 年前3
pandas: powerful Python data analysis toolkit - 1.0.00 NaN 2 4.0 3.0 3 NaN 4.0 4 3.0 6.0 5 7.0 8.0 In [75]: df1.combine_first(df2) Out[75]: A B 0 1.0 NaN 1 2.0 2.0 2 3.0 3.0 3 5.0 4.0 4 3.0 6.0 5 7.0 8.0 General DataFrame combine The combine_first() a six b seven c six d seven e six dtype: object In [200]: s.map(t) Out[200]: a 6.0 b 7.0 c 6.0 d 7.0 e 6.0 dtype: float64 2.4.7 Reindexing and altering labels reindex() is the fundamental data [362]: dft1 = dft1.astype({'a': np.bool, 'c': np.float64}) In [363]: dft1 Out[363]: a b c 0 True 4 7.0 1 False 5 8.0 2 True 6 9.0 In [364]: dft1.dtypes Out[364]: a bool b int64 c float64 dtype: object0 码力 | 3015 页 | 10.78 MB | 1 年前3
pandas: powerful Python data analysis toolkit - 0.25.0\\\\\\\\\\\\\\\\\\\\\\Out[74]: ˓→ A B 0 5.0 NaN 1 2.0 NaN 2 4.0 3.0 3 NaN 4.0 4 3.0 6.0 5 7.0 8.0 In [75]: df1.combine_first(df2) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ \\\\\\\\\\\\\\\\\\\\\\Out[75]: ˓→ A B 0 1.0 NaN 1 2.0 2.0 2 3.0 3.0 3 5.0 4.0 4 3.0 6.0 5 7.0 8.0 General DataFrame combine The combine_first() method above calls the more general DataFrame.combine() ˓→ a 6.0 b 7.0 c 6.0 (continues on next page) 3.3. Essential basic functionality 99 pandas: powerful Python data analysis toolkit, Release 0.25.0 (continued from previous page) d 7.0 e 6.0 dtype:0 码力 | 2827 页 | 9.62 MB | 1 年前3
共 26 条
- 1
- 2
- 3













