核心数据结构Series 原

leonhu

``````import pandas as pd
series_film = fandango['FILM']
print(series_film[:5])
series_rt = fandango['RottenTomatoes']
print(series_rt[:5])
``````
``````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
``````
``````from pandas import Series
film_names = series_film.values
rt_scores = series_rt.values

series_custom = Series(rt_scores, index=film_names)
# print(series_custom)

series_custom[['Minions (2015)', 'Leviathan (2014)']]

``````
``````The Water Diviner (2015)        63
Irrational Man (2015)           42
Top Five (2014)                 86
Shaun the Sheep Movie (2015)    99
Love & Mercy (2015)             89
dtype: int64
``````
``````# int index is also avilable
fiveten = series_custom[5:10]
print(fiveten)
``````
``````The Water Diviner (2015)        63
Irrational Man (2015)           42
Top Five (2014)                 86
Shaun the Sheep Movie (2015)    99
Love & Mercy (2015)             89
dtype: int64
``````
``````sc2 = series_custom.sort_index()
print(sc2[:10])

sc3 = series_custom.sort_values()
print(sc3[:10])
``````
``````'71 (2015)                    97
5 Flights Up (2015)           52
A Little Chaos (2015)         40
A Most Violent Year (2014)    90
Aloha (2015)                  19
American Sniper (2015)        72
American Ultra (2015)         46
Amy (2015)                    97
Annie (2014)                  27
dtype: int64
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
Mortdecai (2015)                 12
Seventh Son (2015)               12
dtype: int64
``````
``````# The values in a Series object are treated as an ndarray,
# the core data in NumPy
import numpy as np
# Return the highest value (will return a single vlaue not a Series)
print(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
dtype: int64

100
``````
``````# print(series_custom > 50)
series_greater_than_50 = series_custom[series_custom > 50]
# print( series_greater_than_50[:10])

criteria_one = series_custom > 50
criteria_two = series_custom < 75
both_criteria = series_custom[criteria_one & criteria_two]
print(len(both_criteria))
``````
``````33
``````
``````# data alignment same index
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
print(rt_mean[:10])
``````
``````FILM
Avengers: Age of Ultron (2015)    80.0
Cinderella (2015)                 82.5
Ant-Man (2015)                    85.0
Do You Believe? (2015)            51.0
Hot Tub Time Machine 2 (2015)     21.0
The Water Diviner (2015)          62.5
Irrational Man (2015)             47.5
Top Five (2014)                   75.0
Shaun the Sheep Movie (2015)      90.5
Love & Mercy (2015)               88.0
dtype: float64
``````
``````
``````

leonhu

gyhmolo
03/02
0
0
Python数据处理库pandas入门教程

pandas是一个Python语言的软件包，在我们使用Python语言进行机器学习编程的时候，这是一个非常常用的基础编程库。本文是对它的一个入门教程。 pandas提供了快速，灵活和富有表现力的数据结构...

paulquei
2018/05/24
0
0

pandas Pandas是基于Numpy开发出的,专门用于数据分析的开源Python库 Pandas的两大核心数据结构 Series(一维数据) Series 创建Series的方法 允许索引重复 DataFrame(多特征数据,既有行索引,又...

2018/01/01
0
0
Highmaps网页图表教程之图表配置项结构与商业授权

Highmaps网页图表教程之图表配置项结构与商业授权 Highmaps图表配置项结构 Highmaps最核心的部分就是图表配置项。用户通过图表配置项来对标题进行定制，从而实现自己所要的效果。所以，掌握图...

2015/08/17
197
0
Python 数据分析包：pandas 基础

pandas 是基于 Numpy 构建的含有更高级数据结构和工具的数据分析包 类似于 Numpy 的核心是 ndarray，pandas 也是围绕着 Series 和 DataFrame 两个核心数据结构展开的 。Series 和 DataFrame ...

lionets
2014/06/10
60.4K
5

mskk
18分钟前
3
0

import java.io.IOException;import javax.websocket.OnClose;import javax.websocket.OnError;import javax.websocket.OnMessage;import javax.websocket.OnOpen;import java......

jingshishengxu
28分钟前
2
0
shell介绍，命令历史，命令补全和别名，通配符，输入输出重定向，管道符和作业控制

shell介绍 可以使用 yum list |grep zsh 或者 yum list |grep ksh 这样可以搜索 zsh 和 ksh ，有需要的话可以安装 总之，默认使用的就是 .bash shell 命令历史 输入过的命令会被保存在一个文...

doomcat
45分钟前
7
0
1995年的资深工程师，和你谈谈如何进阶

1995年的资深工程师，和你谈谈如何进阶 自我介绍 网络ID：杭城小刘，城市：顾名思义，人在杭州。1995年出生，本科毕业，现在是一名 iOS 资深工程师，年薪 35w。兴趣爱好广泛：乒乓球、美食、...

10
0
Kafka 面试题

1.Kafka中的ISR、AR代表什么？ ISR：与leader保持同步的follower集合 AR：分区的所有副本 2.Kafka中的HW、LEO分别代表什么？ LEO：每个副本的最后条消息的offset HW：一个分区中所有副本最小...

GrayWorld

5
0