微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Python机器学习之Pandas

import pandas
food_info = pandas.read_csv("food_info.csv")
# print(type(food_info))
print(food_info.shape)
print(food_info.loc[0])
# print(food_info.dtypes)
# print(help(pandas.read_csv))
(8618, 36)
NDB_No                         1001
Shrt_Desc          BUTTER WITH SALT
Water_(g)                     15.87
Energ_Kcal                      717
Protein_(g)                    0.85
Lipid_Tot_(g)                 81.11
Ash_(g)                        2.11
Carbohydrt_(g)                 0.06
Fiber_TD_(g)                      0
Sugar_Tot_(g)                  0.06
Calcium_(mg)                     24
Iron_(mg)                      0.02
Magnesium_(mg)                    2
Phosphorus_(mg)                  24
Potassium_(mg)                   24
sodium_(mg)                     643
Zinc_(mg)                      0.09
copper_(mg)                       0
Manganese_(mg)                    0
Selenium_(mcg)                    1
Vit_C_(mg)                        0
Thiamin_(mg)                  0.005
Riboflavin_(mg)               0.034
Niacin_(mg)                   0.042
Vit_B6_(mg)                   0.003
Vit_B12_(mcg)                  0.17
Vit_A_IU                       2499
Vit_A_RAE                       684
Vit_E_(mg)                     2.32
Vit_D_mcg                       1.5
Vit_D_IU                         60
Vit_K_(mcg)                       7
FA_Sat_(g)                   51.368
FA_Mono_(g)                  21.021
FA_poly_(g)                   3.043
Cholestrl_(mg)                  215
Name: 0, dtype: object
print(food_info.head()) #显示前5条数据
print(food_info.tail(4))
print(food_info.columns)
print(food_info.shape)
   NDB_No                 Shrt_Desc  Water_(g)  Energ_Kcal  Protein_(g)  \
0    1001          BUTTER WITH SALT      15.87         717         0.85   
1    1002  BUTTER WHIPPED WITH SALT      15.87         717         0.85   
2    1003      BUTTER OIL ANHYDROUS       0.24         876         0.28   
3    1004               CHEESE BLUE      42.41         353        21.40   
4    1005              CHEESE BRICK      41.11         371        23.24   

   Lipid_Tot_(g)  Ash_(g)  Carbohydrt_(g)  Fiber_TD_(g)  Sugar_Tot_(g)  \
0          81.11     2.11            0.06           0.0           0.06   
1          81.11     2.11            0.06           0.0           0.06   
2          99.48     0.00            0.00           0.0           0.00   
3          28.74     5.11            2.34           0.0           0.50   
4          29.68     3.18            2.79           0.0           0.51   

        ...        Vit_A_IU  Vit_A_RAE  Vit_E_(mg)  Vit_D_mcg  Vit_D_IU  \
0       ...          2499.0      684.0        2.32        1.5      60.0   
1       ...          2499.0      684.0        2.32        1.5      60.0   
2       ...          3069.0      840.0        2.80        1.8      73.0   
3       ...           721.0      198.0        0.25        0.5      21.0   
4       ...          1080.0      292.0        0.26        0.5      22.0   

   Vit_K_(mcg)  FA_Sat_(g)  FA_Mono_(g)  FA_poly_(g)  Cholestrl_(mg)  
0          7.0      51.368       21.021        3.043           215.0  
1          7.0      50.489       23.426        3.012           219.0  
2          8.6      61.924       28.732        3.694           256.0  
3          2.4      18.669        7.778        0.800            75.0  
4          2.5      18.764        8.598        0.784            94.0  

[5 rows x 36 columns]
      NDB_No                   Shrt_Desc  Water_(g)  Energ_Kcal  Protein_(g)  \
8614   90240  SCALLOP (BAY&SEA) CKD STMD      70.25         111        20.54   
8615   90480                  SYRUP CANE      26.00         269         0.00   
8616   90560                   SNAIL RAW      79.20          90        16.10   
8617   93600            TURTLE GREEN RAW      78.50          89        19.80   

      Lipid_Tot_(g)  Ash_(g)  Carbohydrt_(g)  Fiber_TD_(g)  Sugar_Tot_(g)  \
8614           0.84     2.97            5.41           0.0            0.0   
8615           0.00     0.86           73.14           0.0           73.2   
8616           1.40     1.30            2.00           0.0            0.0   
8617           0.50     1.20            0.00           0.0            0.0   

           ...        Vit_A_IU  Vit_A_RAE  Vit_E_(mg)  Vit_D_mcg  Vit_D_IU  \
8614       ...             5.0        2.0         0.0        0.0       2.0   
8615       ...             0.0        0.0         0.0        0.0       0.0   
8616       ...           100.0       30.0         5.0        0.0       0.0   
8617       ...           100.0       30.0         0.5        0.0       0.0   

      Vit_K_(mcg)  FA_Sat_(g)  FA_Mono_(g)  FA_poly_(g)  Cholestrl_(mg)  
8614          0.0       0.218        0.082        0.222            41.0  
8615          0.0       0.000        0.000        0.000             0.0  
8616          0.1       0.361        0.259        0.252            50.0  
8617          0.1       0.127        0.088        0.170            50.0  

[4 rows x 36 columns]
Index(['NDB_No', 'Shrt_Desc', 'Water_(g)', 'Energ_Kcal', 'Protein_(g)',
       'Lipid_Tot_(g)', 'Ash_(g)', 'Carbohydrt_(g)', 'Fiber_TD_(g)',
       'Sugar_Tot_(g)', 'Calcium_(mg)', 'Iron_(mg)', 'Magnesium_(mg)',
       'Phosphorus_(mg)', 'Potassium_(mg)', 'sodium_(mg)', 'Zinc_(mg)',
       'copper_(mg)', 'Manganese_(mg)', 'Selenium_(mcg)', 'Vit_C_(mg)',
       'Thiamin_(mg)', 'Riboflavin_(mg)', 'Niacin_(mg)', 'Vit_B6_(mg)',
       'Vit_B12_(mcg)', 'Vit_A_IU', 'Vit_A_RAE', 'Vit_E_(mg)', 'Vit_D_mcg',
       'Vit_D_IU', 'Vit_K_(mcg)', 'FA_Sat_(g)', 'FA_Mono_(g)', 'FA_poly_(g)',
       'Cholestrl_(mg)'],
      dtype='object')
(8618, 36)
print(food_info.loc[0]) #输出第一行数据
NDB_No                         1001
Shrt_Desc          BUTTER WITH SALT
Water_(g)                     15.87
Energ_Kcal                      717
Protein_(g)                    0.85
Lipid_Tot_(g)                 81.11
Ash_(g)                        2.11
Carbohydrt_(g)                 0.06
Fiber_TD_(g)                      0
Sugar_Tot_(g)                  0.06
Calcium_(mg)                     24
Iron_(mg)                      0.02
Magnesium_(mg)                    2
Phosphorus_(mg)                  24
Potassium_(mg)                   24
sodium_(mg)                     643
Zinc_(mg)                      0.09
copper_(mg)                       0
Manganese_(mg)                    0
Selenium_(mcg)                    1
Vit_C_(mg)                        0
Thiamin_(mg)                  0.005
Riboflavin_(mg)               0.034
Niacin_(mg)                   0.042
Vit_B6_(mg)                   0.003
Vit_B12_(mcg)                  0.17
Vit_A_IU                       2499
Vit_A_RAE                       684
Vit_E_(mg)                     2.32
Vit_D_mcg                       1.5
Vit_D_IU                         60
Vit_K_(mcg)                       7
FA_Sat_(g)                   51.368
FA_Mono_(g)                  21.021
FA_poly_(g)                   3.043
Cholestrl_(mg)                  215
Name: 0, dtype: object
#切片
food_info.loc[3:6]
#切片第2,5,10行
food_info.loc[[2,5,10]]
NDB_No Shrt_Desc Water_(g) Energ_Kcal Protein_(g) Lipid_Tot_(g) Ash_(g) Carbohydrt_(g) Fiber_TD_(g) Sugar_Tot_(g) ... Vit_A_IU Vit_A_RAE Vit_E_(mg) Vit_D_mcg Vit_D_IU Vit_K_(mcg) FA_Sat_(g) FA_Mono_(g) FA_poly_(g) Cholestrl_(mg)
2 1003 BUTTER OIL ANHYDROUS 0.24 876 0.28 99.48 0.00 0.00 0.0 0.00 ... 3069.0 840.0 2.80 1.8 73.0 8.6 61.924 28.732 3.694 256.0
5 1006 CHEESE BRIE 48.42 334 20.75 27.68 2.70 0.45 0.0 0.45 ... 592.0 174.0 0.24 0.5 20.0 2.3 17.410 8.013 0.826 100.0
10 1011 CHEESE COLBY 38.20 394 23.76 32.11 3.36 2.57 0.0 0.52 ... 994.0 264.0 0.28 0.6 24.0 2.7 20.218 9.280 0.953 95.0

3 rows × 36 columns

#定位到列名
ndb_col = food_info["NDB_No"]
print(ndb_col)
0        1001
1        1002
2        1003
3        1004
4        1005
5        1006
6        1007
7        1008
8        1009
9        1010
10       1011
11       1012
12       1013
13       1014
14       1015
15       1016
16       1017
17       1018
18       1019
19       1020
20       1021
21       1022
22       1023
23       1024
24       1025
25       1026
26       1027
27       1028
28       1029
29       1030
        ...  
8588    43544
8589    43546
8590    43550
8591    43566
8592    43570
8593    43572
8594    43585
8595    43589
8596    43595
8597    43597
8598    43598
8599    44005
8600    44018
8601    44048
8602    44055
8603    44061
8604    44074
8605    44110
8606    44158
8607    44203
8608    44258
8609    44259
8610    44260
8611    48052
8612    80200
8613    83110
8614    90240
8615    90480
8616    90560
8617    93600
Name: NDB_No, dtype: int64
#指定列名
columns = ["Zinc_(mg)", "copper_(mg)"]
zinc_copper = food_info[columns]
print(zinc_copper)
      Zinc_(mg)  copper_(mg)
0          0.09        0.000
1          0.05        0.016
2          0.01        0.001
3          2.66        0.040
4          2.60        0.024
5          2.38        0.019
6          2.38        0.021
7          2.94        0.024
8          3.43        0.056
9          2.79        0.042
10         3.07        0.042
11         0.40        0.029
12         0.33        0.040
13         0.47        0.030
14         0.51        0.033
15         0.38        0.028
16         0.51        0.019
17         3.75        0.036
18         2.88        0.032
19         3.50        0.025
20         1.14        0.080
21         3.90        0.036
22         3.90        0.032
23         2.10        0.021
24         3.00        0.032
25         2.92        0.011
26         2.46        0.022
27         2.76        0.025
28         3.61        0.034
29         2.81        0.031
...         ...          ...
8588       3.30        0.377
8589       0.05        0.040
8590       0.05        0.030
8591       1.15        0.116
8592       5.03        0.200
8593       3.83        0.545
8594       0.08        0.035
8595       3.90        0.027
8596       4.10        0.100
8597       3.13        0.027
8598       0.13        0.000
8599       0.02        0.000
8600       0.09        0.037
8601       0.21        0.026
8602       2.77        0.571
8603       0.41        0.838
8604       0.05        0.028
8605       0.03        0.023
8606       0.10        0.112
8607       0.02        0.020
8608       1.49        0.854
8609       0.19        0.040
8610       0.10        0.038
8611       0.85        0.182
8612       1.00        0.250
8613       1.10        0.100
8614       1.55        0.033
8615       0.19        0.020
8616       1.00        0.400
8617       1.00        0.250

[8618 rows x 2 columns]
#把当前的列名做成一个list
col_names = food_info.columns.tolist()
print(col_names)
gram_columns = []
for c in col_names:
    if c.endswith("(g)"):
        gram_columns.append(c)
gram_df = food_info[gram_columns]
print(gram_df.head(3))
['NDB_No', 'Shrt_Desc', 'Water_(g)', 'Energ_Kcal', 'Protein_(g)', 'Lipid_Tot_(g)', 'Ash_(g)', 'Carbohydrt_(g)', 'Fiber_TD_(g)', 'Sugar_Tot_(g)', 'Calcium_(mg)', 'Iron_(mg)', 'Magnesium_(mg)', 'Phosphorus_(mg)', 'Potassium_(mg)', 'sodium_(mg)', 'Zinc_(mg)', 'copper_(mg)', 'Manganese_(mg)', 'Selenium_(mcg)', 'Vit_C_(mg)', 'Thiamin_(mg)', 'Riboflavin_(mg)', 'Niacin_(mg)', 'Vit_B6_(mg)', 'Vit_B12_(mcg)', 'Vit_A_IU', 'Vit_A_RAE', 'Vit_E_(mg)', 'Vit_D_mcg', 'Vit_D_IU', 'Vit_K_(mcg)', 'FA_Sat_(g)', 'FA_Mono_(g)', 'FA_poly_(g)', 'Cholestrl_(mg)']
   Water_(g)  Protein_(g)  Lipid_Tot_(g)  Ash_(g)  Carbohydrt_(g)  \
0      15.87         0.85          81.11     2.11            0.06   
1      15.87         0.85          81.11     2.11            0.06   
2       0.24         0.28          99.48     0.00            0.00   

   Fiber_TD_(g)  Sugar_Tot_(g)  FA_Sat_(g)  FA_Mono_(g)  FA_poly_(g)  
0           0.0           0.06      51.368       21.021        3.043  
1           0.0           0.06      50.489       23.426        3.012  
2           0.0           0.00      61.924       28.732        3.694  
import pandas
food_info = pandas.read_csv("food_info.csv")
print(food_info)
      NDB_No                                          Shrt_Desc  Water_(g)  \
