4. pandas学习笔记Series

版权声明:转载注明出处 https://blog.csdn.net/deephacking/article/details/82731642
import pandas as pd
from pandas import Series

data = pd.read_csv("fandango_score_comparison.csv")
# 定位某一列
series_film = data["FILM"]
print(series_film[0:10])
# 列类型为Series
print(type(series_film))
# 定位某一行
data_row = data.loc[0]
print(data_row)
# 行类型为Series
print(type(data_row))
# 取电影名字,结果为ndarray
film_name = series_film.values
print(film_name)
# 取IMDB分数
IMDB_scores = data["IMDB"]
new_score = IMDB_scores.values
print(new_score)
# 自定义Series
custom_series = Series(new_score,index=film_name)
print(custom_series["The Wolfpack (2015)"])
print(custom_series[["Kumiko, The Treasure Hunter (2015)", "Gett: The Trial of Viviane Amsalem (2015)"]])

猜你喜欢

转载自blog.csdn.net/deephacking/article/details/82731642