import pandas as pd
from pandas import Series
import numpy as np
fandango = pd.read_csv('fandango_score_comparison.csv')
series_film = fandango['FILM']
# print(series_film[0:5])
series_rt = fandango['RottenTomatoes']
# print(series_rt[0:5])
film_names = series_film.values
# print(type(film_names))
# print(film_names)
rt_scores = series_rt.values
# print(rt_scores)
series_custom = Series(rt_scores , index=film_names)
# print(series_custom[['Minions (2015)', 'Leviathan (2014)']])
fiveten = series_custom[5:10]
# print(fiveten)
# ------------------------按索引进行排序----------------------
original_index = series_custom.index.tolist()
print(original_index)
sorted_index = sorted(original_index)
sorted_by_index = series_custom.reindex(sorted_index)
print(sorted_by_index)
# ------------------------按索引进行排序----------------------
sc2 = series_custom.sort_index()
print(sc2[0:10])
# ------------------------按值进行排序----------------------
sc3 = series_custom.sort_values()
print(sc3[0:10])
# ------------------------常用的数值计算---------------------------
np.add(series_custom, series_custom)
np.sin(series_custom)
np.max(series_custom)
# --------------------把大于50的值赋给series_greater_than_50----------------------
series_greater_than_50 = series_custom[series_custom > 50]
# --------------------把大于50且小于75的值赋给both_criteria----------------------
criteria_one = series_custom > 50
criteria_two = series_custom < 75
both_criteria = series_custom[criteria_one & criteria_two]
print(both_criteria)
rt_critics = Series(fandango['RottenTomatoes'].values, index=fandango['FILM'])
rt_users = Series(fandango['RottenTomatoes_User'].values, index=fandango['FILM'])
rt_mean = (rt_critics + rt_users)/2
网友评论