<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 EventVestor
Step1:  Let's go over the columns
Step2:  Now suppose we want a DataFrame of all earnings releases with revenue over 30 billion dollars. For those earnings releases, we only want the sid and the asof_date.
<ASSISTANT_TASK:>
Python Code:
# import the dataset
from quantopian.interactive.data.eventvestor import earnings_releases
# or if you want to import the free dataset, use:
# from quantopian.interactivedata.eventvestor import earnings_releases_free
# import data operations
from odo import odo
# import other libraries we will use
import pandas as pd
# Let's use blaze to understand the data a bit using Blaze dshape()
earnings_releases.dshape
# And how many rows are there?
# N.B. we're using a Blaze function to do this, not len()
earnings_releases.count()
# Let's see what the data looks like. We'll grab the first three rows.
earnings_releases[:3]
Explanation: EventVestor: Earnings Releases
In this notebook, we'll take a look at EventVestor's Earnings Releases dataset, available on the Quantopian Store. This dataset spans January 01, 2007 through the current day, and documents quarterly earnings releases.
Blaze
Before we dig into the data, we want to tell you about how  you generally access Quantopian Store data sets. These datasets are available through an API service known as Blaze. Blaze provides the Quantopian user with a convenient interface to access very large datasets.
Blaze provides an important function for accessing these datasets. Some of these sets are many millions of records. Bringing that data directly into Quantopian Research directly just is not viable. So Blaze allows us to provide a simple querying interface and shift the burden over to the server side.
It is common to use Blaze to reduce your dataset in size, convert it over to Pandas and then to use Pandas for further computation, manipulation and visualization.
Helpful links:
* Query building for Blaze
* Pandas-to-Blaze dictionary
* SQL-to-Blaze dictionary.
Once you've limited the size of your Blaze object, you can convert it to a Pandas DataFrames using:
from odo import odo
odo(expr, pandas.DataFrame)
Free samples and limits
One other key caveat: we limit the number of results returned from any given expression to 10,000 to protect against runaway memory usage. To be clear, you have access to all the data server side. We are limiting the size of the responses back from Blaze.
There is a free version of this dataset as well as a paid one. The free one includes about three years of historical data, though not up to the current day.
With preamble in place, let's get started:
End of explanation
# get apple's sid first
aapl_sid = symbols('AAPL').sid
aapl_earnings = earnings_releases[('2011-12-31' < earnings_releases['asof_date']) & (earnings_releases['asof_date'] <'2013-01-01') & (earnings_releases.sid==aapl_sid)]
# When displaying a Blaze Data Object, the printout is automatically truncated to ten rows.
aapl_earnings.sort('asof_date')
Explanation: Let's go over the columns:
- event_id: the unique identifier for this event.
- asof_date: EventVestor's timestamp of event capture.
- trade_date: for event announcements made before trading ends, trade_date is the same as event_date. For announcements issued after market close, trade_date is next market open day.
- symbol: stock ticker symbol of the affected company.
- event_type: this should always be Earnings Release/Earnings release.
- event_headline: a brief description of the event
- event_phase: the inclusion of this field is likely an error on the part of the data vendor. We're currently attempting to resolve this.
- fiscal_period: fiscal period for the reported earnings, such as 1Q 15, 2Q 15, etc.
- calendar_period: identifies the calendar period based on the fiscal period end date. E.g. if the fiscal period ends any time after the middle of a given calendar quarter, like 1Q 15, that calendar quarter will be assigned regardless of the fiscal quarter.
- fiscal_periodend: the last date for the reported earnings period.
- currency: currency used for reporting earnings.
- revenue: revenue in millions
- gross_income: gross income in millions
- operating_income: operating income in millions
- net_income: net income in millions
- eps: earnings per share, in the reported currency
- eps_surprisepct: the meaning of this column is presently uncertain. We're working with our data vendor to resolve this issue.
- event_rating: this is always 1. The meaning of this is uncertain.
- timestamp: this is our timestamp on when we registered the data.
- sid: the equity's unique identifier. Use this instead of the symbol.
We've done much of the data processing for you. Fields like timestamp and sid are standardized across all our Store Datasets, so the datasets are easy to combine. We have standardized the sid across all our equity databases.
We can select columns and rows with ease. Below, we'll fetch all of Apple's entries from 2012.
End of explanation
# manipulate with Blaze first:
big_earnings = earnings_releases[earnings_releases.revenue > 40000]
# now that we've got a much smaller object (len: ~2167 rows), we can convert it to a pandas DataFrame
df = odo(big_earnings, pd.DataFrame)
df = df[['sid', 'asof_date','revenue']].dropna()
df.sort('revenue',ascending=False)
Explanation: Now suppose we want a DataFrame of all earnings releases with revenue over 30 billion dollars. For those earnings releases, we only want the sid and the asof_date.
End of explanation
<END_TASK>