动手学深度学习 v2.0量轴‐1长度 的总和(4 + 4)。 X = torch.arange(12, dtype=torch.float32).reshape((3,4)) Y = torch.tensor([[2.0, 1, 4, 3], [1, 2, 3, 4], [4, 3, 2, 1]]) torch.cat((X, Y), dim=0), torch.cat((X, Y), dim=1) (tensor([[ pandas as pd data = pd.read_csv(data_file) print(data) NumRooms Alley Price 0 NaN Pave 127500 1 2.0 NaN 106000 2 4.0 NaN 178100 3 NaN NaN 140000 2.2.2 处理缺失值 注意,“NaN”项代表缺失值。为了处理缺失的数据,典型的方法包括插值法和删除法,其中插值法用一个替 next page) 48 2. 预备知识 (continued from previous page) print(inputs) NumRooms Alley 0 3.0 Pave 1 2.0 NaN 2 4.0 NaN 3 3.0 NaN 对于inputs中的类别值或离散值,我们将“NaN”视为一个类别。由于“巷子类型”(“Alley”)列只接受两 种类型的类别值“Pave”和0 码力 | 797 页 | 29.45 MB | 1 年前3
pandas: powerful Python data analysis toolkit - 0.24.0astype(float) \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\Out[12]: 0 1.0 1 2.0 2 NaN Name: A, Length: 3, dtype: float64 Reduction and groupby operations such as sum work. In floating-point array, since NaN is a float. In [29]: pd.array([1, 2, np.nan]) Out[29]:[1.0, 2.0, nan] Length: 3, dtype: float64 1.1.4 Storing Interval and Period Data in Series and DataFrame Interval (GH21767). In the future this will raise a ValueError. Also changes the behavior of .from_codes([1. 1, 2.0]). • Bug in Categorical.sort_values() where NaN values were always positioned in front regardless 0 码力 | 2973 页 | 9.90 MB | 1 年前3
pandas: powerful Python data analysis toolkit - 0.25.0\\\\\Out[7]: ˓→ height weightkind cat -0.4 18.6 -2.0 17.8 dog -28.0 40.0 -190.5 205.5 [2 rows x 4 columns] Previously, these raised a SpecificationError 126404 5 NaN 2013-01-02 0.275165 0.804503 0.446934 5 1.0 2013-01-03 -0.918029 -1.032644 1.599718 5 2.0 2013-01-04 -1.236791 -0.438204 0.101452 5 3.0 2013-01-05 -1.632181 -0.992838 0.741029 5 4.0 2013-01-06 NaN 2013-01-02 -0.275165 -0.804503 -0.446934 -5 -1.0 2013-01-03 -0.918029 -1.032644 -1.599718 -5 -2.0 2013-01-04 -1.236791 -0.438204 -0.101452 -5 -3.0 2013-01-05 -1.632181 -0.992838 -0.741029 -5 -4.0 2013-01-06 0 码力 | 2827 页 | 9.62 MB | 1 年前3
pandas: powerful Python data analysis toolkit - 0.25.1\\\\\Out[7]: ˓→ height weightkind cat -0.4 18.6 -2.0 17.8 dog -28.0 40.0 -190.5 205.5 [2 rows x 4 columns] Previously, these raised a SpecificationError 612266 5 NaN 2013-01-02 -0.348338 1.733068 1.226064 5 1.0 2013-01-03 -0.136964 -0.276600 -0.614256 5 2.0 2013-01-04 0.066430 0.886690 1.544564 5 3.0 2013-01-05 0.996132 0.368752 1.232876 5 4.0 2013-01-06 NaN 2013-01-02 -0.348338 -1.733068 -1.226064 -5 -1.0 2013-01-03 -0.136964 -0.276600 -0.614256 -5 -2.0 2013-01-04 -0.066430 -0.886690 -1.544564 -5 -3.0 2013-01-05 -0.996132 -0.368752 -1.232876 -5 -4.0 2013-01-06 0 码力 | 2833 页 | 9.65 MB | 1 年前3
pandas: powerful Python data analysis toolkit - 1.1.0Timothy J ˓→ male 54.0 0 0 17463 51.8625 E46 S 7 8 0 3 Palsson, Master. Gosta Leonard ˓→ male 2.0 3 1 349909 21.0750 NaN S To see the first N rows of a DataFrame, use the head() method with the required Moran, Mr. James male NaN 0 ˓→ 0 330877 8.4583 NaN Q 7 8 0 3 Palsson, Master. Gosta Leonard male 2.0 3 ˓→ 1 349909 21.0750 NaN S Similar to the conditional expression, the isin() conditional function Moran, Mr. James male NaN 0 ˓→ 0 330877 8.4583 NaN Q 7 8 0 3 Palsson, Master. Gosta Leonard male 2.0 3 ˓→ 1 349909 21.0750 NaN S Note: When combining multiple conditional statements, each condition0 码力 | 3229 页 | 10.87 MB | 1 年前3
pandas: powerful Python data analysis toolkit - 1.1.1Moran, Mr. James male NaN 0 ˓→ 0 330877 8.4583 NaN Q 7 8 0 3 Palsson, Master. Gosta Leonard male 2.0 3 ˓→ 1 349909 21.0750 NaN S Similar to the conditional expression, the isin() conditional function Moran, Mr. James male NaN 0 ˓→ 0 330877 8.4583 NaN Q 7 8 0 3 Palsson, Master. Gosta Leonard male 2.0 3 ˓→ 1 349909 21.0750 NaN S Note: When combining multiple conditional statements, each condition DataFrame([tuple(list(x) + [val]) for x, val in np.ndenumerate(a)]) Out[29]: 0 1 2 3 0 0 0 0 1.0 1 0 0 1 2.0 2 0 0 2 3.0 3 0 0 3 4.0 4 0 1 0 5.0 .. .. .. .. ... 19 1 1 3 20.0 20 1 2 0 21.0 21 1 2 1 220 码力 | 3231 页 | 10.87 MB | 1 年前3
pandas: powerful Python data analysis toolkit - 1.0.0nan], ....: 'z': [True, False, True]}) ....: In [19]: df Out[19]: x y z 0 abc 1.0 True 1 None 2.0 False 2 def NaN True [3 rows x 3 columns] In [20]: df.dtypes Out[20]: x object y float64 z bool 495508 5 NaN 2013-01-02 -1.217227 -0.814532 1.419296 5 1.0 2013-01-03 1.789156 0.984494 1.794371 5 2.0 2013-01-04 0.743967 -0.470009 -1.308438 5 3.0 2013-01-05 0.969829 -0.538649 -0.384829 5 4.0 2013-01-06 NaN 2013-01-02 -1.217227 -0.814532 -1.419296 -5 -1.0 2013-01-03 -1.789156 -0.984494 -1.794371 -5 -2.0 2013-01-04 -0.743967 -0.470009 -1.308438 -5 -3.0 2013-01-05 -0.969829 -0.538649 -0.384829 -5 -4.0 2013-01-060 码力 | 3015 页 | 10.78 MB | 1 年前3
pandas: powerful Python data analysis toolkit - 1.3.4Timothy J ␣ ˓→male 54.0 0 0 17463 51.8625 E46 S 7 8 0 3 Palsson, Master. Gosta Leonard ␣ ˓→male 2.0 3 1 349909 21.0750 NaN S To see the first N rows of a DataFrame, use the head() method with the required Moran, Mr. James male NaN 0 ␣ ˓→ 0 330877 8.4583 NaN Q 7 8 0 3 Palsson, Master. Gosta Leonard male 2.0 3 ␣ ˓→ 1 349909 21.0750 NaN S Similar to the conditional expression, the isin() conditional function Moran, Mr. James male NaN 0 ␣ ˓→ 0 330877 8.4583 NaN Q 7 8 0 3 Palsson, Master. Gosta Leonard male 2.0 3 ␣ ˓→ 1 349909 21.0750 NaN S 1.4. Tutorials 25 pandas: powerful Python data analysis toolkit, Release0 码力 | 3605 页 | 14.68 MB | 1 年前3
pandas: powerful Python data analysis toolkit - 1.3.3Moran, Mr. James male NaN 0 ␣ ˓→ 0 330877 8.4583 NaN Q 7 8 0 3 Palsson, Master. Gosta Leonard male 2.0 3 ␣ ˓→ 1 349909 21.0750 NaN S Similar to the conditional expression, the isin() conditional function toolkit, Release 1.3.3 (continued from previous page) 7 8 0 3 Palsson, Master. Gosta Leonard male 2.0 3 ␣ ˓→ 1 349909 21.0750 NaN S Note: When combining multiple conditional statements, each condition DataFrame([tuple(list(x) + [val]) for x, val in np.ndenumerate(a)]) Out[29]: 0 1 2 3 0 0 0 0 1.0 1 0 0 1 2.0 2 0 0 2 3.0 3 0 0 3 4.0 4 0 1 0 5.0 .. .. .. .. ... 19 1 1 3 20.0 20 1 2 0 21.0 21 1 2 1 220 码力 | 3603 页 | 14.65 MB | 1 年前3
pandas: powerful Python data analysis toolkit - 1.3.2DataFrame([tuple(list(x) + [val]) for x, val in np.ndenumerate(a)]) Out[29]: 0 1 2 3 0 0 0 0 1.0 1 0 0 1 2.0 2 0 0 2 3.0 3 0 0 3 4.0 4 0 1 0 5.0 .. .. .. .. ... 19 1 1 3 20.0 20 1 2 0 21.0 21 1 2 1 22 list(enumerate(list(range(1, 5)) + [np.NAN])) In [31]: pd.DataFrame(a) Out[31]: 0 1 0 0 1.0 1 1 2.0 2 2 3.0 3 3 4.0 4 4 NaN For more details and examples see the Into to Data Structures documentation index="Animal", columns="FeedType", aggfunc= ˓→"sum") Out[39]: FeedType A B Animal Animal1 10.0 5.0 Animal2 2.0 13.0 Animal3 6.0 NaN The second approach is to use the groupby() method: In [40]: df.groupby(["Animal"0 码力 | 3509 页 | 14.01 MB | 1 年前3
共 274 条
- 1
- 2
- 3
- 4
- 5
- 6
- 28