0       1001                                   BUTTER WITH SALT      15.87   
1       1002                           BUTTER WHIPPED WITH SALT      15.87   
2       1003                               BUTTER OIL ANHYDROUS       0.24   
3       1004                                        CHEESE BLUE      42.41   
4       1005                                       CHEESE BRICK      41.11   
5       1006                                        CHEESE BRIE      48.42   
6       1007                                   CHEESE CAMEMBERT      51.80   
7       1008                                     CHEESE CaraWAY      39.28   
8       1009                                     CHEESE CHEDDAR      37.10   
9       1010                                    CHEESE CHESHIRE      37.65   
10      1011                                       CHEESE COLBY      38.20   
11      1012                CHEESE CottAGE CRMD LRG OR SML CURD      79.79   
12      1013                        CHEESE CottAGE CRMD W/FRUIT      79.64   
13      1014   CHEESE CottAGE NONFAT UNCRMD DRY LRG OR SML CURD      81.01   
14      1015                   CHEESE CottAGE LOWFAT 2% MILKFAT      81.24   
15      1016                   CHEESE CottAGE LOWFAT 1% MILKFAT      82.48   
16      1017                                       CHEESE CREAM      54.44   
17      1018                                        CHEESE Edam      41.56   
18      1019                                        CHEESE FETA      55.22   
19      1020                                     CHEESE FONTINA      37.92   
20      1021                                     CHEESE GJetoST      13.44   
21      1022                                       CHEESE GOUDA      41.46   
22      1023                                     CHEESE GRUYERE      33.19   
23      1024                                   CHEESE LIMBURGER      48.42   
24      1025                                    CHEESE MONTEREY      41.01   
25      1026                         CHEESE MOZZARELLA WHL MILK      50.01   
26      1027                CHEESE MOZZARELLA WHL MILK LO MOIST      48.38   
27      1028                   CHEESE MOZZARELLA PART SKIM MILK      53.78   
28      1029               CHEESE MOZZARELLA LO MOIST PART-SKIM      45.54   
29      1030                                    CHEESE MUENSTER      41.77   
...      ...                                                ...        ...   
8588   43544         BABYFOOD CRL RICE W/ PEARS & APPL DRY INST       2.00   
8589   43546                     BABYFOOD BANANA NO TAPIOCA STR      76.70   
8590   43550                     BABYFOOD BANANA APPL DSSRT STR      83.10   
8591   43566       SNACKS TORTILLA CHIPS LT (BAKED W/ LESS OIL)       1.30   
8592   43570  CEREALS RTE POST HONEY BUNCHES OF OATS HONEY RSTD       5.00   
8593   43572                         POPCORN MICROWAVE LOFAT&NA       2.80   
8594   43585                       BABYFOOD FRUIT SUPREME DSSRT      81.60   
8595   43589                               CHEESE SWISS LOW FAT      59.60   
8596   43595             BREAKFAST BAR CORN FLAKE CRUST W/FRUIT      14.50   
8597   43597                            CHEESE MOZZARELLA LO NA      49.90   
8598   43598                           MAYONNAISE DRSNG NO CHOL      21.70   
8599   44005                          OIL CORN PEANUT AND OLIVE       0.00   
8600   44018                   SWEETENERS TABLetoP FRUCTOSE LIQ      23.90   
8601   44048                              CHEESE FOOD IMITATION      55.50   
8602   44055                                CELERY FLAKES DRIED       9.00   
8603   44061           PuddiNGS CHOC FLAVOR LO CAL INST DRY MIX       4.20   
8604   44074                    BABYFOOD GRAPE JUC NO SUGAR CND      84.40   
8605   44110                   JELLIES RED SUGAR HOME PRESERVED      53.00   
8606   44158                         PIE FILLINGS BLUEBerry CND      54.66   
8607   44203               COCKTAIL MIX NON-ALCOHOLIC CONCD FRZ      28.24   
8608   44258            PuddiNGS CHOC FLAVOR LO CAL REG DRY MIX       6.80   
8609   44259  PuddiNGS ALL FLAVORS XCPT CHOC LO CAL REG DRY MIX      10.40   
8610   44260  PuddiNGS ALL FLAVORS XCPT CHOC LO CAL INST DRY...       6.84   
8611   48052                                 VITAL WHEAT gluTEN       8.20   
8612   80200                                      FROG LEGS RAW      81.90   
8613   83110                                    MACKEREL SALTED      43.00   
8614   90240                         SCALLOP (BAY&SEA) CKD STMD      70.25   
8615   90480                                         SYRUP CANE      26.00   
8616   90560                                          SNAIL RAW      79.20   
8617   93600                                   TURTLE GREEN RAW      78.50   

      Energ_Kcal  Protein_(g)  Lipid_Tot_(g)  Ash_(g)  Carbohydrt_(g)  \
0            717         0.85          81.11     2.11            0.06   
1            717         0.85          81.11     2.11            0.06   
2            876         0.28          99.48     0.00            0.00   
3            353        21.40          28.74     5.11            2.34   
4            371        23.24          29.68     3.18            2.79   
5            334        20.75          27.68     2.70            0.45   
6            300        19.80          24.26     3.68            0.46   
7            376        25.18          29.20     3.28            3.06   
8            406        24.04          33.82     3.71            1.33   
9            387        23.37          30.60     3.60            4.78   
10           394        23.76          32.11     3.36            2.57   
11            98        11.12           4.30     1.41            3.38   
12            97        10.69           3.85     1.20            4.61   
13            72        10.34           0.29     1.71            6.66   
14            81        10.45           2.27     1.27            4.76   
15            72        12.39           1.02     1.39            2.72   
16           342         5.93          34.24     1.32            4.07   
17           357        24.99          27.80     4.22            1.43   
18           264        14.21          21.28     5.20            4.09   
19           389        25.60          31.14     3.79            1.55   
20           466         9.65          29.51     4.75           42.65   
21           356        24.94          27.44     3.94            2.22   
22           413        29.81          32.34     4.30            0.36   
23           327        20.05          27.25     3.79            0.49   
24           373        24.48          30.28     3.55            0.68   
25           300        22.17          22.35     3.28            2.19   
26           318        21.60          24.64     2.91            2.47   
27           254        24.26          15.92     3.27            2.77   
28           301        24.58          19.72     3.80            6.36   
29           368        23.41          30.04     3.66            1.12   
...          ...          ...            ...      ...             ...   
8588         389         6.60           0.90     2.00           88.60   
8589          91         1.00           0.20     0.76           21.34   
8590          68         0.30           0.20     0.29           16.30   
8591         465         8.70          15.20     1.85           73.40   
8592         401         7.12           5.46     1.22           81.19   
8593         429        12.60           9.50     1.71           73.39   
8594          73         0.50           0.20     0.52           17.18   
8595         179        28.40           5.10     3.50            3.40   
8596         377         4.40           7.50     0.80           72.90   
8597         280        27.50          17.10     2.40            3.10   
8598         688         0.00          77.80     0.40            0.30   
8599         884         0.00         100.00     0.00            0.00   
8600         279         0.00           0.00     0.00           76.10   
8601         257         4.08          19.50     4.74           16.18   
8602         319        11.30           2.10    13.90           63.70   
8603         356         5.30           2.40     9.90           78.20   
8604          62         0.00           0.00     0.22           15.38   
8605         179         0.30           0.03     0.08           46.10   
8606         181         0.41           0.20     0.35           44.38   
8607         287         0.08           0.01     0.07           71.60   
8608         365        10.08           3.00     5.70           74.42   
8609         351         1.60           0.10     1.86           86.04   
8610         350         0.81           0.90     6.80           84.66   
8611         370        75.16           1.85     1.00           13.79   
8612          73        16.40           0.30     1.40            0.00   
8613         305        18.50          25.10    13.40            0.00   
8614         111        20.54           0.84     2.97            5.41   
8615         269         0.00           0.00     0.86           73.14   
8616          90        16.10           1.40     1.30            2.00   
8617          89        19.80           0.50     1.20            0.00   

      Fiber_TD_(g)  Sugar_Tot_(g)  ...  Vit_A_IU  Vit_A_RAE  Vit_E_(mg)  \
0              0.0           0.06  ...    2499.0      684.0        2.32   
1              0.0           0.06  ...    2499.0      684.0        2.32   
2              0.0           0.00  ...    3069.0      840.0        2.80   
3              0.0           0.50  ...     721.0      198.0        0.25   
4              0.0           0.51  ...    1080.0      292.0        0.26   
5              0.0           0.45  ...     592.0      174.0        0.24   
6              0.0           0.46  ...     820.0      241.0        0.21   
7              0.0            NaN  ...    1054.0      271.0         NaN   
8              0.0           0.28  ...     994.0      263.0        0.78   
9              0.0            NaN  ...     985.0      233.0         NaN   
10             0.0           0.52  ...     994.0      264.0        0.28   
11             0.0           2.67  ...     140.0       37.0        0.08   
12             0.2           2.38  ...     146.0       38.0        0.04   
13             0.0           1.85  ...       8.0        2.0        0.01   
14             0.0           4.00  ...     225.0       68.0        0.08   
15             0.0           2.72  ...      41.0       11.0        0.01   
16             0.0           3.21  ...    1343.0      366.0        0.29   
17             0.0           1.43  ...     825.0      243.0        0.24   
18             0.0           4.09  ...     422.0      125.0        0.18   
19             0.0           1.55  ...     913.0      261.0        0.27   
20             0.0            NaN  ...    1113.0      334.0         NaN   
21             0.0           2.22  ...     563.0      165.0        0.24   
22             0.0           0.36  ...     948.0      271.0        0.28   
23             0.0           0.49  ...    1155.0      340.0        0.23   
24             0.0           0.50  ...     769.0      198.0        0.26   
25             0.0           1.03  ...     676.0      179.0        0.19   
26             0.0           1.01  ...     745.0      197.0        0.21   
27             0.0           1.13  ...     481.0      127.0        0.14   
28             0.0           2.24  ...     846.0      254.0        0.43   
29             0.0           1.12  ...    1012.0      298.0        0.26   
...            ...            ...  ...       ...        ...         ...   
8588           2.6           1.35  ...       0.0        0.0        0.13   
8589           1.6          11.36  ...       5.0        0.0        0.25   
8590           1.0          14.66  ...      30.0        2.0        0.02   
8591           5.7           0.53  ...      81.0        4.0        3.53   
8592           4.2          19.79  ...    2731.0      806.0        1.22   
8593          14.2           0.54  ...     147.0        7.0        5.01   
8594           2.0          14.87  ...      50.0        3.0        0.79   
8595           0.0           1.33  ...     152.0       40.0        0.07   
8596           2.1          35.10  ...    2027.0      608.0        0.76   
8597           0.0           1.23  ...     517.0      137.0        0.15   
8598           0.0           0.30  ...       0.0        0.0       11.79   
8599           0.0           0.00  ...       0.0        0.0       14.78   
8600           0.1          76.00  ...       0.0        0.0        0.00   
8601           0.0           8.21  ...     900.0       45.0        2.15   
8602          27.8          35.90  ...    1962.0       98.0        5.55   
8603           6.1           0.70  ...       0.0        0.0        0.02   
8604           0.1            NaN  ...       8.0        NaN         NaN   
8605           0.8          45.30  ...       3.0        0.0        0.00   
8606           2.6          37.75  ...      22.0        1.0        0.23   
8607           0.0          24.53  ...      12.0        1.0        0.02   
8608          10.1           0.70  ...       0.0        0.0        0.02   
8609           0.9           2.90  ...       0.0        0.0        0.05   
8610           0.8           0.90  ...       0.0        0.0        0.08   
8611           0.6           0.00  ...       0.0        0.0        0.00   
8612           0.0           0.00  ...      50.0       15.0        1.00   
8613           0.0           0.00  ...     157.0       47.0        2.38   
8614           0.0           0.00  ...       5.0        2.0        0.00   
8615           0.0          73.20  ...       0.0        0.0        0.00   
8616           0.0           0.00  ...     100.0       30.0        5.00   
8617           0.0           0.00  ...     100.0       30.0        0.50   

      Vit_D_mcg  Vit_D_IU  Vit_K_(mcg)  FA_Sat_(g)  FA_Mono_(g)  FA_poly_(g)  \
