六、pandasモジュール:(21)Series構造
5175 ワード
import pandas as pd
import numpy as np
from pandas import Series
df = pd.read_csv("fandango_score_comparison.csv")
series_film = df["FILM"]# Series
series_film[0:5]
series_rt = df["RottenTomatoes"]
#***********************************************
film_names = series_film.values# series
rt_scores = series_rt.values
# Series
series_custom = Series(rt_scores,index = film_names)#
series_custom[5:10]
#Series
scores_index=sorted(series_custom.index)# sorted(series_custom.index.tolist()), index , index , index index+values
scores_by_index = series_custom.reindex(scores_index)# index , index
# index ,
scores_index2 = series_custom.sort_index()# index
scores_values= series_custom.sort_values()# values , ( )
# 2 ( index ,Series , index ,
# ,
values_add = np.add(series_custom,series_custom)# 2 **
#index alignment,index , values
rt_critics = Series(df["RottenTomatoes"].values,index = df["FILM"])
rt_users = Series(df["RottenTomatoes_User"].values,index = df["FILM"])
rt_mean = (rt_critics+rt_users)/2