4/5/25, 11:16 PM pandas - Colab
import pandas as pd
data=pd.Series([12,20,30,40,50,60,70])
data=pd.Series([12,20,30,40,50,60,70], index=('a','b','c','d','e','f','g'))
data.values
array([12, 20, 30, 40, 50, 60, 70])
data.index
Index(['a', 'b', 'c', 'd', 'e', 'f', 'g'], dtype='object')
data_Series={
'Cloumn1':pd.Series(data=[100,200,300,400,500,600,700],dtype='int16'),
'Cloumn2':pd.Series(data=[10,20,30,40,50,60,70],dtype='int16')
pd.DataFrame(data_Series)
Cloumn1 Cloumn2
0 100 10
1 200 20
2 300 30
3 400 40
4 500 50
5 600 60
6 700 70
data={
'Day':pd.Series(data=['D1','D2','D3','D4','D5','D6','D7','D8','D9','D10','D11','D12','D13','D14']),
'Outlook':pd.Series(data=['Sunny','Sunny','Overcast','Rain','Rain','Rain','Overcast','Sunny','Sunny','Rain','Sunny','Overcast','Overcas
'Temperature':pd.Series(data=['Hot','Hot','Hot','mild','cool','cool','cool','mild','cool','mild','mild','mild','Hot','mild']),
'Humidity':pd.Series(data=['high','high','high','high','normal','normal','normal','high','normal','normal','normal','high','normal','hig
'wind':pd.Series(data=['weak','strong','weak','weak','weak','strong','strong','weak','weak','weak','strong','strong','weak','strong']),
'play tennis':pd.Series(data=['no','no','yes','yes','yes','no','yes','no','yes','yes','yes','yes','yes','no'])}
pd.DataFrame(data)
https://colab.research.google.com/drive/1nlTM-iwOFyzFMn8yY4olBw_bueZSx8bi#scrollTo=F02e0wqP59CS&printMode=true 1/7
4/5/25, 11:16 PM pandas - Colab
Day Outlook Temperature Humidity wind play tennis
0 D1 Sunny Hot high weak no
1 D2 Sunny Hot high strong no
2 D3 Overcast Hot high weak yes
3 D4 Rain mild high weak yes
4 D5 Rain cool normal weak yes
5 D6 Rain cool normal strong no
6 D7 Overcast cool normal strong yes
7 D8 Sunny mild high weak no
8 D9 Sunny cool normal weak yes
9 D10 Rain mild normal weak yes
10 D11 Sunny mild normal strong yes
11 D12 Overcast mild high strong yes
12 D13 Overcast Hot normal weak yes
13 D14 Rain mild high strong no
movies_df=pd.read_csv("https://raw.githubusercontent.com/ammishra08/MachineLearning/master/Datasets/movies.csv",sep=',')
display(movies_df)
Audience score Rotten Tomatoes Worldwide
Film Genre Lead Studio Profitability Year
% % Gross
The Weinstein
0 Zack and Miri Make a Porno Romance 70 1.747542 64 $41.94 2008
Company
The Weinstein
1 Youth in Revolt Comedy 52 1.090000 68 $19.62 2010
Company
You Will Meet a Tall Dark
2 Comedy Independent 35 1.211818 43 $26.66 2010
Stranger
3 When in Rome Comedy Disney 44 0.000000 15 $43.04 2010
4 What Happens in Vegas Comedy Fox 72 6.267647 28 $219.37 2008
... ... ... ... ... ... ... ... ...
72 Across the Universe romance Independent 84 0.652603 54 $29.37 2007
73 A Serious Man Drama Universal 64 4.382857 89 $30.68 2009
74 A Dangerous Method Drama Independent 89 0.448645 79 $8.97 2011
75 27 Dresses Comedy Fox 71 5 343622 40 $160 31 2008
movies_df.head()
Audience score Rotten Tomatoes Worldwide
Film Genre Lead Studio Profitability Year
% % Gross
The Weinstein
0 Zack and Miri Make a Porno Romance 70 1.747542 64 $41.94 2008
Company
The Weinstein
1 Youth in Revolt Comedy 52 1.090000 68 $19.62 2010
Company
You Will Meet a Tall Dark
2 Comedy Independent 35 1.211818 43 $26.66 2010
Stranger
movies_df.tail()
https://colab.research.google.com/drive/1nlTM-iwOFyzFMn8yY4olBw_bueZSx8bi#scrollTo=F02e0wqP59CS&printMode=true 2/7
4/5/25, 11:16 PM pandas - Colab
Film Genre Lead Studio Audience score % Profitability Rotten Tomatoes % Worldwide Gross Year
72 Across the Universe romance Independent 84 0.652603 54 $29.37 2007
73 A Serious Man Drama Universal 64 4.382857 89 $30.68 2009
74 A Dangerous Method Drama Independent 89 0.448645 79 $8.97 2011
75 27 Dresses Comedy Fox 71 5.343622 40 $160.31 2008
76 (500) Days of Summer comedy Fox 81 8.096000 87 $60.72 2009
movies_df.shape
(77, 8)
movies_df.columns
Index(['Film', 'Genre', 'Lead Studio', 'Audience score %', 'Profitability',
'Rotten Tomatoes %', 'Worldwide Gross', 'Year'],
dtype='object')
len(movies_df.columns)
print(movies_df.shape[0])
77
print(movies_df.shape[1])
movies_df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 77 entries, 0 to 76
Data columns (total 8 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 Film 77 non-null object
1 Genre 77 non-null object
2 Lead Studio 77 non-null object
3 Audience score % 77 non-null int64
4 Profitability 77 non-null float64
5 Rotten Tomatoes % 77 non-null int64
6 Worldwide Gross 77 non-null object
7 Year 77 non-null int64
dtypes: float64(1), int64(3), object(4)
memory usage: 4.9+ KB
movies_df['Profitability'].sort_values()
https://colab.research.google.com/drive/1nlTM-iwOFyzFMn8yY4olBw_bueZSx8bi#scrollTo=F02e0wqP59CS&printMode=true 3/7
4/5/25, 11:16 PM pandas - Colab
Profitability
3 0.000000
33 0.000000
57 0.000000
8 0.005000
42 0.252895
... ...
12 10.180027
7 11.089742
14 14.196400
60 22.913136
68 66.934000
77 rows × 1 columns
dtype: float64
movies_df['Profitability'].sort_values(ascending=False)
Profitability
68 66.934000
60 22.913136
14 14.196400
7 11.089742
12 10.180027
... ...
42 0.252895
8 0.005000
3 0.000000
33 0.000000
57 0.000000
77 rows × 1 columns
dtype: float64
movies_df.sort_values(by='Audience score %',ascending=False)
https://colab.research.google.com/drive/1nlTM-iwOFyzFMn8yY4olBw_bueZSx8bi#scrollTo=F02e0wqP59CS&printMode=true 4/7
4/5/25, 11:16 PM pandas - Colab
Audience score Rotten Tomatoes Worldwide
Film Genre Lead Studio Profitability Year
% % Gross
6 WALL-E Animation Disney 89 2.896019 96 $521.28 2008
74 A Dangerous Method Drama Independent 89 0.448645 79 $8.97 2011
22 Tangled Animation Disney 88 1.365692 89 $355.01 2010
43 Midnight in Paris Romence Sony 84 8.744706 93 $148.66 2011
The Weinstein
39 My Week with Marilyn Drama 84 0.825800 83 $8.26 2011
Company
... ... ... ... ... ... ... ... ...
55 Killers Action Lionsgate 45 1.245333 11 $93.40 2010
3 When in Rome Comedy Disney 44 0.000000 15 $43.04 2010
18 The Heartbreak Kid Comedy Paramount 41 2.129444 30 $127.77 2007
48 Love Happens Drama Universal 40 2.004444 18 $36.08 2009
You Will Meet a Tall Dark
movies_df.iloc[10:25, :]
Film Genre Lead Studio Audience score % Profitability Rotten Tomatoes % Worldwide Gross Year
10 Tyler Perry's Why Did I get Married Romance Independent 47 3.724192 46 $55.86 2007
11 Twilight: Breaking Dawn Romance Independent 68 6.383364 26 $702.17 2011
12 Twilight Romance Summit 82 10.180027 49 $376.66 2008
13 The Ugly Truth Comedy Independent 68 5.402632 14 $205.30 2009
14 The Twilight Saga: New Moon Drama Summit 78 14.196400 27 $709.82 2009
15 The Time Traveler's Wife Drama Paramount 65 2.598205 38 $101.33 2009
16 The Proposal Comedy Disney 74 7.867500 43 $314.70 2009
17 The Invention of Lying Comedy Warner Bros. 47 1.751351 56 $32.40 2009
18 The Heartbreak Kid Comedy Paramount 41 2.129444 30 $127.77 2007
19 The Duchess Drama Paramount 68 3.207850 60 $43.31 2008
20 The Curious Case of Benjamin Button Fantasy Warner Bros. 81 1.783944 73 $285.43 2008
21 The Back-up Plan Comedy CBS 47 2.202571 20 $77.09 2010
22 Tangled Animation Disney 88 1.365692 89 $355.01 2010
23 Something Borrowed Romance Independent 48 1.719514 15 $60.18 2011
24 She's Out of My League Comedy Paramount 60 2.440500 57 $48.81 2010
movies_df.iloc[10:25, 2:7]
https://colab.research.google.com/drive/1nlTM-iwOFyzFMn8yY4olBw_bueZSx8bi#scrollTo=F02e0wqP59CS&printMode=true 5/7
4/5/25, 11:16 PM pandas - Colab
Lead Studio Audience score % Profitability Rotten Tomatoes % Worldwide Gross
10 Independent 47 3.724192 46 $55.86
11 Independent 68 6.383364 26 $702.17
12 Summit 82 10.180027 49 $376.66
13 Independent 68 5.402632 14 $205.30
14 Summit 78 14.196400 27 $709.82
15 Paramount 65 2.598205 38 $101.33
16 Disney 74 7.867500 43 $314.70
17 Warner Bros. 47 1.751351 56 $32.40
18 Paramount 41 2.129444 30 $127.77
19 Paramount 68 3.207850 60 $43.31
20 Warner Bros. 81 1.783944 73 $285.43
21 CBS 47 2.202571 20 $77.09
22 Disney 88 1.365692 89 $355.01
23 Independent 48 1.719514 15 $60.18
24 Paramount 60 2.440500 57 $48.81
movies_df.iloc[10:25, -1]
Year
10 2007
11 2011
12 2008
13 2009
14 2009
15 2009
16 2009
17 2009
18 2007
19 2008
20 2008
21 2010
22 2010
23 2011
24 2010
dtype: int64
movies_df.iloc[10:25, -2:]
https://colab.research.google.com/drive/1nlTM-iwOFyzFMn8yY4olBw_bueZSx8bi#scrollTo=F02e0wqP59CS&printMode=true 6/7
4/5/25, 11:16 PM pandas - Colab
Worldwide Gross Year
10 $55.86 2007
11 $702.17 2011
12 $376.66 2008
13 $205.30 2009
14 $709.82 2009
15 $101.33 2009
16 $314.70 2009
movies_df.iloc[10:30:2, 0:8:2]
17 $32.40 2009
18 $127.77 2007 Film Lead Studio Profitability Worldwide Gross
10
19 Tyler Perry's Why 2008
$43.31 Did I get Married Independent 3.724192 $55.86
12
20 $285.43 2008 Twilight Summit 10.180027 $376.66
14
21 The$77.09
Twilight Saga:
2010 New Moon Summit 14.196400 $709.82
16
22 $355.01 The Proposal
2010 Disney 7.867500 $314.70
18
23 $60.18The Heartbreak Kid
2011 Paramount 2.129444 $127.77
20
24 The Curious$48.81
Case of 2010
Benjamin Button Warner Bros. 1.783944 $285.43
22 Tangled Disney 1.365692 $355.01
24 She's Out of My League Paramount 2.440500 $48.81
26 Sex and the City 2 Warner Bros. 2.883500 $288.35
28 Remember Me Summit 3.491250 $55.86
movies_new=movies_df.set_index("Film")
https://colab.research.google.com/drive/1nlTM-iwOFyzFMn8yY4olBw_bueZSx8bi#scrollTo=F02e0wqP59CS&printMode=true 7/7