0           1.5      60.0          7.0      51.368       21.021        3.043   
1           1.5      60.0          7.0      50.489       23.426        3.012   
2           1.8      73.0          8.6      61.924       28.732        3.694   
3           0.5      21.0          2.4      18.669        7.778        0.800   
4           0.5      22.0          2.5      18.764        8.598        0.784   
5           0.5      20.0          2.3      17.410        8.013        0.826   
6           0.4      18.0          2.0      15.259        7.023        0.724   
7           NaN       NaN          NaN      18.584        8.275        0.830   
8           0.6      24.0          2.9      19.368        8.428        1.433   
9           NaN       NaN          NaN      19.475        8.671        0.870   
10          0.6      24.0          2.7      20.218        9.280        0.953   
11          0.1       3.0          0.0       1.718        0.778        0.123   
12          0.0       0.0          0.4       2.311        1.036        0.124   
13          0.0       0.0          0.0       0.169        0.079        0.003   
14          0.0       0.0          0.0       1.235        0.516        0.083   
15          0.0       0.0          0.1       0.645        0.291        0.031   
16          0.6      25.0          2.9      19.292        8.620        1.437   
17          0.5      20.0          2.3      17.572        8.125        0.665   
18          0.4      16.0          1.8      14.946        4.623        0.591   
19          0.6      23.0          2.6      19.196        8.687        1.654   
20          NaN       NaN          NaN      19.160        7.879        0.938   
21          0.5      20.0          2.3      17.614        7.747        0.657   
22          0.6      24.0          2.7      18.913       10.043        1.733   
23          0.5      20.0          2.3      16.746        8.606        0.495   
24          0.6      22.0          2.5      19.066        8.751        0.899   
25          0.4      16.0          2.3      13.152        6.573        0.765   
26          0.5      18.0          2.5      15.561        7.027        0.778   
27          0.3      12.0          1.6      10.114        4.510        0.472   
28          0.4      15.0          1.3      11.473        5.104        0.861   
29          0.6      22.0          2.5      19.113        8.711        0.661   
...         ...       ...          ...         ...          ...          ...   
8588        0.0       0.0          0.3       0.185        0.252        0.231   
8589        0.0       0.0          0.5       0.072        0.028        0.041   
8590        0.0       0.0          0.1       0.058        0.018        0.047   
8591        0.0       0.0          0.7       2.837        6.341        5.024   
8592        4.6     183.0          3.0       0.600        2.831        1.307   
8593        0.0       0.0         15.7       1.415        4.085        3.572   
8594        0.0       0.0          5.1       0.030        0.025        0.068   
8595        0.1       4.0          0.5       3.304        1.351        0.180   
8596        0.0       0.0         13.8       1.500        5.000        0.900   
8597        0.3      13.0          1.8      10.867        4.844        0.509   
8598        0.0       0.0         24.7      10.784       18.026       45.539   
8599        0.0       0.0         21.0      14.367       48.033       33.033   
8600        0.0       0.0          0.0       0.000        0.000        0.000   
8601        0.0       0.0         36.7       7.996        3.108        7.536   
8602        0.0       0.0        584.2       0.555        0.405        1.035   
8603        0.0       0.0          0.4       0.984        1.154        0.131   
8604        NaN       NaN          NaN       0.000        0.000        0.000   
8605        0.0       0.0          0.2       0.009        0.001        0.008   
8606        0.0       0.0          3.9       0.000        0.000        0.000   
8607        0.0       0.0          0.0       0.003        0.001        0.009   
8608        0.0       0.0          0.5       1.578        1.150        0.130   
8609        0.0       0.0          1.1       0.018        0.032        0.050   
8610        0.0       0.0          1.7       0.099        0.116        0.433   
8611        0.0       0.0          0.0       0.272        0.156        0.810   
8612        0.2       8.0          0.1       0.076        0.053        0.102   
8613       25.2    1006.0          7.8       7.148        8.320        6.210   
8614        0.0       2.0          0.0       0.218        0.082        0.222   
8615        0.0       0.0          0.0       0.000        0.000        0.000   
8616        0.0       0.0          0.1       0.361        0.259        0.252   
8617        0.0       0.0          0.1       0.127        0.088        0.170   

      Cholestrl_(mg)  
0              215.0  
1              219.0  
2              256.0  
3               75.0  
4               94.0  
5              100.0  
6               72.0  
7               93.0  
8              102.0  
9              103.0  
10              95.0  
11              17.0  
12              13.0  
13               7.0  
14              12.0  
15               4.0  
16             110.0  
17              89.0  
18              89.0  
19             116.0  
20              94.0  
21             114.0  
22             110.0  
23              90.0  
24              89.0  
25              79.0  
26              89.0  
27              64.0  
28              65.0  
29              96.0  
...              ...  
8588             0.0  
8589             0.0  
8590             0.0  
8591             0.0  
8592             0.0  
8593             0.0  
8594             0.0  
8595            35.0  
8596             0.0  
8597            54.0  
8598             0.0  
8599             0.0  
8600             0.0  
8601             6.0  
8602             0.0  
8603             0.0  
8604             0.0  
8605             0.0  
8606             0.0  
8607             0.0  
8608             0.0  
8609             0.0  
8610             0.0  
8611             0.0  
8612            50.0  
8613            95.0  
8614            41.0  
8615             0.0  
8616            50.0  
8617            50.0  

[8618 rows x 36 columns]
print(food_info["Iron_(mg)"][0:10])
#这一列每个值都除以1000
div_1000 = food_info["Iron_(mg)"] / 1000
print(div_1000.loc[0:10])
0    0.02
1    0.16
2    0.00
3    0.31
4    0.43
5    0.50
6    0.33
7    0.64
8    0.16
9    0.21
Name: Iron_(mg), dtype: float64
0     0.00002
1     0.00016
2     0.00000
3     0.00031
4     0.00043
5     0.00050
6     0.00033
7     0.00064
8     0.00016
9     0.00021
10    0.00076
Name: Iron_(mg), dtype: float64
#对应位置的列相乘
water_energy = food_info["Water_(g)"]*food_info["Energ_Kcal"]
print(water_energy[0:10])
iron_grams = food_info["Iron_(mg)"] / 1000
print(food_info.shape)
#增加新的一列
food_info["Iron_(g)"] = iron_grams
print(food_info.shape)
0    11378.79
1    11378.79
2      210.24
3    14970.73
4    15251.81
5    16172.28
6    15540.00
7    14769.28
8    15062.60
9    14570.55
dtype: float64
(8618, 36)
(8618, 37)
weighted_protein = food_info["Protein_(g)"] * 2
weighted_fat = -0.75 * food_info["Lipid_Tot_(g)"]
initial_rating = weighted_protein + weighted_fat
print(weighted_protein[0:10],weighted_fat[0:10],initial_rating[0:10])
0     1.70
1     1.70
2     0.56
3    42.80
4    46.48
5    41.50
6    39.60
7    50.36
8    48.08
9    46.74
Name: Protein_(g), dtype: float64 0   -60.8325
1   -60.8325
2   -74.6100
3   -21.5550
4   -22.2600
5   -20.7600
6   -18.1950
7   -21.9000
8   -25.3650
9   -22.9500
Name: Lipid_Tot_(g), dtype: float64 0   -59.1325
1   -59.1325
2   -74.0500
3    21.2450
4    24.2200
5    20.7400
6    21.4050
7    28.4600
8    22.7150
9    23.7900
dtype: float64
#求某一列的最大值
max_calories = food_info["Energ_Kcal"].max()
print(max_calories)
#将一列都除以最大值
normalized_calories = food_info["Energ_Kcal"] / max_calories
normalized_protein = food_info["Protein_(g)"] / food_info["Protein_(g)"].max()
normalized_fat = food_info["Lipid_Tot_(g)"] / food_info["Lipid_Tot_(g)"].max()
food_info["normalized_protein"] = normalized_protein
food_info["normalized_fat"] = normalized_fat
print(food_info.shape)
print(food_info["normalized_protein"][0:10],food_info["normalized_fat"][0:10])
902
(8618, 39)
0    0.009624
1    0.009624
2    0.003170
3    0.242301
4    0.263134
5    0.234941
6    0.224185
7    0.285100
8    0.272192
9    0.264606
Name: normalized_protein, dtype: float64 0    0.8111
1    0.8111
2    0.9948
3    0.2874
4    0.2968
5    0.2768
6    0.2426
7    0.2920
8    0.3382
9    0.3060
Name: normalized_fat, dtype: float64
#对某一列进行排序,认从小到大
food_info.sort_values("sodium_(mg)", inplace = True)
print(food_info["sodium_(mg)"])
#加上ascending=False为从大到小
food_info.sort_values("sodium_(mg)", inplace = True, ascending=False)
print(food_info["sodium_(mg)"])
760     0.0
758     0.0
405     0.0
761     0.0
2269    0.0
763     0.0
764     0.0
770     0.0
774     0.0
396     0.0
395     0.0
6827    0.0
394     0.0
393     0.0
391     0.0
390     0.0
787     0.0
788     0.0
2270    0.0
2231    0.0
407     0.0
748     0.0
409     0.0
747     0.0
702     0.0
703     0.0
704     0.0
705     0.0
706     0.0
707     0.0
       ... 
8153    NaN
8155    NaN
8156    NaN
8157    NaN
8158    NaN
8159    NaN
8160    NaN
8161    NaN
8163    NaN
8164    NaN
8165    NaN
8167    NaN
8169    NaN
8170    NaN
8172    NaN
8173    NaN
8174    NaN
8175    NaN
8176    NaN
8177    NaN
8178    NaN
8179    NaN
8180    NaN
8181    NaN
8183    NaN
8184    NaN
8185    NaN
8195    NaN
8251    NaN
8267    NaN
Name: sodium_(mg), dtype: float64
276     38758.0
5814    27360.0
6192    26050.0
1242    26000.0
1245    24000.0
1243    24000.0
1244    23875.0
292     17000.0
1254    11588.0
5811    10600.0
8575     9690.0
291      8068.0
1249     8031.0
5812     7893.0
1292     7851.0
293      7203.0
4472     7027.0
4836     6820.0
1261     6580.0
3747     6008.0
1266     5730.0
4835     5586.0
4834     5493.0
1263     5356.0
1553     5203.0
1552     5053.0
1251     4957.0
1257     4843.0
294      4616.0
8613     4450.0
         ...   
