机器学习_第三季_Series

这一节没讲啥技术知识, 我就简单的罗列一下, 与numpy相似

1. 导入csv文件

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])

2. 将文件做成Series格式

from pandas import Series

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)
series_custom[['Minions (2015)', 'Leviathan (2014)']]
fiveten = series_custom[5: 10]
print(fiveten)

3. 取得数据进行排序

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)

4. 对值进行排序

sc2 = series_custom.sort_index()
sc3 = series_custom.sort_values()
# print(sc2)
print(sc3)

你可能感兴趣的:(机器学习_第三季_Series)