Pandas: Access those movies,released after 1995-01-01
11. Movies Released After 1995-01-01
Write a Pandas program to access those movies,released after 1995-01-01.
Sample Solution:
Python Code :
import pandas as pd
df = pd.read_csv('movies_metadata.csv')
# Create a smaller dataframe
small_df = df[['title', 'release_date', 'budget', 'revenue', 'runtime']]
result = small_df[small_df['release_date'] > '1995-01-01']
print("DataFrame based on release date>'1995-01-01'.")
print(result)
Sample Output:
DataFrame based on release date>'1995-01-01'.
title release_date budget revenue runtime
0 Toy Story 1995-10-30 30000000 373554033 81.0
1 Jumanji 1995-12-15 65000000 262797249 104.0
2 Grumpier Old Men 1995-12-22 0 0 101.0
3 Waiting to Exhale 1995-12-22 16000000 81452156 127.0
4 Father of the Bride Part II 1995-02-10 0 76578911 106.0
5 Heat 1995-12-15 60000000 187436818 170.0
6 Sabrina 1995-12-15 58000000 0 127.0
7 Tom and Huck 1995-12-22 0 0 97.0
8 Sudden Death 1995-12-22 35000000 64350171 106.0
9 GoldenEye 1995-11-16 58000000 352194034 130.0
10 The American President 1995-11-17 62000000 107879496 106.0
11 Dracula: Dead and Loving It 1995-12-22 0 0 88.0
12 Balto 1995-12-22 0 11348324 78.0
13 Nixon 1995-12-22 44000000 13681765 192.0
14 Cutthroat Island 1995-12-22 98000000 10017322 119.0
15 Casino 1995-11-22 52000000 116112375 178.0
16 Sense and Sensibility 1995-12-13 16500000 135000000 136.0
17 Four Rooms 1995-12-09 4000000 4300000 98.0
18 Ace Ventura: When Nature Calls 1995-11-10 30000000 212385533 90.0
19 Money Train 1995-11-21 60000000 35431113 103.0
20 Get Shorty 1995-10-20 30250000 115101622 105.0
21 Copycat 1995-10-27 0 0 124.0
22 Assassins 1995-10-06 50000000 30303072 132.0
23 Powder 1995-10-27 0 0 111.0
24 Leaving Las Vegas 1995-10-27 3600000 49800000 112.0
25 Othello 1995-12-15 0 0 123.0
26 Now and Then 1995-10-20 12000000 27400000 100.0
27 Persuasion 1995-09-27 0 0 104.0
28 The City of Lost Children 1995-05-16 18000000 1738611 108.0
29 Shanghai Triad 1995-04-30 0 0 108.0
30 Dangerous Minds 1995-08-11 0 180000000 99.0
31 Twelve Monkeys 1995-12-29 29500000 168840000 129.0
32 Wings of Courage 1996-09-18 0 0 50.0
33 Babe 1995-07-18 30000000 254134910 89.0
34 Carrington 1995-11-08 0 0 121.0
35 Dead Man Walking 1995-12-29 11000000 39363635 122.0
36 Across the Sea of Time 1995-10-20 0 0 51.0
37 It Takes Two 1995-11-17 0 0 101.0
38 Clueless 1995-07-19 12000000 0 97.0
39 Cry, the Beloved Country 1995-12-15 0 676525 106.0
40 Richard III 1995-12-29 0 0 104.0
41 Dead Presidents 1995-10-06 10000000 0 119.0
42 Restoration 1995-12-29 19000000 0 117.0
43 Mortal Kombat 1995-08-18 18000000 122195920 101.0
44 To Die For 1995-05-20 20000000 21284514 106.0
45 How To Make An American Quilt 1995-10-06 10000000 23574130 116.0
46 Se7en 1995-09-22 33000000 327311859 127.0
47 Pocahontas 1995-06-14 55000000 346079773 81.0
48 When Night Is Falling 1995-05-05 0 0 96.0
49 The Usual Suspects 1995-07-19 6000000 23341568 106.0
For more Practice: Solve these Related Problems:
- Write a Pandas program to filter movies_metadata.csv for movies released after January 1, 1995.
- Write a Pandas program to convert the release_date column to datetime and then display movies released after 1995-01-01.
- Write a Pandas program to extract movies from movies_metadata.csv released after 1995 and show their title and release_date.
- Write a Pandas program to filter movies_metadata.csv for movies post-1995 and count how many records meet this criterion.
Go to:
PREV : Sort by Release Date.
NEXT : Sort by Runtime Descending.
Python-Pandas Code Editor:
Sample Table:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