8153        NaN
8155        NaN
8156        NaN
8157        NaN
8158        NaN
8159        NaN
8160        NaN
8161        NaN
8163        NaN
8164        NaN
8165        NaN
8167        NaN
8169        NaN
8170        NaN
8172        NaN
8173        NaN
8174        NaN
8175        NaN
8176        NaN
8177        NaN
8178        NaN
8179        NaN
8180        NaN
8181        NaN
8183        NaN
8184        NaN
8185        NaN
8195        NaN
8251        NaN
8267        NaN
Name: sodium_(mg), dtype: float64
import pandas as pd
import numpy as np
titanic_survival = pd.read_csv("titanic_train.csv")
titanic_survival.head()
#Passengerld 每个人的编号 Survived 只有两个值 0和1 (是否获救) Pclass舱位等级123 Name 乘客姓名
#Sex 性别 Age年龄 SibSp 家人数量 Parch老人孩子数量 Ticket 船票编码 fare 船票价格 
#Cabin 船舱编号NaN 缺失值 Embarked 登船地点(码头)
PassengerId Survived Pclass Name Sex Age SibSp Parch Ticket fare Cabin Embarked
0 1 0 3 Braund, Mr. Owen Harris male 22.0 1 0 A/5 21171 7.2500 NaN S
1 2 1 1 Cumings, Mrs. John Bradley (Florence Briggs Th... female 38.0 1 0 PC 17599 71.2833 C85 C
2 3 1 3 Heikkinen, Miss. Laina female 26.0 0 0 STON/O2. 3101282 7.9250 NaN S
3 4 1 1 Futrelle, Mrs. Jacques Heath (Lily May Peel) female 35.0 1 0 113803 53.1000 C123 S
4 5 0 3 Allen, Mr. William Henry male 35.0 0 0 373450 8.0500 NaN S
age = titanic_survival["Age"]
#0-10个人的年龄
print(age.loc[0:10])
#isnull()判断是缺失值True
age_is_null = pd.isnull(age)
print(age_is_null)
#作为索引找到行号
age_null_true = age[age_is_null]
print(age_null_true)
#缺失值的数量
age_null_count = len(age_null_true)
print(age_null_count)
0     22.0
1     38.0
2     26.0
3     35.0
4     35.0
5      NaN
6     54.0
7      2.0
8     27.0
9     14.0
10     4.0
Name: Age, dtype: float64
0      False
1      False
2      False
3      False
4      False
5       True
6      False
7      False
8      False
9      False
10     False
11     False
12     False
13     False
14     False
15     False
16     False
17      True
18     False
19      True
20     False
21     False
22     False
23     False
24     False
25     False
26      True
27     False
28      True
29      True
       ...  
861    False
862    False
863     True
864    False
865    False
866    False
867    False
868     True
869    False
870    False
871    False
872    False
873    False
874    False
875    False
876    False
877    False
878     True
879    False
880    False
881    False
882    False
883    False
884    False
885    False
886    False
887    False
888     True
889    False
890    False
Name: Age, dtype: bool
5     NaN
17    NaN
19    NaN
26    NaN
28    NaN
29    NaN
31    NaN
32    NaN
36    NaN
42    NaN
45    NaN
46    NaN
47    NaN
48    NaN
55    NaN
64    NaN
65    NaN
76    NaN
77    NaN
82    NaN
87    NaN
95    NaN
101   NaN
107   NaN
109   NaN
121   NaN
126   NaN
128   NaN
140   NaN
154   NaN
       ..
718   NaN
727   NaN
732   NaN
738   NaN
739   NaN
740   NaN
760   NaN
766   NaN
768   NaN
773   NaN
776   NaN
778   NaN
783   NaN
790   NaN
792   NaN
793   NaN
815   NaN
825   NaN
826   NaN
828   NaN
832   NaN
837   NaN
839   NaN
846   NaN
849   NaN
859   NaN
863   NaN
868   NaN
878   NaN
888   NaN
Name: Age, dtype: float64
177
#未处理缺失值时计算平均年龄
mean_age = sum(titanic_survival["Age"]) / len(titanic_survival["Age"])
print(mean_age)
nan
#计算非缺失值的平均年龄
good_ages = titanic_survival["Age"][age_is_null == False]
correct_mean_age = sum(good_ages) / len(good_ages)
print(correct_mean_age)
#.mean()函数计算平均值
correct_mean_age = titanic_survival["Age"].mean()
print(correct_mean_age)
29.6991176471
29.69911764705882
#不同船舱等级的船票价格
passenger_classes = [1, 2, 3]
fares_by_class = {}
for this_class in passenger_classes:
    #pclass_rows为不同舱别的数据,包含所有列
    pclass_rows = titanic_survival[titanic_survival["Pclass"] == this_class]
    #pclass_fares为["fare"]列,即不同舱别票价列的数据
    pclass_fares = pclass_rows["fare"]
    #不同舱别的平均票价
    fare_for_class = pclass_fares.mean()
    #存入list
    fares_by_class[this_class] = fare_for_class
print(fares_by_class)  
{1: 84.15468749999992, 2: 20.66218315217391, 3: 13.675550101832997}
#pivot_table参数 index= 索引 values 与**之间的关系 aggfunc= 统计的什么关系
#计算每个舱位的获救概率
passenger_survival = titanic_survival.pivot_table(index="Pclass", values="Survived", aggfunc=np.mean)
print(passenger_survival)
Pclass
1    0.629630
2    0.472826
3    0.242363
Name: Survived, dtype: float64
#计算每个舱位的平均年龄, fun未指定认为求均值
passenger_age = titanic_survival.pivot_table(index="Pclass", values = "Age")
print(passenger_age)
Pclass
1    38.233441
2    29.877630
3    25.140620
Name: Age, dtype: float64
#计算每个码头中总的船票价格和登船人数
port_stats = titanic_survival.pivot_table(index="Embarked", values=["fare","Survived"], aggfunc=np.sum)
print(port_stats)
                fare  Survived
Embarked                      
C         10072.2962        93
Q          1022.2543        30
S         17439.3988       217
#丢弃缺失值 dropna
drop_na_columns = titanic_survival.dropna(axis=1)
new_titanic_survival = titanic_survival.dropna(axis=0, subset=["Age", "Sex"])
print(new_titanic_survival)
     PassengerId  Survived  Pclass  \
0              1         0       3   
1              2         1       1   
2              3         1       3   
3              4         1       1   
4              5         0       3   
6              7         0       1   
7              8         0       3   
8              9         1       3   
9             10         1       2   
10            11         1       3   
11            12         1       1   
12            13         0       3   
13            14         0       3   
14            15         0       3   
15            16         1       2   
16            17         0       3   
18            19         0       3   
20            21         0       2   
21            22         1       2   
22            23         1       3   
23            24         1       1   
24            25         0       3   
25            26         1       3   
27            28         0       1   
30            31         0       1   
33            34         0       2   
34            35         0       1   
35            36         0       1   
37            38         0       3   
38            39         0       3   
..           ...       ...     ...   
856          857         1       1   
857          858         1       1   
858          859         1       3   
860          861         0       3   
861          862         0       2   
862          863         1       1   
864          865         0       2   
865          866         1       2   
866          867         1       2   
867          868         0       1   
869          870         1       3   
870          871         0       3   
871          872         1       1   
872          873         0       1   
873          874         0       3   
874          875         1       2   
875          876         1       3   
876          877         0       3   
877          878         0       3   
879          880         1       1   
880          881         1       2   
881          882         0       3   
882          883         0       3   
883          884         0       2   
884          885         0       3   
885          886         0       3   
886          887         0       2   
887          888         1       1   
889          890         1       1   
890          891         0       3   

                                                  Name     Sex   Age  SibSp  \
0                              Braund, Mr. Owen Harris    male  22.0      1   
1    Cumings, Mrs. John Bradley (Florence Briggs Th...  female  38.0      1   
2                               Heikkinen, Miss. Laina  female  26.0      0   
3         Futrelle, Mrs. Jacques Heath (Lily May Peel)  female  35.0      1   
4                             Allen, Mr. William Henry    male  35.0      0   
6                              McCarthy, Mr. Timothy J    male  54.0      0   
7                       Palsson, Master. Gosta Leonard    male   2.0      3   
8    Johnson, Mrs. Oscar W (Elisabeth Vilhelmina Berg)  female  27.0      0   
9                  Nasser, Mrs. Nicholas (Adele Achem)  female  14.0      1   
10                     Sandstrom, Miss. Marguerite Rut  female   4.0      1   
11                            Bonnell, Miss. Elizabeth  female  58.0      0   
12                      Saundercock, Mr. William Henry    male  20.0      0   
13                         AndeRSSon, Mr. Anders Johan    male  39.0      1   
14                Vestrom, Miss. Hulda Amanda Adolfina  female  14.0      0   
15                    Hewlett, Mrs. (Mary D Kingcome)   female  55.0      0   
16                                Rice, Master. Eugene    male   2.0      4   
18   Vander Planke, Mrs. Julius (Emelia Maria Vande...  female  31.0      1   
20                                Fynney, Mr. Joseph J    male  35.0      0   
21                               Beesley, Mr. LaWrence    male  34.0      0   
22                         McGowan, Miss. Anna "Annie"  female  15.0      0   
23                        Sloper, Mr. William Thompson    male  28.0      0   
24                       Palsson, Miss. Torborg Danira  female   8.0      3   
25   Asplund, Mrs. Carl Oscar (Selma Augusta Emilia...  female  38.0      1   
27                      Fortune, Mr. Charles Alexander    male  19.0      3   
30                            Uruchurtu, Don. Manuel E    male  40.0      0   
33                               Wheadon, Mr. Edward H    male  66.0      0   
34                             Meyer, Mr. Edgar Joseph    male  28.0      1   
35                      Holverson, Mr. Alexander Oskar    male  42.0      1   
37                            Cann, Mr. Ernest Charles    male  21.0      0   
38                  Vander Planke, Miss. Augusta Maria  female  18.0      2   
..                                                 ...     ...   ...    ...   
856         Wick, Mrs. George Dennick (Mary Hitchcock)  female  45.0      1   
857                             Daly, Mr. Peter Denis     male  51.0      0   
858              Baclini, Mrs. Solomon (Latifa Qurban)  female  24.0      0   
860                            Hansen, Mr. Claus Peter    male  41.0      2   
861                        Giles, Mr. Frederick Edward    male  21.0      1   
862  Swift, Mrs. Frederick Joel (Margaret Welles Ba...  female  48.0      0   
864                             Gill, Mr. John William    male  24.0      0   
865                           Bystrom, Mrs. (Karolina)  female  42.0      0   
866                       Duran y More, Miss. Asuncion  female  27.0      1   
867               Roebling, Mr. Washington Augustus II    male  31.0      0   
869                    Johnson, Master. Harold Theodor    male   4.0      1   
870                                  Balkic, Mr. Cerin    male  26.0      0   
871   Beckwith, Mrs. Richard Leonard (Sallie Monypeny)  female  47.0      1   
872                           Carlsson, Mr. Frans Olof    male  33.0      0   
873                        Vander Cruyssen, Mr. Victor    male  47.0      0   
874              Abelson, Mrs. Samuel (Hannah Wizosky)  female  28.0      1   
875                   Najib, Miss. Adele Kiamie "Jane"  female  15.0      0   
876                      Gustafsson, Mr. Alfred Ossian    male  20.0      0   
877                               Petroff, Mr. Nedelio    male  19.0      0   
879      Potter, Mrs. Thomas Jr (Lily Alexenia Wilson)  female  56.0      0   
880       Shelley, Mrs. William (Imanita Parrish Hall)  female  25.0      0   
881                                 Markun, Mr. Johann    male  33.0      0   
882                       Dahlberg, Miss. Gerda Ulrika  female  22.0      0   
883                      Banfield, Mr. Frederick James    male  28.0      0   
884                             Sutehall, Mr. Henry Jr    male  25.0      0   
885               Rice, Mrs. William (Margaret norton)  female  39.0      0   
886                              Montvila, Rev. Juozas    male  27.0      0   
887                       Graham, Miss. Margaret Edith  female  19.0      0   
889                              Behr, Mr. Karl Howell    male  26.0      0   
890                                Dooley, Mr. Patrick    male  32.0      0   

     Parch            Ticket      fare        Cabin Embarked  
0        0         A/5 21171    7.2500          NaN        S  
1        0          PC 17599   71.2833          C85        C  
2        0  STON/O2. 3101282    7.9250          NaN        S  
3        0            113803   53.1000         C123        S  
4        0            373450    8.0500          NaN        S  
6        0             17463   51.8625          E46        S  
7        1            349909   21.0750          NaN        S  
8        2            347742   11.1333          NaN        S  
9        0            237736   30.0708          NaN        C  
10       1           PP 9549   16.7000           G6        S  
11       0            113783   26.5500         C103        S  
12       0         A/5. 2151    8.0500          NaN        S  
13       5            347082   31.2750          NaN        S  
14       0            350406    7.8542          NaN        S  
15       0            248706   16.0000          NaN        S  
16       1            382652   29.1250          NaN        Q  
18       0            345763   18.0000          NaN        S  
20       0            239865   26.0000          NaN        S  
21       0            248698   13.0000          D56        S  
22       0            330923    8.0292          NaN        Q  
23       0            113788   35.5000           A6        S  
24       1            349909   21.0750          NaN        S  
25       5            347077   31.3875          NaN        S  
27       2             19950  263.0000  C23 C25 C27        S  
30       0          PC 17601   27.7208          NaN        C  
33       0        C.A. 24579   10.5000          NaN        S  
34       0          PC 17604   82.1708          NaN        C  
35       0            113789   52.0000          NaN        S  
37       0        A./5. 2152    8.0500          NaN        S  
38       0            345764   18.0000          NaN        S  
..     ...               ...       ...          ...      ...  
856      1             36928  164.8667          NaN        S  
857      0            113055   26.5500          E17        S  
858      3              2666   19.2583          NaN        C  
860      0            350026   14.1083          NaN        S  
861      0             28134   11.5000          NaN        S  
862      0             17466   25.9292          D17        S  
864      0            233866   13.0000          NaN        S  
865      0            236852   13.0000          NaN        S  
866      0     SC/PARIS 2149   13.8583          NaN        C  
867      0          PC 17590   50.4958          A24        S  
869      1            347742   11.1333          NaN        S  
870      0            349248    7.8958          NaN        S  
871      1             11751   52.5542          D35        S  
872      0               695    5.0000  B51 B53 B55        S  
873      0            345765    9.0000          NaN        S  
874      0         P/PP 3381   24.0000          NaN        C  
875      0              2667    7.2250          NaN        C  
876      0              7534    9.8458          NaN        S  
877      0            349212    7.8958          NaN        S  
879      1             11767   83.1583          C50        C  
880      1            230433   26.0000          NaN        S  
881      0            349257    7.8958          NaN        S  
882      0              7552   10.5167          NaN        S  
883      0  C.A./sotoN 34068   10.5000          NaN        S  
884      0   sotoN/OQ 392076    7.0500          NaN        S  
885      5            382652   29.1250          NaN        Q  
886      0            211536   13.0000          NaN        S  
887      0            112053   30.0000          B42        S  
889      0            111369   30.0000         C148        C  
890      0            370376    7.7500          NaN        Q  

[714 rows x 12 columns]
#定位到具体的值
row_index_83_age = titanic_survival.loc[83, "Age"]
row_index_1000_pclass = titanic_survival.loc[766, "Pclass"]
print(row_index_83_age, row_index_1000_pclass)
28.0 1
new_titanic_survival = titanic_survival.sort_values("Age", ascending=False)
print(new_titanic_survival[0:10])
#将index值重新排序reset_index, drop=true为原来的删除
titanic_reindexed = new_titanic_survival.reset_index(drop=True)
print(titanic_reindexed[0:10])
     PassengerId  Survived  Pclass                                  Name  \
630          631         1       1  Barkworth, Mr. Algernon Henry Wilson   
851          852         0       3                   svensson, Mr. Johan   
493          494         0       1               Artagaveytia, Mr. Ramon   
96            97         0       1             Goldschmidt, Mr. George B   
116          117         0       3                  Connors, Mr. Patrick   
672          673         0       2           Mitchell, Mr. Henry Michael   
745          746         0       1          Crosby, Capt. Edward Gifford   
33            34         0       2                 Wheadon, Mr. Edward H   
54            55         0       1        Ostby, Mr. Engelhart Cornelius   
280          281         0       3                      Duane, Mr. Frank   

      Sex   Age  SibSp  Parch      Ticket     fare Cabin Embarked  
630  male  80.0      0      0       27042  30.0000   A23        S  
851  male  74.0      0      0      347060   7.7750   NaN        S  
493  male  71.0      0      0    PC 17609  49.5042   NaN        C  
96   male  71.0      0      0    PC 17754  34.6542    A5        C  
116  male  70.5      0      0      370369   7.7500   NaN        Q  
672  male  70.0      0      0  C.A. 24580  10.5000   NaN        S  
745  male  70.0      1      1   WE/P 5735  71.0000   B22        S  
33   male  66.0      0      0  C.A. 24579  10.5000   NaN        S  
54   male  65.0      0      1      113509  61.9792   B30        C  
280  male  65.0      0      0      336439   7.7500   NaN        Q  
   PassengerId  Survived  Pclass                                  Name   Sex  \
0          631         1       1  Barkworth, Mr. Algernon Henry Wilson  male   
1          852         0       3                   svensson, Mr. Johan  male   
2          494         0       1               Artagaveytia, Mr. Ramon  male   
3           97         0       1             Goldschmidt, Mr. George B  male   
4          117         0       3                  Connors, Mr. Patrick  male   
5          673         0       2           Mitchell, Mr. Henry Michael  male   
6          746         0       1          Crosby, Capt. Edward Gifford  male   
7           34         0       2                 Wheadon, Mr. Edward H  male   
8           55         0       1        Ostby, Mr. Engelhart Cornelius  male   
9          281         0       3                      Duane, Mr. Frank  male   

    Age  SibSp  Parch      Ticket     fare Cabin Embarked  
0  80.0      0      0       27042  30.0000   A23        S  
1  74.0      0      0      347060   7.7750   NaN        S  
2  71.0      0      0    PC 17609  49.5042   NaN        C  
3  71.0      0      0    PC 17754  34.6542    A5        C  
4  70.5      0      0      370369   7.7500   NaN        Q  
5  70.0      0      0  C.A. 24580  10.5000   NaN        S  
6  70.0      1      1   WE/P 5735  71.0000   B22        S  
7  66.0      0      0  C.A. 24579  10.5000   NaN        S  
8  65.0      0      1      113509  61.9792   B30        C  
9  65.0      0      0      336439   7.7500   NaN        Q  
#apply函数,可以自定义函数,参数为函数
#返回第100行数据
def hundredth_row(column):
    hundredth_item = column.loc[99]
    return hundredth_item
hundredth_row = titanic_survival.apply(hundredth_row)
print(hundredth_row)
PassengerId                  100
Survived                       0
Pclass                         2
Name           Kantor, Mr. Sinai
Sex                         male
Age                           34
SibSp                          1
Parch                          0
Ticket                    244367
fare                          26
Cabin                        NaN
Embarked                       S
dtype: object
#计算每一列缺失值个数
def is_null_count(column):
    column_null = pd.isnull(column)
    null = column[column_null]
    return len(null)

column_null_count = titanic_survival.apply(is_null_count)
print(column_null_count)
PassengerId      0
Survived         0
Pclass           0
Name             0
Sex              0
Age            177
SibSp            0
Parch            0
Ticket           0
fare             0
Cabin          687
Embarked         2
dtype: int64
def which_class(row):
    pclass = row['Pclass']
    if pclass == 1:
        "First Class"
    elif pclass == 2:
        return "Second Class"
    elif pclass == 3:
        return "Third Class"
    else:
        return "UnkNown"

classes = titanic_survival.apply(which_class, axis=1)
print(classes)
0       Third Class
1              None
2       Third Class
3              None
4       Third Class
5       Third Class
6              None
7       Third Class
8       Third Class
9      Second Class
10      Third Class
11             None
12      Third Class
13      Third Class
14      Third Class
15     Second Class
16      Third Class
17     Second Class
18      Third Class
19      Third Class
20     Second Class
21     Second Class
22      Third Class
23             None
24      Third Class
25      Third Class
26      Third Class
27             None
28      Third Class
29      Third Class
           ...     
861    Second Class
862            None
863     Third Class
864    Second Class
865    Second Class
866    Second Class
867            None
868     Third Class
869     Third Class
870     Third Class
871            None
872            None
873     Third Class
874    Second Class
875     Third Class
876     Third Class
877     Third Class
878     Third Class
879            None
880    Second Class
881     Third Class
882     Third Class
883    Second Class
884     Third Class
885     Third Class
886    Second Class
887            None
888     Third Class
889            None
890     Third Class
dtype: object
def is_minor(row):
    if row["Age"] < 18:
        return True
    else:
        return False
    
minors = titanic_survival.apply(is_minor, axis=1)
print(minors)

def generate_age_label(row):
    age = row["Age"]
    if pd.isnull(age):
        return "unkNown"
    elif age<18:
        return "minor"
    else:
        return "adult"
    
age_labels = titanic_survival.apply(generate_age_label, axis=1)
print(age_labels)
0      False
1      False
2      False
3      False
4      False
5      False
6      False
7       True
8      False
9       True
10      True
11     False
12     False
13     False
14      True
15     False
16      True
17     False
18     False
19     False
20     False
21     False
22      True
23     False
24      True
25     False
26     False
27     False
28     False
29     False
       ...  
861    False
862    False
863    False
864    False
865    False
866    False
867    False
868    False
869     True
870    False
871    False
872    False
873    False
874    False
875     True
876    False
877    False
878    False
879    False
880    False
881    False
882    False
883    False
884    False
885    False
886    False
887    False
888    False
889    False
890    False
dtype: bool
0        adult
1        adult
2        adult
3        adult
4        adult
5      unkNown
6        adult
7        minor
8        adult
9        minor
10       minor
11       adult
12       adult
13       adult
14       minor
15       adult
16       minor
17     unkNown
18       adult
19     unkNown
20       adult
21       adult
22       minor
23       adult
24       minor
25       adult
26     unkNown
27       adult
28     unkNown
29     unkNown
        ...   
861      adult
862      adult
863    unkNown
864      adult
865      adult
866      adult
867      adult
868    unkNown
869      minor
870      adult
871      adult
872      adult
873      adult
874      adult
875      minor
876      adult
877      adult
878    unkNown
879      adult
880      adult
881      adult
882      adult
883      adult
884      adult
885      adult
886      adult
887      adult
888    unkNown
889      adult
890      adult
dtype: object
titanic_survival['age_labels'] = age_labels
age_group_survival = titanic_survival.pivot_table(index="age_labels", values="Survived")
print(age_group_survival)
age_labels
adult      0.381032
minor      0.539823
unkNown    0.293785
Name: Survived, dtype: float64
#切分为series结构
import pandas as pd
fandango = pd.read_csv("fandango_score_comparison.csv")
series_film = fandango['FILM']
print(type(series_film))
print(series_film[0:5])
series_rt = fandango['RottenTomatoes']
print(series_rt[0:5])
<class 'pandas.core.series.Series'>
0    Avengers: Age of Ultron (2015)
1                 Cinderella (2015)
2                    Ant-Man (2015)
3            Do You Believe? (2015)
4     Hot Tub Time Machine 2 (2015)
Name: FILM, dtype: object
0    74
1    85
2    80
3    18
4    14
Name: RottenTomatoes, dtype: int64
#新建series结构
from pandas import Series
#pandas是封装在numpy结构基础之上的
film_names = series_film.values
# print(type(film_names), film_names)
rt_scores = series_rt.values
# print(rt_scores)
#用名字当成索引
series_custom = Series(rt_scores,index=film_names)
series_custom[['Minions (2015)', 'Leviathan (2014)', 'Avengers: Age of Ultron (2015)']]
Minions (2015)                    54
Leviathan (2014)                  99
Avengers: Age of Ultron (2015)    74
dtype: int64
#排序 按照首字母排序
original_index = series_custom.index.tolist()
# print(original_index)
sorted_index = sorted(original_index)
# print(sorted_index)
sorted_by_index = series_custom.reindex(sorted_index)
# print(sorted_by_index)
original_values = series_custom.values.tolist()
# print(original_index)
sorted_values = sorted(original_values)
# print(sorted_values)
sc3 = series_custom.sort_values()
print(sc3)
Paul Blart: Mall cop 2 (2015)                    5
Hitman: Agent 47 (2015)                          7
Hot Pursuit (2015)                               8
Fantastic Four (2015)                            9
Taken 3 (2015)                                   9
The Boy Next Door (2015)                        10
The Loft (2015)                                 11
Unfinished Business (2015)                      11
Mortdecai (2015)                                12
Seventh Son (2015)                              12
The Vatican Tapes (2015)                        13
Sinister 2 (2015)                               13
The Lazarus Effect (2015)                       14
Hot Tub Time Machine 2 (2015)                   14
The gallows (2015)                              16
The Gunman (2015)                               17
Pixels (2015)                                   17
Strange Magic (2015)                            17
Do You Believe? (2015)                          18
Serena (2015)                                   18
Aloha (2015)                                    19
Self/less (2015)                                20
Little Boy (2015)                               20
The Woman In Black 2 Angel of Death (2015)      22
Fifty Shades of Grey (2015)                     25
Terminator Genisys (2015)                       26
Child 44 (2015)                                 26
Dark Places (2015)                              26
Jupiter Ascending (2015)                        26
Annie (2014)                                    27
                                              ... 
Ex Machina (2015)                               92
Mission: Impossible – Rogue Nation (2015)     92
Spy (2015)                                      93
The Gift (2015)                                 93
The Wrecking Crew (2015)                        93
Monkey Kingdom (2015)                           94
I'll See You In My Dreams (2015)                94
Tangerine (2015)                                95
The Diary of a Teenage Girl (2015)              95
Wild Tales (2014)                               96
It Follows (2015)                               96
Red Army (2015)                                 96
The Salt of the Earth (2015)                    96
What We Do in the Shadows (2015)                96
'71 (2015)                                      97
About Elly (2015)                               97
Two Days, One Night (2014)                      97
Amy (2015)                                      97
Mad Max: Fury Road (2015)                       97
Inside Out (2015)                               98
Paddington (2015)                               98
Mr. Turner (2014)                               98
Timbuktu (2015)                                 99
Shaun the Sheep Movie (2015)                    99
Leviathan (2014)                                99
Song of the Sea (2014)                          99
Phoenix (2015)                                  99
Selma (2014)                                    99
Seymour: An Introduction (2015)                100
Gett: The Trial of Viviane Amsalem (2015)      100
Length: 146, dtype: int64
#相加
import numpy as np
print(np.add(series_custom, series_custom))
np.sin(series_custom)
np.max(series_custom)
Avengers: Age of Ultron (2015)                    148
Cinderella (2015)                                 170
Ant-Man (2015)                                    160
Do You Believe? (2015)                             36
Hot Tub Time Machine 2 (2015)                      28
The Water Diviner (2015)                          126
Irrational Man (2015)                              84
Top Five (2014)                                   172
Shaun the Sheep Movie (2015)                      198
love & Mercy (2015)                               178
Far From The Madding Crowd (2015)                 168
Black Sea (2015)                                  164
Leviathan (2014)                                  198
Unbroken (2014)                                   102
The Imitation Game (2014)                         180
Taken 3 (2015)                                     18
Ted 2 (2015)                                       92
Southpaw (2015)                                   118
Night at the Museum: Secret of the Tomb (2014)    100
Pixels (2015)                                      34
McFarland, USA (2015)                             158
Insidious: Chapter 3 (2015)                       118
The Man From U.N.C.L.E. (2015)                    136
Run All Night (2015)                              120
Trainwreck (2015)                                 170
Selma (2014)                                      198
Ex Machina (2015)                                 184
Still Alice (2015)                                176
Wild Tales (2014)                                 192
The End of the Tour (2015)                        184
                                                 ... 
Clouds of Sils Maria (2015)                       178
Testament of Youth (2015)                         162
Infinitely Polar Bear (2015)                      160
Phoenix (2015)                                    198
The Wolfpack (2015)                               168
The Stanford Prison Experiment (2015)             168
Tangerine (2015)                                  190
Magic Mike XXL (2015)                             124
Home (2015)                                        90
The Wedding Ringer (2015)                          54
Woman in Gold (2015)                              104
The Last Five Years (2015)                        120
Mission: Impossible – Rogue Nation (2015)       184
Amy (2015)                                        194
Jurassic World (2015)                             142
Minions (2015)                                    108
Max (2015)                                         70
Paul Blart: Mall cop 2 (2015)                      10
The Longest Ride (2015)                            62
The Lazarus Effect (2015)                          28
The Woman In Black 2 Angel of Death (2015)         44
Danny Collins (2015)                              154
Spare Parts (2015)                                104
Serena (2015)                                      36
Inside Out (2015)                                 196
Mr. Holmes (2015)                                 174
'71 (2015)                                        194
Two Days, One Night (2014)                        194
Gett: The Trial of Viviane Amsalem (2015)         200
Kumiko, The Treasure Hunter (2015)                174
Length: 146, dtype: int64





100
import pandas as pd
fandango = pd.read_csv('fandango_score_comparison.csv')
print(type(fandango))
#将'FILM'当做索引
fandango_films = fandango.set_index('FILM', drop=False)
print(fandango_films.index)
<class 'pandas.core.frame.DataFrame'>
Index(['Avengers: Age of Ultron (2015)', 'Cinderella (2015)', 'Ant-Man (2015)',
       'Do You Believe? (2015)', 'Hot Tub Time Machine 2 (2015)',
       'The Water Diviner (2015)', 'Irrational Man (2015)', 'Top Five (2014)',
       'Shaun the Sheep Movie (2015)', 'love & Mercy (2015)',
       ...
       'The Woman In Black 2 Angel of Death (2015)', 'Danny Collins (2015)',
       'Spare Parts (2015)', 'Serena (2015)', 'Inside Out (2015)',
       'Mr. Holmes (2015)', ''71 (2015)', 'Two Days, One Night (2014)',
       'Gett: The Trial of Viviane Amsalem (2015)',
       'Kumiko, The Treasure Hunter (2015)'],
      dtype='object', name='FILM', length=146)
fandango_films['Avengers: Age of Ultron (2015)':'Hot Tub Time Machine 2 (2015)']
fandango_films.loc['Avengers: Age of Ultron (2015)':'Hot Tub Time Machine 2 (2015)']
fandango_films.loc['Kumiko, The Treasure Hunter (2015)']
movies = ['Kumiko, The Treasure Hunter (2015)', 'Do You Believe? (2015)','Ant-Man (2015)']
fandango_films.loc[movies]
FILM RottenTomatoes RottenTomatoes_User Metacritic Metacritic_User IMDB Fandango_Stars Fandango_ratingvalue RT_norm RT_user_norm ... IMDB_norm RT_norm_round RT_user_norm_round Metacritic_norm_round Metacritic_user_norm_round IMDB_norm_round Metacritic_user_Vote_count IMDB_user_Vote_count Fandango_Votes Fandango_Difference
FILM
Kumiko, The Treasure Hunter (2015) Kumiko, The Treasure Hunter (2015) 87 63 68 6.4 6.7 3.5 3.5 4.35 3.15 ... 3.35 4.5 3.0 3.5 3.0 3.5 19 5289 41 0.0
Do You Believe? (2015) Do You Believe? (2015) 18 84 22 4.7 5.4 5.0 4.5 0.90 4.20 ... 2.70 1.0 4.0 1.0 2.5 2.5 31 3136 1793 0.5
Ant-Man (2015) Ant-Man (2015) 80 90 64 8.1 7.8 5.0 4.5 4.00 4.50 ... 3.90 4.0 4.5 3.0 4.0 4.0 627 103660 12055 0.5

3 rows × 22 columns

#类型转换
import numpy as np
types = fandango_films.dtypes
# print(types)
float_columns = types[types.values == 'float64'].index
float_df = fandango_films[float_columns]
print(float_df)
#lambda 快速定义单行函数 std()计算标准差
deviations = float_df.apply(lambda x:np.std(x))
                                                Metacritic_User  IMDB  \
FILM                                                                    
Avengers: Age of Ultron (2015)                              7.1   7.8   
Cinderella (2015)                                           7.5   7.1   
Ant-Man (2015)                                              8.1   7.8   
Do You Believe? (2015)                                      4.7   5.4   
Hot Tub Time Machine 2 (2015)                               3.4   5.1   
The Water Diviner (2015)                                    6.8   7.2   
Irrational Man (2015)                                       7.6   6.9   
Top Five (2014)                                             6.8   6.5   
Shaun the Sheep Movie (2015)                                8.8   7.4   
love & Mercy (2015)                                         8.5   7.8   
Far From The Madding Crowd (2015)                           7.5   7.2   
Black Sea (2015)                                            6.6   6.4   
Leviathan (2014)                                            7.2   7.7   
Unbroken (2014)                                             6.5   7.2   
The Imitation Game (2014)                                   8.2   8.1   
Taken 3 (2015)                                              4.6   6.1   
Ted 2 (2015)                                                6.5   6.6   
Southpaw (2015)                                             8.2   7.8   
Night at the Museum: Secret of the Tomb (2014)              5.8   6.3   
Pixels (2015)                                               5.3   5.6   
McFarland, USA (2015)                                       7.2   7.5   
Insidious: Chapter 3 (2015)                                 6.9   6.3   
The Man From U.N.C.L.E. (2015)                              7.9   7.6   
Run All Night (2015)                                        7.3   6.6   
Trainwreck (2015)                                           6.0   6.7   
Selma (2014)                                                7.1   7.5   
Ex Machina (2015)                                           7.9   7.7   
Still Alice (2015)                                          7.8   7.5   
Wild Tales (2014)                                           8.8   8.2   
The End of the Tour (2015)                                  7.5   7.9   
...                                                         ...   ...   
Clouds of Sils Maria (2015)                                 7.1   6.8   
Testament of Youth (2015)                                   7.9   7.3   
Infinitely Polar Bear (2015)                                7.9   7.2   
Phoenix (2015)                                              8.0   7.2   
The Wolfpack (2015)                                         7.0   7.1   
The Stanford Prison Experiment (2015)                       8.5   7.1   
Tangerine (2015)                                            7.3   7.4   
Magic Mike XXL (2015)                                       5.4   6.3   
Home (2015)                                                 7.3   6.7   
The Wedding Ringer (2015)                                   3.3   6.7   
Woman in Gold (2015)                                        7.2   7.4   
The Last Five Years (2015)                                  6.9   6.0   
Mission: Impossible – Rogue Nation (2015)                 8.0   7.8   
Amy (2015)                                                  8.8   8.0   
Jurassic World (2015)                                       7.0   7.3   
Minions (2015)                                              5.7   6.7   
Max (2015)                                                  5.9   7.0   
Paul Blart: Mall cop 2 (2015)                               2.4   4.3   
The Longest Ride (2015)                                     4.8   7.2   
The Lazarus Effect (2015)                                   4.9   5.2   
The Woman In Black 2 Angel of Death (2015)                  4.4   4.9   
Danny Collins (2015)                                        7.1   7.1   
Spare Parts (2015)                                          7.1   7.2   
Serena (2015)                                               5.3   5.4   
Inside Out (2015)                                           8.9   8.6   
Mr. Holmes (2015)                                           7.9   7.4   
'71 (2015)                                                  7.5   7.2   
Two Days, One Night (2014)                                  8.8   7.4   
Gett: The Trial of Viviane Amsalem (2015)                   7.3   7.8   
Kumiko, The Treasure Hunter (2015)                          6.4   6.7   

                                                Fandango_Stars  \
FILM                                                             
Avengers: Age of Ultron (2015)                             5.0   
Cinderella (2015)                                          5.0   
Ant-Man (2015)                                             5.0   
Do You Believe? (2015)                                     5.0   
Hot Tub Time Machine 2 (2015)                              3.5   
The Water Diviner (2015)                                   4.5   
Irrational Man (2015)                                      4.0   
Top Five (2014)                                            4.0   
Shaun the Sheep Movie (2015)                               4.5   
love & Mercy (2015)                                        4.5   
Far From The Madding Crowd (2015)                          4.5   
Black Sea (2015)                                           4.0   
Leviathan (2014)                                           4.0   
Unbroken (2014)                                            4.5   
The Imitation Game (2014)                                  5.0   
Taken 3 (2015)                                             4.5   
Ted 2 (2015)                                               4.5   
Southpaw (2015)                                            5.0   
Night at the Museum: Secret of the Tomb (2014)             4.5   
Pixels (2015)                                              4.5   
McFarland, USA (2015)                                      5.0   
Insidious: Chapter 3 (2015)                                4.5   
The Man From U.N.C.L.E. (2015)                             4.5   
Run All Night (2015)                                       4.5   
Trainwreck (2015)                                          4.5   
Selma (2014)                                               5.0   
Ex Machina (2015)                                          4.5   
Still Alice (2015)                                         4.5   
Wild Tales (2014)                                          4.5   
The End of the Tour (2015)                                 4.5   
...                                                        ...   
Clouds of Sils Maria (2015)                                3.5   
Testament of Youth (2015)                                  4.0   
Infinitely Polar Bear (2015)                               4.0   
Phoenix (2015)                                             3.5   
The Wolfpack (2015)                                        3.5   
The Stanford Prison Experiment (2015)                      4.0   
Tangerine (2015)                                           4.0   
Magic Mike XXL (2015)                                      4.5   
Home (2015)                                                4.5   
The Wedding Ringer (2015)                                  4.5   
Woman in Gold (2015)                                       4.5   
The Last Five Years (2015)                                 4.5   
Mission: Impossible – Rogue Nation (2015)                4.5   
Amy (2015)                                                 4.5   
Jurassic World (2015)                                      4.5   
Minions (2015)                                             4.0   
Max (2015)                                                 4.5   
Paul Blart: Mall cop 2 (2015)                              3.5   
The Longest Ride (2015)                                    4.5   
The Lazarus Effect (2015)                                  3.0   
The Woman In Black 2 Angel of Death (2015)                 3.0   
Danny Collins (2015)                                       4.0   
Spare Parts (2015)                                         4.5   
Serena (2015)                                              3.0   
Inside Out (2015)                                          4.5   
Mr. Holmes (2015)                                          4.0   
'71 (2015)                                                 3.5   
Two Days, One Night (2014)                                 3.5   
Gett: The Trial of Viviane Amsalem (2015)                  3.5   
Kumiko, The Treasure Hunter (2015)                         3.5   

                                                Fandango_ratingvalue  RT_norm  \
FILM                                                                            
Avengers: Age of Ultron (2015)                                   4.5     3.70   
Cinderella (2015)                                                4.5     4.25   
Ant-Man (2015)                                                   4.5     4.00   
Do You Believe? (2015)                                           4.5     0.90   
Hot Tub Time Machine 2 (2015)                                    3.0     0.70   
The Water Diviner (2015)                                         4.0     3.15   
Irrational Man (2015)                                            3.5     2.10   
Top Five (2014)                                                  3.5     4.30   
Shaun the Sheep Movie (2015)                                     4.0     4.95   
love & Mercy (2015)                                              4.0     4.45   
Far From The Madding Crowd (2015)                                4.0     4.20   
Black Sea (2015)                                                 3.5     4.10   
Leviathan (2014)                                                 3.5     4.95   
Unbroken (2014)                                                  4.1     2.55   
The Imitation Game (2014)                                        4.6     4.50   
Taken 3 (2015)                                                   4.1     0.45   
Ted 2 (2015)                                                     4.1     2.30   
Southpaw (2015)                                                  4.6     2.95   
Night at the Museum: Secret of the Tomb (2014)                   4.1     2.50   
Pixels (2015)                                                    4.1     0.85   
McFarland, USA (2015)                                            4.6     3.95   
Insidious: Chapter 3 (2015)                                      4.1     2.95   
The Man From U.N.C.L.E. (2015)                                   4.1     3.40   
Run All Night (2015)                                             4.1     3.00   
Trainwreck (2015)                                                4.1     4.25   
Selma (2014)                                                     4.6     4.95   
Ex Machina (2015)                                                4.1     4.60   
Still Alice (2015)                                               4.1     4.40   
Wild Tales (2014)                                                4.1     4.80   
The End of the Tour (2015)                                       4.1     4.60   
...                                                              ...      ...   
Clouds of Sils Maria (2015)                                      3.4     4.45   
Testament of Youth (2015)                                        3.9     4.05   
Infinitely Polar Bear (2015)                                     3.9     4.00   
Phoenix (2015)                                                   3.4     4.95   
The Wolfpack (2015)                                              3.4     4.20   
The Stanford Prison Experiment (2015)                            3.9     4.20   
Tangerine (2015)                                                 3.9     4.75   
Magic Mike XXL (2015)                                            4.4     3.10   
Home (2015)                                                      4.4     2.25   
The Wedding Ringer (2015)                                        4.4     1.35   
Woman in Gold (2015)                                             4.4     2.60   
The Last Five Years (2015)                                       4.4     3.00   
Mission: Impossible – Rogue Nation (2015)                      4.4     4.60   
Amy (2015)                                                       4.4     4.85   
Jurassic World (2015)                                            4.5     3.55   
Minions (2015)                                                   4.0     2.70   
Max (2015)                                                       4.5     1.75   
Paul Blart: Mall cop 2 (2015)                                    3.5     0.25   
The Longest Ride (2015)                                          4.5     1.55   
The Lazarus Effect (2015)                                        3.0     0.70   
The Woman In Black 2 Angel of Death (2015)                       3.0     1.10   
Danny Collins (2015)                                             4.0     3.85   
Spare Parts (2015)                                               4.5     2.60   
Serena (2015)                                                    3.0     0.90   
Inside Out (2015)                                                4.5     4.90   
Mr. Holmes (2015)                                                4.0     4.35   
'71 (2015)                                                       3.5     4.85   
Two Days, One Night (2014)                                       3.5     4.85   
Gett: The Trial of Viviane Amsalem (2015)                        3.5     5.00   
Kumiko, The Treasure Hunter (2015)                               3.5     4.35   

                                                RT_user_norm  Metacritic_norm  \
FILM                                                                            
Avengers: Age of Ultron (2015)                          4.30             3.30   
Cinderella (2015)                                       4.00             3.35   
Ant-Man (2015)                                          4.50             3.20   
Do You Believe? (2015)                                  4.20             1.10   
Hot Tub Time Machine 2 (2015)                           1.40             1.45   
The Water Diviner (2015)                                3.10             2.50   
Irrational Man (2015)                                   2.65             2.65   
Top Five (2014)                                         3.20             4.05   
Shaun the Sheep Movie (2015)                            4.10             4.05   
love & Mercy (2015)                                     4.35             4.00   
Far From The Madding Crowd (2015)                       3.85             3.55   
Black Sea (2015)                                        3.00             3.10   
Leviathan (2014)                                        3.95             4.60   
Unbroken (2014)                                         3.50             2.95   
The Imitation Game (2014)                               4.60             3.65   
Taken 3 (2015)                                          2.30             1.30   
Ted 2 (2015)                                            2.90             2.40   
Southpaw (2015)                                         4.00             2.85   
Night at the Museum: Secret of the Tomb (2014)          2.90             2.35   
Pixels (2015)                                           2.70             1.35   
McFarland, USA (2015)                                   4.45             3.00   
Insidious: Chapter 3 (2015)                             2.80             2.60   
The Man From U.N.C.L.E. (2015)                          4.00             2.75   
Run All Night (2015)                                    2.95             2.95   
Trainwreck (2015)                                       3.70             3.75   
Selma (2014)                                            4.30             4.45   
Ex Machina (2015)                                       4.30             3.90   
Still Alice (2015)                                      4.25             3.60   
Wild Tales (2014)                                       4.60             3.85   
The End of the Tour (2015)                              4.45             4.20   
...                                                      ...              ...   
Clouds of Sils Maria (2015)                             3.35             3.90   
Testament of Youth (2015)                               3.95             3.85   
Infinitely Polar Bear (2015)                            3.80             3.20   
Phoenix (2015)                                          4.05             4.55   
The Wolfpack (2015)                                     3.65             3.75   
The Stanford Prison Experiment (2015)                   4.35             3.40   
Tangerine (2015)                                        4.30             4.30   
Magic Mike XXL (2015)                                   3.20             3.00   
Home (2015)                                             3.25             2.75   
The Wedding Ringer (2015)                               3.30             1.75   
Woman in Gold (2015)                                    4.05             2.55   
The Last Five Years (2015)                              3.00             3.00   
Mission: Impossible – Rogue Nation (2015)             4.50             3.75   
Amy (2015)                                              4.55             4.25   
Jurassic World (2015)                                   4.05             2.95   
Minions (2015)                                          2.60             2.80   
Max (2015)                                              3.65             2.35   
Paul Blart: Mall cop 2 (2015)                           1.80             0.65   
The Longest Ride (2015)                                 3.65             1.65   
The Lazarus Effect (2015)                               1.15             1.55   
The Woman In Black 2 Angel of Death (2015)              1.25             2.10   
Danny Collins (2015)                                    3.75             2.90   
Spare Parts (2015)                                      4.15             2.50   
Serena (2015)                                           1.25             1.80   
Inside Out (2015)                                       4.50             4.70   
Mr. Holmes (2015)                                       3.90             3.35   
'71 (2015)                                              4.10             4.15   
Two Days, One Night (2014)                              3.90             4.45   
Gett: The Trial of Viviane Amsalem (2015)               4.05             4.50   
Kumiko, The Treasure Hunter (2015)                      3.15             3.40   

                                                Metacritic_user_nom  \
FILM                                                                  
Avengers: Age of Ultron (2015)                                 3.55   
Cinderella (2015)                                              3.75   
Ant-Man (2015)                                                 4.05   
Do You Believe? (2015)                                         2.35   
Hot Tub Time Machine 2 (2015)                                  1.70   
The Water Diviner (2015)                                       3.40   
Irrational Man (2015)                                          3.80   
Top Five (2014)                                                3.40   
Shaun the Sheep Movie (2015)                                   4.40   
love & Mercy (2015)                                            4.25   
Far From The Madding Crowd (2015)                              3.75   
Black Sea (2015)                                               3.30   
Leviathan (2014)                                               3.60   
Unbroken (2014)                                                3.25   
The Imitation Game (2014)                                      4.10   
Taken 3 (2015)                                                 2.30   
Ted 2 (2015)                                                   3.25   
Southpaw (2015)                                                4.10   
Night at the Museum: Secret of the Tomb (2014)                 2.90   
Pixels (2015)                                                  2.65   
McFarland, USA (2015)                                          3.60   
Insidious: Chapter 3 (2015)                                    3.45   
The Man From U.N.C.L.E. (2015)                                 3.95   
Run All Night (2015)                                           3.65   
Trainwreck (2015)                                              3.00   
Selma (2014)                                                   3.55   
Ex Machina (2015)                                              3.95   
Still Alice (2015)                                             3.90   
Wild Tales (2014)                                              4.40   
The End of the Tour (2015)                                     3.75   
...                                                             ...   
Clouds of Sils Maria (2015)                                    3.55   
Testament of Youth (2015)                                      3.95   
Infinitely Polar Bear (2015)                                   3.95   
Phoenix (2015)                                                 4.00   
The Wolfpack (2015)                                            3.50   
The Stanford Prison Experiment (2015)                          4.25   
Tangerine (2015)                                               3.65   
Magic Mike XXL (2015)                                          2.70   
Home (2015)                                                    3.65   
The Wedding Ringer (2015)                                      1.65   
Woman in Gold (2015)                                           3.60   
The Last Five Years (2015)                                     3.45   
Mission: Impossible – Rogue Nation (2015)                    4.00   
Amy (2015)                                                     4.40   
Jurassic World (2015)                                          3.50   
Minions (2015)                                                 2.85   
Max (2015)                                                     2.95   
Paul Blart: Mall cop 2 (2015)                                  1.20   
The Longest Ride (2015)                                        2.40   
The Lazarus Effect (2015)                                      2.45   
The Woman In Black 2 Angel of Death (2015)                     2.20   
Danny Collins (2015)                                           3.55   
Spare Parts (2015)                                             3.55   
Serena (2015)                                                  2.65   
Inside Out (2015)                                              4.45   
Mr. Holmes (2015)                                              3.95   
'71 (2015)                                                     3.75   
Two Days, One Night (2014)                                     4.40   
Gett: The Trial of Viviane Amsalem (2015)                      3.65   
Kumiko, The Treasure Hunter (2015)                             3.20   

                                                IMDB_norm  RT_norm_round  \
FILM                                                                       
Avengers: Age of Ultron (2015)                       3.90            3.5   
Cinderella (2015)                                    3.55            4.5   
Ant-Man (2015)                                       3.90            4.0   
Do You Believe? (2015)                               2.70            1.0   
Hot Tub Time Machine 2 (2015)                        2.55            0.5   
The Water Diviner (2015)                             3.60            3.0   
Irrational Man (2015)                                3.45            2.0   
Top Five (2014)                                      3.25            4.5   
Shaun the Sheep Movie (2015)                         3.70            5.0   
love & Mercy (2015)                                  3.90            4.5   
Far From The Madding Crowd (2015)                    3.60            4.0   
Black Sea (2015)                                     3.20            4.0   
Leviathan (2014)                                     3.85            5.0   
Unbroken (2014)                                      3.60            2.5   
The Imitation Game (2014)                            4.05            4.5   
Taken 3 (2015)                                       3.05            0.5   
Ted 2 (2015)                                         3.30            2.5   
Southpaw (2015)                                      3.90            3.0   
Night at the Museum: Secret of the Tomb (2014)       3.15            2.5   
Pixels (2015)                                        2.80            1.0   
McFarland, USA (2015)                                3.75            4.0   
Insidious: Chapter 3 (2015)                          3.15            3.0   
The Man From U.N.C.L.E. (2015)                       3.80            3.5   
Run All Night (2015)                                 3.30            3.0   
Trainwreck (2015)                                    3.35            4.5   
Selma (2014)                                         3.75            5.0   
Ex Machina (2015)                                    3.85            4.5   
Still Alice (2015)                                   3.75            4.5   
Wild Tales (2014)                                    4.10            5.0   
The End of the Tour (2015)                           3.95            4.5   
...                                                   ...            ...   
Clouds of Sils Maria (2015)                          3.40            4.5   
Testament of Youth (2015)                            3.65            4.0   
Infinitely Polar Bear (2015)                         3.60            4.0   
Phoenix (2015)                                       3.60            5.0   
The Wolfpack (2015)                                  3.55            4.0   
The Stanford Prison Experiment (2015)                3.55            4.0   
Tangerine (2015)                                     3.70            5.0   
Magic Mike XXL (2015)                                3.15            3.0   
Home (2015)                                          3.35            2.5   
The Wedding Ringer (2015)                            3.35            1.5   
Woman in Gold (2015)                                 3.70            2.5   
The Last Five Years (2015)                           3.00            3.0   
Mission: Impossible – Rogue Nation (2015)          3.90            4.5   
Amy (2015)                                           4.00            5.0   
Jurassic World (2015)                                3.65            3.5   
Minions (2015)                                       3.35            2.5   
Max (2015)                                           3.50            2.0   
Paul Blart: Mall cop 2 (2015)                        2.15            0.5   
The Longest Ride (2015)                              3.60            1.5   
The Lazarus Effect (2015)                            2.60            0.5   
The Woman In Black 2 Angel of Death (2015)           2.45            1.0   
Danny Collins (2015)                                 3.55            4.0   
Spare Parts (2015)                                   3.60            2.5   
Serena (2015)                                        2.70            1.0   
Inside Out (2015)                                    4.30            5.0   
Mr. Holmes (2015)                                    3.70            4.5   
'71 (2015)                                           3.60            5.0   
Two Days, One Night (2014)                           3.70            5.0   
Gett: The Trial of Viviane Amsalem (2015)            3.90            5.0   
Kumiko, The Treasure Hunter (2015)                   3.35            4.5   

                                                RT_user_norm_round  \
FILM                                                                 
Avengers: Age of Ultron (2015)                                 4.5   
Cinderella (2015)                                              4.0   
Ant-Man (2015)                                                 4.5   
Do You Believe? (2015)                                         4.0   
Hot Tub Time Machine 2 (2015)                                  1.5   
The Water Diviner (2015)                                       3.0   
Irrational Man (2015)                                          2.5   
Top Five (2014)                                                3.0   
Shaun the Sheep Movie (2015)                                   4.0   
love & Mercy (2015)                                            4.5   
Far From The Madding Crowd (2015)                              4.0   
Black Sea (2015)                                               3.0   
Leviathan (2014)                                               4.0   
Unbroken (2014)                                                3.5   
The Imitation Game (2014)                                      4.5   
Taken 3 (2015)                                                 2.5   
Ted 2 (2015)                                                   3.0   
Southpaw (2015)                                                4.0   
Night at the Museum: Secret of the Tomb (2014)                 3.0   
Pixels (2015)                                                  2.5   
McFarland, USA (2015)                                          4.5   
Insidious: Chapter 3 (2015)                                    3.0   
The Man From U.N.C.L.E. (2015)                                 4.0   
Run All Night (2015)                                           3.0   
Trainwreck (2015)                                              3.5   
Selma (2014)                                                   4.5   
Ex Machina (2015)                                              4.5   
Still Alice (2015)                                             4.5   
Wild Tales (2014)                                              4.5   
The End of the Tour (2015)                                     4.5   
...                                                            ...   
Clouds of Sils Maria (2015)                                    3.5   
Testament of Youth (2015)                                      4.0   
Infinitely Polar Bear (2015)                                   4.0   
Phoenix (2015)                                                 4.0   
The Wolfpack (2015)                                            3.5   
The Stanford Prison Experiment (2015)                          4.5   
Tangerine (2015)                                               4.5   
Magic Mike XXL (2015)                                          3.0   
Home (2015)                                                    3.5   
The Wedding Ringer (2015)                                      3.5   
Woman in Gold (2015)                                           4.0   
The Last Five Years (2015)                                     3.0   
Mission: Impossible – Rogue Nation (2015)                    4.5   
Amy (2015)                                                     4.5   
Jurassic World (2015)                                          4.0   
Minions (2015)                                                 2.5   
Max (2015)                                                     3.5   
Paul Blart: Mall cop 2 (2015)                                  2.0   
The Longest Ride (2015)                                        3.5   
The Lazarus Effect (2015)                                      1.0   
The Woman In Black 2 Angel of Death (2015)                     1.5   
Danny Collins (2015)                                           4.0   
Spare Parts (2015)                                             4.0   
Serena (2015)                                                  1.5   
Inside Out (2015)                                              4.5   
Mr. Holmes (2015)                                              4.0   
'71 (2015)                                                     4.0   
Two Days, One Night (2014)                                     4.0   
Gett: The Trial of Viviane Amsalem (2015)                      4.0   
Kumiko, The Treasure Hunter (2015)                             3.0   

                                                Metacritic_norm_round  \
FILM                                                                    
Avengers: Age of Ultron (2015)                                    3.5   
Cinderella (2015)                                                 3.5   
Ant-Man (2015)                                                    3.0   
Do You Believe? (2015)                                            1.0   
Hot Tub Time Machine 2 (2015)                                     1.5   
The Water Diviner (2015)                                          2.5   
Irrational Man (2015)                                             2.5   
Top Five (2014)                                                   4.0   
Shaun the Sheep Movie (2015)                                      4.0   
love & Mercy (2015)                                               4.0   
Far From The Madding Crowd (2015)                                 3.5   
Black Sea (2015)                                                  3.0   
Leviathan (2014)                                                  4.5   
Unbroken (2014)                                                   3.0   
The Imitation Game (2014)                                         3.5   
Taken 3 (2015)                                                    1.5   
Ted 2 (2015)                                                      2.5   
Southpaw (2015)                                                   3.0   
Night at the Museum: Secret of the Tomb (2014)                    2.5   
Pixels (2015)                                                     1.5   
McFarland, USA (2015)                                             3.0   
Insidious: Chapter 3 (2015)                                       2.5   
The Man From U.N.C.L.E. (2015)                                    3.0   
Run All Night (2015)                                              3.0   
Trainwreck (2015)                                                 4.0   
Selma (2014)                                                      4.5   
Ex Machina (2015)                                                 4.0   
Still Alice (2015)                                                3.5   
Wild Tales (2014)                                                 4.0   
The End of the Tour (2015)                                        4.0   
...                                                               ...   
Clouds of Sils Maria (2015)                                       4.0   
Testament of Youth (2015)                                         4.0   
Infinitely Polar Bear (2015)                                      3.0   
Phoenix (2015)                                                    4.5   
The Wolfpack (2015)                                               4.0   
The Stanford Prison Experiment (2015)                             3.5   
Tangerine (2015)                                                  4.5   
Magic Mike XXL (2015)                                             3.0   
Home (2015)                                                       3.0   
The Wedding Ringer (2015)                                         2.0   
Woman in Gold (2015)                                              2.5   
The Last Five Years (2015)                                        3.0   
Mission: Impossible – Rogue Nation (2015)                       4.0   
Amy (2015)                                                        4.5   
Jurassic World (2015)                                             3.0   
Minions (2015)                                                    3.0   
Max (2015)                                                        2.5   
Paul Blart: Mall cop 2 (2015)                                     0.5   
The Longest Ride (2015)                                           1.5   
The Lazarus Effect (2015)                                         1.5   
The Woman In Black 2 Angel of Death (2015)                        2.0   
Danny Collins (2015)                                              3.0   
Spare Parts (2015)                                                2.5   
Serena (2015)                                                     2.0   
Inside Out (2015)                                                 4.5   
Mr. Holmes (2015)                                                 3.5   
'71 (2015)                                                        4.0   
Two Days, One Night (2014)                                        4.5   
Gett: The Trial of Viviane Amsalem (2015)                         4.5   
Kumiko, The Treasure Hunter (2015)                                3.5   

                                                Metacritic_user_norm_round  \
FILM                                                                         
Avengers: Age of Ultron (2015)                                         3.5   
Cinderella (2015)                                                      4.0   
Ant-Man (2015)                                                         4.0   
Do You Believe? (2015)                                                 2.5   
Hot Tub Time Machine 2 (2015)                                          1.5   
The Water Diviner (2015)                                               3.5   
Irrational Man (2015)                                                  4.0   
Top Five (2014)                                                        3.5   
Shaun the Sheep Movie (2015)                                           4.5   
love & Mercy (2015)                                                    4.5   
Far From The Madding Crowd (2015)                                      4.0   
Black Sea (2015)                                                       3.5   
Leviathan (2014)                                                       3.5   
Unbroken (2014)                                                        3.5   
The Imitation Game (2014)                                              4.0   
Taken 3 (2015)                                                         2.5   
Ted 2 (2015)                                                           3.5   
Southpaw (2015)                                                        4.0   
Night at the Museum: Secret of the Tomb (2014)                         3.0   
Pixels (2015)                                                          2.5   
McFarland, USA (2015)                                                  3.5   
Insidious: Chapter 3 (2015)                                            3.5   
The Man From U.N.C.L.E. (2015)                                         4.0   
Run All Night (2015)                                                   3.5   
Trainwreck (2015)                                                      3.0   
Selma (2014)                                                           3.5   
Ex Machina (2015)                                                      4.0   
Still Alice (2015)                                                     4.0   
Wild Tales (2014)                                                      4.5   
The End of the Tour (2015)                                             4.0   
...                                                                    ...   
Clouds of Sils Maria (2015)                                            3.5   
Testament of Youth (2015)                                              4.0   
Infinitely Polar Bear (2015)                                           4.0   
Phoenix (2015)                                                         4.0   
The Wolfpack (2015)                                                    3.5   
The Stanford Prison Experiment (2015)                                  4.5   
Tangerine (2015)                                                       3.5   
Magic Mike XXL (2015)                                                  2.5   
Home (2015)                                                            3.5   
The Wedding Ringer (2015)                                              1.5   
Woman in Gold (2015)                                                   3.5   
The Last Five Years (2015)                                             3.5   
Mission: Impossible – Rogue Nation (2015)                            4.0   
Amy (2015)                                                             4.5   
Jurassic World (2015)                                                  3.5   
Minions (2015)                                                         3.0   
Max (2015)                                                             3.0   
Paul Blart: Mall cop 2 (2015)                                          1.0   
The Longest Ride (2015)                                                2.5   
The Lazarus Effect (2015)                                              2.5   
The Woman In Black 2 Angel of Death (2015)                             2.0   
Danny Collins (2015)                                                   3.5   
Spare Parts (2015)                                                     3.5   
Serena (2015)                                                          2.5   
Inside Out (2015)                                                      4.5   
Mr. Holmes (2015)                                                      4.0   
'71 (2015)                                                             4.0   
Two Days, One Night (2014)                                             4.5   
Gett: The Trial of Viviane Amsalem (2015)                              3.5   
Kumiko, The Treasure Hunter (2015)                                     3.0   

                                                IMDB_norm_round  \
FILM                                                              
Avengers: Age of Ultron (2015)                              4.0   
Cinderella (2015)                                           3.5   
Ant-Man (2015)                                              4.0   
Do You Believe? (2015)                                      2.5   
Hot Tub Time Machine 2 (2015)                               2.5   
The Water Diviner (2015)                                    3.5   
Irrational Man (2015)                                       3.5   
Top Five (2014)                                             3.5   
Shaun the Sheep Movie (2015)                                3.5   
love & Mercy (2015)                                         4.0   
Far From The Madding Crowd (2015)                           3.5   
Black Sea (2015)                                            3.0   
Leviathan (2014)                                            4.0   
Unbroken (2014)                                             3.5   
The Imitation Game (2014)                                   4.0   
Taken 3 (2015)                                              3.0   
Ted 2 (2015)                                                3.5   
Southpaw (2015)                                             4.0   
Night at the Museum: Secret of the Tomb (2014)              3.0   
Pixels (2015)                                               3.0   
McFarland, USA (2015)                                       4.0   
Insidious: Chapter 3 (2015)                                 3.0   
The Man From U.N.C.L.E. (2015)                              4.0   
Run All Night (2015)                                        3.5   
Trainwreck (2015)                                           3.5   
Selma (2014)                                                4.0   
Ex Machina (2015)                                           4.0   
Still Alice (2015)                                          4.0   
Wild Tales (2014)                                           4.0   
The End of the Tour (2015)                                  4.0   
...                                                         ...   
Clouds of Sils Maria (2015)                                 3.5   
Testament of Youth (2015)                                   3.5   
Infinitely Polar Bear (2015)                                3.5   
Phoenix (2015)                                              3.5   
The Wolfpack (2015)                                         3.5   
The Stanford Prison Experiment (2015)                       3.5   
Tangerine (2015)                                            3.5   
Magic Mike XXL (2015)                                       3.0   
Home (2015)                                                 3.5   
The Wedding Ringer (2015)                                   3.5   
Woman in Gold (2015)                                        3.5   
The Last Five Years (2015)                                  3.0   
Mission: Impossible – Rogue Nation (2015)                 4.0   
Amy (2015)                                                  4.0   
Jurassic World (2015)                                       3.5   
Minions (2015)                                              3.5   
Max (2015)                                                  3.5   
Paul Blart: Mall cop 2 (2015)                               2.0   
The Longest Ride (2015)                                     3.5   
The Lazarus Effect (2015)                                   2.5   
The Woman In Black 2 Angel of Death (2015)                  2.5   
Danny Collins (2015)                                        3.5   
Spare Parts (2015)                                          3.5   
Serena (2015)                                               2.5   
Inside Out (2015)                                           4.5   
Mr. Holmes (2015)                                           3.5   
'71 (2015)                                                  3.5   
Two Days, One Night (2014)                                  3.5   
Gett: The Trial of Viviane Amsalem (2015)                   4.0   
Kumiko, The Treasure Hunter (2015)                          3.5   

                                                Fandango_Difference  
FILM                                                                 
Avengers: Age of Ultron (2015)                                  0.5  
Cinderella (2015)                                               0.5  
Ant-Man (2015)                                                  0.5  
Do You Believe? (2015)                                          0.5  
Hot Tub Time Machine 2 (2015)                                   0.5  
The Water Diviner (2015)                                        0.5  
Irrational Man (2015)                                           0.5  
Top Five (2014)                                                 0.5  
Shaun the Sheep Movie (2015)                                    0.5  
love & Mercy (2015)                                             0.5  
Far From The Madding Crowd (2015)                               0.5  
Black Sea (2015)                                                0.5  
Leviathan (2014)                                                0.5  
Unbroken (2014)                                                 0.4  
The Imitation Game (2014)                                       0.4  
Taken 3 (2015)                                                  0.4  
Ted 2 (2015)                                                    0.4  
Southpaw (2015)                                                 0.4  
Night at the Museum: Secret of the Tomb (2014)                  0.4  
Pixels (2015)                                                   0.4  
McFarland, USA (2015)                                           0.4  
Insidious: Chapter 3 (2015)                                     0.4  
The Man From U.N.C.L.E. (2015)                                  0.4  
Run All Night (2015)                                            0.4  
Trainwreck (2015)                                               0.4  
Selma (2014)                                                    0.4  
Ex Machina (2015)                                               0.4  
Still Alice (2015)                                              0.4  
Wild Tales (2014)                                               0.4  
The End of the Tour (2015)                                      0.4  
...                                                             ...  
Clouds of Sils Maria (2015)                                     0.1  
Testament of Youth (2015)                                       0.1  
Infinitely Polar Bear (2015)                                    0.1  
Phoenix (2015)                                                  0.1  
The Wolfpack (2015)                                             0.1  
The Stanford Prison Experiment (2015)                           0.1  
Tangerine (2015)                                                0.1  
Magic Mike XXL (2015)                                           0.1  
Home (2015)                                                     0.1  
The Wedding Ringer (2015)                                       0.1  
Woman in Gold (2015)                                            0.1  
The Last Five Years (2015)                                      0.1  
Mission: Impossible – Rogue Nation (2015)                     0.1  
Amy (2015)                                                      0.1  
Jurassic World (2015)                                           0.0  
Minions (2015)                                                  0.0  
Max (2015)                                                      0.0  
Paul Blart: Mall cop 2 (2015)                                   0.0  
The Longest Ride (2015)                                         0.0  
The Lazarus Effect (2015)                                       0.0  
The Woman In Black 2 Angel of Death (2015)                      0.0  
Danny Collins (2015)                                            0.0  
Spare Parts (2015)                                              0.0  
Serena (2015)                                                   0.0  
Inside Out (2015)                                               0.0  
Mr. Holmes (2015)                                               0.0  
'71 (2015)                                                      0.0  
Two Days, One Night (2014)                                      0.0  
Gett: The Trial of Viviane Amsalem (2015)                       0.0  
Kumiko, The Treasure Hunter (2015)                              0.0  

[146 rows x 15 columns]
rt_mt_user = float_df[['RT_user_norm', 'Metacritic_user_nom']]
rt_mt_user.apply(lambda x: np.std(x), axis=1)
print(rt_mt_user)
                                                RT_user_norm  \
FILM                                                           
Avengers: Age of Ultron (2015)                          4.30   
Cinderella (2015)                                       4.00   
Ant-Man (2015)                                          4.50   
Do You Believe? (2015)                                  4.20   
Hot Tub Time Machine 2 (2015)                           1.40   
The Water Diviner (2015)                                3.10   
Irrational Man (2015)                                   2.65   
Top Five (2014)                                         3.20   
Shaun the Sheep Movie (2015)                            4.10   
love & Mercy (2015)                                     4.35   
Far From The Madding Crowd (2015)                       3.85   
Black Sea (2015)                                        3.00   
Leviathan (2014)                                        3.95   
Unbroken (2014)                                         3.50   
The Imitation Game (2014)                               4.60   
Taken 3 (2015)                                          2.30   
Ted 2 (2015)                                            2.90   
Southpaw (2015)                                         4.00   
Night at the Museum: Secret of the Tomb (2014)          2.90   
Pixels (2015)                                           2.70   
McFarland, USA (2015)                                   4.45   
Insidious: Chapter 3 (2015)                             2.80   
The Man From U.N.C.L.E. (2015)                          4.00   
Run All Night (2015)                                    2.95   
Trainwreck (2015)                                       3.70   
Selma (2014)                                            4.30   
Ex Machina (2015)                                       4.30   
Still Alice (2015)                                      4.25   
Wild Tales (2014)                                       4.60   
The End of the Tour (2015)                              4.45   
...                                                      ...   
Clouds of Sils Maria (2015)                             3.35   
Testament of Youth (2015)                               3.95   
Infinitely Polar Bear (2015)                            3.80   
Phoenix (2015)                                          4.05   
The Wolfpack (2015)                                     3.65   
The Stanford Prison Experiment (2015)                   4.35   
Tangerine (2015)                                        4.30   
Magic Mike XXL (2015)                                   3.20   
Home (2015)                                             3.25   
The Wedding Ringer (2015)                               3.30   
Woman in Gold (2015)                                    4.05   
The Last Five Years (2015)                              3.00   
Mission: Impossible – Rogue Nation (2015)             4.50   
Amy (2015)                                              4.55   
Jurassic World (2015)                                   4.05   
Minions (2015)                                          2.60   
Max (2015)                                              3.65   
Paul Blart: Mall cop 2 (2015)                           1.80   
The Longest Ride (2015)                                 3.65   
The Lazarus Effect (2015)                               1.15   
The Woman In Black 2 Angel of Death (2015)              1.25   
Danny Collins (2015)                                    3.75   
Spare Parts (2015)                                      4.15   
Serena (2015)                                           1.25   
Inside Out (2015)                                       4.50   
Mr. Holmes (2015)                                       3.90   
'71 (2015)                                              4.10   
Two Days, One Night (2014)                              3.90   
Gett: The Trial of Viviane Amsalem (2015)               4.05   
Kumiko, The Treasure Hunter (2015)                      3.15   

                                                Metacritic_user_nom  
FILM                                                                 
Avengers: Age of Ultron (2015)                                 3.55  
Cinderella (2015)                                              3.75  
Ant-Man (2015)                                                 4.05  
Do You Believe? (2015)                                         2.35  
Hot Tub Time Machine 2 (2015)                                  1.70  
The Water Diviner (2015)                                       3.40  
Irrational Man (2015)                                          3.80  
Top Five (2014)                                                3.40  
Shaun the Sheep Movie (2015)                                   4.40  
love & Mercy (2015)                                            4.25  
Far From The Madding Crowd (2015)                              3.75  
Black Sea (2015)                                               3.30  
Leviathan (2014)                                               3.60  
Unbroken (2014)                                                3.25  
The Imitation Game (2014)                                      4.10  
Taken 3 (2015)                                                 2.30  
Ted 2 (2015)                                                   3.25  
Southpaw (2015)                                                4.10  
Night at the Museum: Secret of the Tomb (2014)                 2.90  
Pixels (2015)                                                  2.65  
McFarland, USA (2015)                                          3.60  
Insidious: Chapter 3 (2015)                                    3.45  
The Man From U.N.C.L.E. (2015)                                 3.95  
Run All Night (2015)                                           3.65  
Trainwreck (2015)                                              3.00  
Selma (2014)                                                   3.55  
Ex Machina (2015)                                              3.95  
Still Alice (2015)                                             3.90  
Wild Tales (2014)                                              4.40  
The End of the Tour (2015)                                     3.75  
...                                                             ...  
Clouds of Sils Maria (2015)                                    3.55  
Testament of Youth (2015)                                      3.95  
Infinitely Polar Bear (2015)                                   3.95  
Phoenix (2015)                                                 4.00  
The Wolfpack (2015)                                            3.50  
The Stanford Prison Experiment (2015)                          4.25  
Tangerine (2015)                                               3.65  
Magic Mike XXL (2015)                                          2.70  
Home (2015)                                                    3.65  
The Wedding Ringer (2015)                                      1.65  
Woman in Gold (2015)                                           3.60  
The Last Five Years (2015)                                     3.45  
Mission: Impossible – Rogue Nation (2015)                    4.00  
Amy (2015)                                                     4.40  
Jurassic World (2015)                                          3.50  
Minions (2015)                                                 2.85  
Max (2015)                                                     2.95  
Paul Blart: Mall cop 2 (2015)                                  1.20  
The Longest Ride (2015)                                        2.40  
The Lazarus Effect (2015)                                      2.45  
The Woman In Black 2 Angel of Death (2015)                     2.20  
Danny Collins (2015)                                           3.55  
Spare Parts (2015)                                             3.55  
Serena (2015)                                                  2.65  
Inside Out (2015)                                              4.45  
Mr. Holmes (2015)                                              3.95  
'71 (2015)                                                     3.75  
Two Days, One Night (2014)                                     4.40  
Gett: The Trial of Viviane Amsalem (2015)                      3.65  
Kumiko, The Treasure Hunter (2015)                             3.20  

[146 rows x 2 columns]

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