Skip to main content
from edsl import ScenarioList
Call the from_source() method on a ScenarioList and pass (i) source type “wikipedia”, (ii) the URL for the Wikipedia page containing the table and (iii) the number of the table on the page (an integer starting at 0 that can be omitted if there is only 1 table on the page). For example, here we create scenarios for the 4th table at the page about movies of the 1990s:
scenarios = ScenarioList.from_source(
    source_type = "wikipedia",
    url = "https://en.wikipedia.org/wiki/1990s_in_film",
    table_index = 3
)
scenarios
ScenarioList scenarios: 50; keys: ['Worldwide gross', 'Studios', 'Title', 'Year', 'Rank', 'Ref.'];
RankTitleStudiosWorldwide grossYearRef.
01TitanicParamount Pictures/20th Century Fox$1,843,201,2681997[# 1]
12Star Wars: Episode I – The Phantom Menace20th Century Fox$924,317,5581999[# 2]
23Jurassic ParkUniversal Pictures$914,691,1181993[# 3]
34Independence Day20th Century Fox$817,400,8911996[# 4]
45The Lion KingWalt Disney Studios$763,455,5611994[# 5]
56Forrest GumpParamount Pictures$677,387,7161994[# 6]
67The Sixth SenseWalt Disney Studios$672,806,2921999[# 7]
78The Lost World: Jurassic ParkUniversal Pictures$618,638,9991997[# 8]
89Men in BlackSony Pictures/Columbia Pictures$589,390,5391997[# 9]
910ArmageddonWalt Disney Studios$553,709,7881998[# 10]
1011Terminator 2: Judgment DayTriStar Pictures$519,843,3451991[# 11]
1112GhostParamount Pictures$505,702,5881990[# 12]
1213AladdinWalt Disney Studios$504,050,2191992[# 13]
1314TwisterWarner Bros./Universal Pictures$494,471,5241996[# 14]
1415Toy Story 2Walt Disney Studios$485,015,1791999[# 15]
1516Saving Private RyanDreamWorks Pictures/Paramount Pictures$481,840,9091998[# 16]
1617Home Alone20th Century Fox$476,684,6751990[# 17]
1718The MatrixWarner Bros.$463,517,3831999[# 18]
1819Pretty WomanWalt Disney Studios$463,406,2681990[# 19]
1920Mission: ImpossibleParamount Pictures$457,696,3591996[# 20]
2021TarzanWalt Disney Studios$448,191,8191999[# 21]
2122Mrs. Doubtfire20th Century Fox$441,286,1951993[# 22]
2223Dances with WolvesOrion Pictures$424,208,8481990[# 23]
2324The MummyUniversal Pictures$415,933,4061999[# 24]
2425The BodyguardWarner Bros.$411,006,7401992[# 25]
2526Robin Hood: Prince of ThievesWarner Bros.$390,493,9081991[# 26]
2627GodzillaTriStar Pictures$379,014,2941998[# 27]
2728True Lies20th Century Fox$378,882,4111994[# 28]
2829Toy StoryWalt Disney Studios$373,554,0331995[# 29]
2930There’s Something About Mary20th Century Fox$369,884,6511998[# 30]
3031The FugitiveWarner Bros.$368,875,7601993[# 31]
3132Die Hard with a Vengeance20th Century Fox/Cinergi Pictures$366,101,6661995[# 32]
3233Notting HillPolyGram Filmed Entertainment$363,889,6781999[# 33]
3334A Bug’s LifeWalt Disney Studios$363,398,5651998[# 34]
3435The World Is Not EnoughMetro-Goldwyn-Mayer Pictures$361,832,4001999[# 35]
3536Home Alone 2: Lost in New York20th Century Fox$358,994,8501992[# 36]
3637American BeautyDreamWorks Pictures$356,296,6011999[# 37]
3738Apollo 13Universal Pictures/Imagine Entertainment$355,237,9331995[# 38]
3839Basic InstinctTriStar Pictures$352,927,2241992[# 39]
3940GoldenEyeMGM/United Artists$352,194,0341995[# 40]
4041The MaskNew Line Cinema$351,583,4071994[# 41]
4142Speed20th Century Fox$350,448,1451994[# 42]
4243Deep ImpactParamount Pictures/DreamWorks Pictures$349,464,6641998[# 43]
4344Beauty and the BeastWalt Disney Studios$346,317,2071991[# 44]
4445PocahontasWalt Disney Studios$346,079,7731995[# 45]
4546The FlintstonesUniversal Pictures$341,631,2081994[# 46]
4647Batman ForeverWarner Bros.$336,529,1441995[# 47]
4748The RockWalt Disney Studios$335,062,6211996[# 48]
4849Tomorrow Never DiesMGM/United Artists$333,011,0681997[# 49]
4950SevenNew Line Cinema$327,311,8591995[# 50]
scenarios.parameters
{'Rank', 'Ref.', 'Studios', 'Title', 'Worldwide gross', 'Year'}
from edsl import QuestionList

q_leads = QuestionList(
    question_name = "leads",
    question_text = "Who are the lead actors or actresses in {{ scenario.Title }}?"
)

results = q_leads.by(scenarios).run()
(
    results
    .sort_by("Title")
    .select("Title", "leads")
)
scenario.Titleanswer.leads
0A Bug’s Life[‘Dave Foley’, ‘Kevin Spacey’, ‘Julia Louis-Dreyfus’]
1Aladdin[‘Mena Massoud’, ‘Naomi Scott’, ‘Will Smith’]
2American Beauty[‘Kevin Spacey’, ‘Annette Bening’, ‘Thora Birch’]
3Apollo 13[‘Tom Hanks’, ‘Bill Paxton’, ‘Kevin Bacon’, ‘Gary Sinise’, ‘Ed Harris’]
4Armageddon[‘Bruce Willis’, ‘Ben Affleck’, ‘Liv Tyler’]
5Basic Instinct[‘Michael Douglas’, ‘Sharon Stone’]
6Batman Forever[‘Val Kilmer’, ‘Tommy Lee Jones’, ‘Jim Carrey’, ‘Nicole Kidman’, “Chris O’Donnell”]
7Beauty and the Beast[‘Emma Watson’, ‘Dan Stevens’]
8Dances with Wolves[‘Kevin Costner’, ‘Mary McDonnell’, ‘Graham Greene’]
9Deep Impact[‘Elijah Wood’, ‘Morgan Freeman’, ‘Robert Duvall’, ‘Téa Leoni’, ‘Vanessa Redgrave’, ‘Maximilian Schell’, ‘Leelee Sobieski’]
10Die Hard with a Vengeance[‘Bruce Willis’, ‘Samuel L. Jackson’, ‘Jeremy Irons’]
11Forrest Gump[‘Tom Hanks’, ‘Robin Wright’, ‘Gary Sinise’, ‘Mykelti Williamson’, ‘Sally Field’]
12Ghost[‘Patrick Swayze’, ‘Demi Moore’, ‘Whoopi Goldberg’]
13Godzilla[‘Aaron Taylor-Johnson’, ‘Elizabeth Olsen’, ‘Bryan Cranston’]
14GoldenEye[‘Pierce Brosnan’, ‘Sean Bean’, ‘Izabella Scorupco’, ‘Famke Janssen’]
15Home Alone[‘Macaulay Culkin’, ‘Joe Pesci’, ‘Daniel Stern’, “Catherine O’Hara”, ‘John Heard’]
16Home Alone 2: Lost in New York[‘Macaulay Culkin’, ‘Joe Pesci’, ‘Daniel Stern’, “Catherine O’Hara”, ‘John Heard’]
17Independence Day[‘Will Smith’, ‘Jeff Goldblum’, ‘Bill Pullman’]
18Jurassic Park[‘Sam Neill’, ‘Laura Dern’, ‘Jeff Goldblum’, ‘Richard Attenborough’]
19Men in Black[‘Will Smith’, ‘Tommy Lee Jones’]
20Mission: Impossible[‘Tom Cruise’, ‘Jon Voight’, ‘Emmanuelle Béart’, ‘Henry Czerny’, ‘Ving Rhames’]
21Mrs. Doubtfire[‘Robin Williams’, ‘Sally Field’, ‘Pierce Brosnan’]
22Notting Hill[‘Hugh Grant’, ‘Julia Roberts’]
23Pocahontas[‘Irene Bedard’, ‘Mel Gibson’]
24Pretty Woman[‘Richard Gere’, ‘Julia Roberts’]
25Robin Hood: Prince of Thieves[‘Kevin Costner’, ‘Morgan Freeman’, ‘Mary Elizabeth Mastrantonio’, ‘Alan Rickman’, ‘Christian Slater’]
26Saving Private Ryan[‘Tom Hanks’, ‘Matt Damon’, ‘Tom Sizemore’, ‘Edward Burns’, ‘Barry Pepper’, ‘Adam Goldberg’, ‘Vin Diesel’, ‘Giovanni Ribisi’]
27Seven[‘Brad Pitt’, ‘Morgan Freeman’, ‘Gwyneth Paltrow’]
28Speed[‘Keanu Reeves’, ‘Sandra Bullock’, ‘Dennis Hopper’]
29Star Wars: Episode I – The Phantom Menace[‘Liam Neeson’, ‘Ewan McGregor’, ‘Natalie Portman’, ‘Jake Lloyd’]
30Tarzan[‘Johnny Weissmuller’, ‘Christopher Lambert’, ‘Tony Goldwyn’, ‘Alexander Skarsgård’]
31Terminator 2: Judgment Day[‘Arnold Schwarzenegger’, ‘Linda Hamilton’, ‘Edward Furlong’, ‘Robert Patrick’]
32The Bodyguard[‘Kevin Costner’, ‘Whitney Houston’]
33The Flintstones[‘John Goodman’, ‘Elizabeth Perkins’, ‘Rick Moranis’, “Rosie O’Donnell”]
34The Fugitive[‘Harrison Ford’, ‘Tommy Lee Jones’]
35The Lion King[‘Matthew Broderick’, ‘James Earl Jones’, ‘Jeremy Irons’, ‘Moira Kelly’, ‘Nathan Lane’]
36The Lost World: Jurassic Park[‘Jeff Goldblum’, ‘Julianne Moore’, ‘Vince Vaughn’]
37The Mask[‘Jim Carrey’, ‘Cameron Diaz’]
38The Matrix[‘Keanu Reeves’, ‘Laurence Fishburne’, ‘Carrie-Anne Moss’]
39The Mummy[‘Brendan Fraser’, ‘Rachel Weisz’, ‘John Hannah’, ‘Arnold Vosloo’]
40The Rock[‘Sean Connery’, ‘Nicolas Cage’, ‘Ed Harris’]
41The Sixth Sense[‘Bruce Willis’, ‘Haley Joel Osment’, ‘Toni Collette’]
42The World Is Not Enough[‘Pierce Brosnan’, ‘Sophie Marceau’, ‘Robert Carlyle’, ‘Denise Richards’]
43There’s Something About Mary[‘Cameron Diaz’, ‘Ben Stiller’, ‘Matt Dillon’]
44Titanic[‘Leonardo DiCaprio’, ‘Kate Winslet’]
45Tomorrow Never Dies[‘Pierce Brosnan’, ‘Jonathan Pryce’, ‘Michelle Yeoh’, ‘Teri Hatcher’]
46Toy Story[‘Tom Hanks’, ‘Tim Allen’]
47Toy Story 2[‘Tom Hanks’, ‘Tim Allen’, ‘Joan Cusack’]
48True Lies[‘Arnold Schwarzenegger’, ‘Jamie Lee Curtis’]
49Twister[‘Helen Hunt’, ‘Bill Paxton’]

Posting to Coop

from edsl import Notebook

nb = Notebook(path = "scenario_list_wikipedia.ipynb")

nb.push(
    description = "Example code for generating scenarios from Wikipedia tables",
    alias = "example-wikipedia-table-scenarios-notebook",
    visibility = "public"
)
{'description': 'Example code for generating scenarios from Wikipedia tables',
 'object_type': 'notebook',
 'url': 'https://www.expectedparrot.com/content/678ac016-b6ab-4314-ac83-dd0981c1ddbe',
 'alias_url': 'https://www.expectedparrot.com/content/RobinHorton/example-wikipedia-table-scenarios-notebook',
 'uuid': '678ac016-b6ab-4314-ac83-dd0981c1ddbe',
 'version': '0.1.62.dev1',
 'visibility': 'public'}
I