{"id":630,"date":"2018-02-08T11:50:00","date_gmt":"2018-02-08T10:50:00","guid":{"rendered":"https:\/\/eaa-online.org\/arc\/blog\/blog\/retrieving-data-wrds-directly-using-python-r-and-stata\/"},"modified":"2022-10-17T15:22:56","modified_gmt":"2022-10-17T13:22:56","slug":"retrieving-data-wrds-directly-using-python-r-and-stata","status":"publish","type":"post","link":"https:\/\/eaa-online.org\/arc\/blog\/2018\/02\/08\/retrieving-data-wrds-directly-using-python-r-and-stata\/","title":{"rendered":"Retrieving data from WRDS directly using Python, R, and Stata"},"content":{"rendered":"<div class=\"cell border-box-sizing text_cell rendered\">\n<div class=\"inner_cell\">\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<p>Downloading data from the WRDS website is convenient but not the most transparent and replicable as it requires a workflow along the lines of:<\/p>\n<ol>\n<li>Create a list of identifiers using your program (i.e. Python)<\/li>\n<li>Load the identifiers into the WRDS web interface + make your query<\/li>\n<li>Download the resulting data from WRDS into a file<\/li>\n<li>Load the WRDS data file back into your program<\/li>\n<\/ol>\n<p>The problem is that step 2 and step 3 happen outside of your code. This essentially leaves a gap in the steps required to run your code, which can leave other people (or your future-self) confused as to what you exactly did on the WRDS website to extract the required data.<\/p>\n<p>For a long time WRDS only offered to programmatically interface with WRDS data through SAS files. Non-SAS clients (think Python and R) could therefore only interact with WRDS data through SAS-bindings. This approach technically worked but was definitely a substantial hassle for many applications. Fortunately, WRDS decided to also make all their data available through a series of PostgreSQL databases. This change happened somewhere in June \/ July of 2017 (at least for the WRDS Python package). In other words, we can now finally directly interface with WRDS data using tools like Python, R, Stata, and MATLAB!<\/p>\n<p>The WRDS support documents extensively describe how interface with WRDS using the different programs. I will include all links below, but for the sake of completeness will discuss a couple of tips and tricks + some Python code examples to illustrate how one can use it.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing text_cell rendered\">\n<div class=\"inner_cell\">\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<h3 id=\"Links-to-WRDS-documentation\">Links to WRDS documentation<a class=\"anchor-link\" href=\"#Links-to-WRDS-documentation\">\u00b6<\/a><\/h3>\n<ul>\n<li><a title=\"WRDS documentation\" href=\"https:\/\/wrds-web.wharton.upenn.edu\/wrds\/support\/index.cfm\" target=\"_blank\" rel=\"noopener\">Homepage WRDS documentation<\/a><\/li>\n<li><a title=\"WRDS documentation for Python\" href=\"https:\/\/wrds-www.wharton.upenn.edu\/pages\/support\/wrds-cloud\/holding\/python-programming-wrds\/\" target=\"_blank\" rel=\"noopener\">WRDS documentation: Python<\/a><\/li>\n<li><a title=\"WRDS documentation for R\" href=\"https:\/\/wrds-www.wharton.upenn.edu\/pages\/support\/wrds-cloud\/holding\/r-programming-wrds\" target=\"_blank\" rel=\"noopener\">WRDS documentation: R<\/a><\/li>\n<li><a title=\"WRDS documentation for Stata\" href=\"https:\/\/wrds-www.wharton.upenn.edu\/pages\/support\/wrds-cloud\/holding\/stata-programming-wrds\" target=\"_blank\" rel=\"noopener\">WRDS documentation: Stata<\/a><\/li>\n<li><a title=\"WRDS documentation for MATLAB\" href=\"https:\/\/wrds-www.wharton.upenn.edu\/pages\/support\/wrds-cloud\/holding\/using-matlab-wrds\" target=\"_blank\" rel=\"noopener\">WRDS documentation: MATLAB<\/a><\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing text_cell rendered\">\n<div class=\"inner_cell\">\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<h1 id=\"Tips-and-Tricks\"><u>Tips and Tricks<\/u><\/h1>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing text_cell rendered\">\n<div class=\"inner_cell\">\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<ul>\n<li>The WRDS documentation for a particular program is usually roughly split into two sections: using the WRDS cloud and using your own system. If you have a sufficiently powerful system I recommend to start with using your own system. As such I don\u2019t recommend to go through all of the documentation linearly, but instead to scroll down to the actual code examples.<\/li>\n<li>Making SQL queries can be very slow depending on the efficiency of your SQL query. If you are going to make a big query I would usually recommend to only use \u201cWHERE .. IN (.., ..)\u201d queries on the primary identifier columns.<\/li>\n<li>The SQL query will return the raw data, this will in nearly all cases differ from the output you get using the WRDS web interface. This is due to the fact that the WRDS web interface usually has pre-selected \u201cdata quality\u201d options. For example, the Historical CIK-CUSIP link table from the WRDS SEC Analytics Suite excludes \u201cInvalid Link\u201d and \u201cName Mismatch\u201d observations whereas the SQL query will by default include all observations. This can be easily resolved by some data cleaning after the SQL query but it is important to inspect your data after the query!<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing text_cell rendered\">\n<div class=\"inner_cell\">\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<h1 id=\"Python-example-code\"><u>Python example code<\/u><a class=\"anchor-link\" href=\"#Python-example-code\">\u00b6<\/a><\/h1>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing text_cell rendered\">\n<div class=\"inner_cell\">\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<h2 id=\"Import-WRDS-library\">Import WRDS library<a class=\"anchor-link\" href=\"#Import-WRDS-library\">\u00b6<\/a><\/h2>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing text_cell rendered\">\n<div class=\"inner_cell\">\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<p>Note, the <code>WRDS<\/code>library can be installed from the command line using <code>pip install wrds<\/code><br \/>\n<a href=\"https:\/\/pypi.python.org\/pypi\/wrds\">https:\/\/pypi.python.org\/pypi\/wrds<\/a><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing code_cell rendered\">\n<div class=\"input\">\n<div class=\"prompt input_prompt\">In\u00a0[1]:<\/div>\n<div class=\"inner_cell\">\n<div class=\"input_area\">\n<div class=\"highlight hl-ipython3\">\n<pre><span class=\"kn\">import<\/span> <span class=\"nn\">wrds<\/span>\r\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing code_cell rendered\">\n<div class=\"input\">\n<div class=\"prompt input_prompt\">In\u00a0[2]:<\/div>\n<div class=\"inner_cell\">\n<div class=\"input_area\">\n<div class=\"highlight hl-ipython3\">\n<pre><span class=\"n\">db<\/span> <span class=\"o\">=<\/span> <span class=\"n\">wrds<\/span><span class=\"o\">.<\/span><span class=\"n\">Connection<\/span><span class=\"p\">()<\/span>\r\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"output_wrapper\">\n<div class=\"output\">\n<div class=\"output_area\">\n<div class=\"prompt\"><\/div>\n<div class=\"output_subarea output_stream output_stdout output_text\">\n<pre>Enter your WRDS username [TiesPC]: wrds_user\r\nEnter your password:\u00b7\u00b7\u00b7\u00b7\u00b7\u00b7\u00b7\u00b7\r\nLoading library list...\r\nDone\r\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing text_cell rendered\">\n<div class=\"inner_cell\">\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<h2 id=\"Get-META-data\">Get META data<a class=\"anchor-link\" href=\"#Get-META-data\">\u00b6<\/a><\/h2>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing text_cell rendered\">\n<div class=\"inner_cell\">\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<h3 id=\"See-all-libraries\">See all available libraries<a class=\"anchor-link\" href=\"#See-all-libraries\">\u00b6<\/a><\/h3>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing code_cell rendered\">\n<div class=\"input\">\n<div class=\"prompt input_prompt\">In\u00a0[3]:<\/div>\n<div class=\"inner_cell\">\n<div class=\"input_area\">\n<div class=\"highlight hl-ipython3\">\n<pre><span class=\"n\">libraries<\/span> <span class=\"o\">=<\/span> <span class=\"n\">db<\/span><span class=\"o\">.<\/span><span class=\"n\">list_libraries<\/span><span class=\"p\">()<\/span>\r\n<span class=\"n\">libraries<\/span><span class=\"p\">[:<\/span><span class=\"mi\">4<\/span><span class=\"p\">]<\/span>\r\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"output_wrapper\">\n<div class=\"output\">\n<div class=\"output_area\">\n<div class=\"prompt output_prompt\">Out[3]:<\/div>\n<div class=\"output_text output_subarea output_execute_result\">\n<pre>['aha_sample', 'ahasamp', 'audit', 'audit_audit_comp']<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing text_cell rendered\">\n<div class=\"inner_cell\">\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<h3 id=\"See-all-tables-in-a-library\">See all tables in a library<a class=\"anchor-link\" href=\"#See-all-tables-in-a-library\">\u00b6<\/a><\/h3>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing code_cell rendered\">\n<div class=\"input\">\n<div class=\"prompt input_prompt\">In\u00a0[4]:<\/div>\n<div class=\"inner_cell\">\n<div class=\"input_area\">\n<div class=\"highlight hl-ipython3\">\n<pre><span class=\"n\">tables<\/span> <span class=\"o\">=<\/span> <span class=\"n\">db<\/span><span class=\"o\">.<\/span><span class=\"n\">list_tables<\/span><span class=\"p\">(<\/span><span class=\"s1\">'wrdssec'<\/span><span class=\"p\">)<\/span>\r\n<span class=\"n\">tables<\/span><span class=\"p\">[:<\/span><span class=\"mi\">4<\/span><span class=\"p\">]<\/span>\r\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"output_wrapper\">\n<div class=\"output\">\n<div class=\"output_area\">\n<div class=\"prompt output_prompt\">Out[4]:<\/div>\n<div class=\"output_text output_subarea output_execute_result\">\n<pre>['wrds_forms_reg', 'wrds_13f_link', 'wrds_13f_summary', 'wrds_forms']<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing text_cell rendered\">\n<div class=\"inner_cell\">\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<h3 id=\"See-all-column-headers-in-a-table\">See all column headers in a table<a class=\"anchor-link\" href=\"#See-all-column-headers-in-a-table\">\u00b6<\/a><\/h3>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing code_cell rendered\">\n<div class=\"input\">\n<div class=\"prompt input_prompt\">In\u00a0[5]:<\/div>\n<div class=\"inner_cell\">\n<div class=\"input_area\">\n<div class=\"highlight hl-ipython3\">\n<pre><span class=\"n\">col_headers<\/span> <span class=\"o\">=<\/span> <span class=\"n\">db<\/span><span class=\"o\">.<\/span><span class=\"n\">describe_table<\/span><span class=\"p\">(<\/span><span class=\"n\">library<\/span><span class=\"o\">=<\/span><span class=\"s1\">'wrdssec'<\/span><span class=\"p\">,<\/span> <span class=\"n\">table<\/span><span class=\"o\">=<\/span><span class=\"s1\">'wrds_nlpsa'<\/span><span class=\"p\">)<\/span>\r\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"output_wrapper\">\n<div class=\"output\">\n<div class=\"output_area\">\n<div class=\"prompt\"><\/div>\n<div class=\"output_subarea output_stream output_stdout output_text\">\n<pre>Approximately 45332100 rows in wrdssec.wrds_nlpsa.\r\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing code_cell rendered\">\n<div class=\"input\">\n<div class=\"prompt input_prompt\">In\u00a0[6]:<\/div>\n<div class=\"inner_cell\">\n<div class=\"input_area\">\n<div class=\"highlight hl-ipython3\">\n<pre><span class=\"n\">col_headers<\/span><span class=\"o\">.<\/span><span class=\"n\">head<\/span><span class=\"p\">()<\/span>\r\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"output_wrapper\">\n<div class=\"output\">\n<div class=\"output_area\">\n<div class=\"prompt\"><\/div>\n<div class=\"output_html rendered_html output_subarea \">\n<div>\n<style type=\"text\/css\">\n.dataframe thead tr:only-child th {<br \/>\n        text-align: right;<br \/>\n    }<\/p>\n<p>    .dataframe thead th {<br \/>\n        text-align: left;<br \/>\n    }<\/p>\n<p>    .dataframe tbody tr th {<br \/>\n        vertical-align: top;<br \/>\n    }\t\t\t\t\t\t<\/style>\n<table class=\"dataframe\" border=\"1\">\n<thead>\n<tr style=\"text-align: right;\">\n<th><\/th>\n<th>name<\/th>\n<th>nullable<\/th>\n<th>type<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<th>0<\/th>\n<td>gvkey<\/td>\n<td>True<\/td>\n<td>VARCHAR(6)<\/td>\n<\/tr>\n<tr>\n<th>1<\/th>\n<td>cik<\/td>\n<td>True<\/td>\n<td>VARCHAR(10)<\/td>\n<\/tr>\n<tr>\n<th>2<\/th>\n<td>fdate<\/td>\n<td>True<\/td>\n<td>DATE<\/td>\n<\/tr>\n<tr>\n<th>3<\/th>\n<td>form<\/td>\n<td>True<\/td>\n<td>VARCHAR(12)<\/td>\n<\/tr>\n<tr>\n<th>4<\/th>\n<td>coname<\/td>\n<td>True<\/td>\n<td>VARCHAR(62)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing text_cell rendered\">\n<div class=\"inner_cell\">\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<h2 id=\"Querying-data\">Querying data<a class=\"anchor-link\" href=\"#Querying-data\">\u00b6<\/a><\/h2>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing text_cell rendered\">\n<div class=\"inner_cell\">\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<p>There are two ways:<\/p>\n<ol>\n<li><code>get_table()<\/code><\/li>\n<li><code>raw_sql()<\/code><\/li>\n<\/ol>\n<p>For a table with not too many rows (like some of the linktables) you can use <code>get_table()<\/code>, otherwise <code>raw_sql()<\/code>is advisable.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing text_cell rendered\">\n<div class=\"inner_cell\">\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<h3 id=\"Get-first-5-rows-using-get_table()\">Get first 5 rows using <code>get_table()<\/code><a class=\"anchor-link\" href=\"#Get-first-5-rows-using-get_table()\">\u00b6<\/a><\/h3>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing code_cell rendered\">\n<div class=\"input\">\n<div class=\"prompt input_prompt\">In\u00a0[9]:<\/div>\n<div class=\"inner_cell\">\n<div class=\"input_area\">\n<div class=\"highlight hl-ipython3\">\n<pre><span class=\"n\">data_5rows<\/span> <span class=\"o\">=<\/span> <span class=\"n\">db<\/span><span class=\"o\">.<\/span><span class=\"n\">get_table<\/span><span class=\"p\">(<\/span><span class=\"n\">library<\/span><span class=\"o\">=<\/span><span class=\"s1\">'wrdssec'<\/span><span class=\"p\">,<\/span> <span class=\"n\">table<\/span><span class=\"o\">=<\/span><span class=\"s1\">'wrds_nlpsa'<\/span><span class=\"p\">,<\/span> <span class=\"n\">columns<\/span> <span class=\"o\">=<\/span> <span class=\"p\">[<\/span><span class=\"s1\">'gvkey'<\/span><span class=\"p\">,<\/span> <span class=\"s1\">'cik'<\/span><span class=\"p\">,<\/span> <span class=\"s1\">'filename'<\/span><span class=\"p\">,<\/span> <span class=\"s1\">'finterms_litigious_count'<\/span><span class=\"p\">],<\/span> <span class=\"n\">obs<\/span><span class=\"o\">=<\/span><span class=\"mi\">5<\/span><span class=\"p\">)<\/span>\r\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing code_cell rendered\">\n<div class=\"input\">\n<div class=\"prompt input_prompt\">In\u00a0[10]:<\/div>\n<div class=\"inner_cell\">\n<div class=\"input_area\">\n<div class=\"highlight hl-ipython3\">\n<pre><span class=\"n\">data_5rows<\/span>\r\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"output_wrapper\">\n<div class=\"output\">\n<div class=\"output_area\">\n<div class=\"prompt\"><\/div>\n<div class=\"output_html rendered_html output_subarea \">\n<div>\n<style type=\"text\/css\">\n.dataframe thead tr:only-child th {<br \/>\n        text-align: right;<br \/>\n    }<\/p>\n<p>    .dataframe thead th {<br \/>\n        text-align: left;<br \/>\n    }<\/p>\n<p>    .dataframe tbody tr th {<br \/>\n        vertical-align: top;<br \/>\n    }\t\t\t\t\t\t<\/style>\n<table class=\"dataframe\" border=\"1\">\n<thead>\n<tr style=\"text-align: right;\">\n<th><\/th>\n<th>gvkey<\/th>\n<th>cik<\/th>\n<th>filename<\/th>\n<th>finterms_litigious_count<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<th>0<\/th>\n<td>None<\/td>\n<td>0000000003<\/td>\n<td>000000\/3\/0000950103-94-000082.txt<\/td>\n<td>0.0<\/td>\n<\/tr>\n<tr>\n<th>1<\/th>\n<td>None<\/td>\n<td>0000000003<\/td>\n<td>000000\/3\/0000934850-95-001755.txt<\/td>\n<td>0.0<\/td>\n<\/tr>\n<tr>\n<th>2<\/th>\n<td>None<\/td>\n<td>0000000003<\/td>\n<td>000000\/3\/0000000003-96-000001.txt<\/td>\n<td>0.0<\/td>\n<\/tr>\n<tr>\n<th>3<\/th>\n<td>None<\/td>\n<td>0000000003<\/td>\n<td>000000\/3\/0000934850-97-000209.txt<\/td>\n<td>2.0<\/td>\n<\/tr>\n<tr>\n<th>4<\/th>\n<td>None<\/td>\n<td>0000000003<\/td>\n<td>000000\/3\/0000934850-98-001281.txt<\/td>\n<td>0.0<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing text_cell rendered\">\n<div class=\"inner_cell\">\n<div class=\"text_cell_render border-box-sizing rendered_html\">\n<h3 id=\"Query-using-raw_sql()\">Query using <code>raw_sql()<\/code><a class=\"anchor-link\" href=\"#Query-using-raw_sql()\">\u00b6<\/a><\/h3>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing code_cell rendered\">\n<div class=\"input\">\n<div class=\"prompt input_prompt\">In\u00a0[13]:<\/div>\n<div class=\"inner_cell\">\n<div class=\"input_area\">\n<div class=\"highlight hl-ipython3\">\n<pre><span class=\"n\">data_5rows<\/span><span class=\"o\">.<\/span><span class=\"n\">cik<\/span><span class=\"o\">.<\/span><span class=\"n\">values<\/span>\r\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"output_wrapper\">\n<div class=\"output\">\n<div class=\"output_area\">\n<div class=\"prompt output_prompt\">Out[13]:<\/div>\n<div class=\"output_text output_subarea output_execute_result\">\n<pre>array(['0000000003', '0000000003', '0000000003', '0000000003', '0000000003'], dtype=object)<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing code_cell rendered\">\n<div class=\"input\">\n<div class=\"prompt input_prompt\">In\u00a0[14]:<\/div>\n<div class=\"inner_cell\">\n<div class=\"input_area\">\n<div class=\"highlight hl-ipython3\">\n<pre><span class=\"n\">sql_query<\/span> <span class=\"o\">=<\/span> <span class=\"s2\">\"\"\"<\/span>\r\n<span class=\"s2\">SELECT gvkey,<\/span>\r\n<span class=\"s2\">       cik,<\/span>\r\n<span class=\"s2\">       filename,<\/span>\r\n<span class=\"s2\">       finterms_litigious_count<\/span>\r\n<span class=\"s2\">FROM wrdssec.wrds_nlpsa<\/span>\r\n<span class=\"s2\">WHERE cik IN ('0000000003', '0000000003', '0000000003', '0000000003', '0000000003')<\/span>\r\n<span class=\"s2\">\"\"\"<\/span>\r\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing code_cell rendered\">\n<div class=\"input\">\n<div class=\"prompt input_prompt\">In\u00a0[15]:<\/div>\n<div class=\"inner_cell\">\n<div class=\"input_area\">\n<div class=\"highlight hl-ipython3\">\n<pre><span class=\"n\">data_query<\/span> <span class=\"o\">=<\/span> <span class=\"n\">db<\/span><span class=\"o\">.<\/span><span class=\"n\">raw_sql<\/span><span class=\"p\">(<\/span><span class=\"n\">sql_query<\/span><span class=\"p\">)<\/span>\r\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"cell border-box-sizing code_cell rendered\">\n<div class=\"input\">\n<div class=\"prompt input_prompt\">In\u00a0[16]:<\/div>\n<div class=\"inner_cell\">\n<div class=\"input_area\">\n<div class=\"highlight hl-ipython3\">\n<pre><span class=\"n\">data_query<\/span>\r\n<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"output_wrapper\">\n<div class=\"output\">\n<div class=\"output_area\">\n<div class=\"prompt\"><\/div>\n<div class=\"output_html rendered_html output_subarea \">\n<div>\n<style type=\"text\/css\">\n.dataframe thead tr:only-child th {<br \/>\n        text-align: right;<br \/>\n    }<\/p>\n<p>    .dataframe thead th {<br \/>\n        text-align: left;<br \/>\n    }<\/p>\n<p>    .dataframe tbody tr th {<br \/>\n        vertical-align: top;<br \/>\n    }\t\t\t\t\t\t<\/style>\n<table class=\"dataframe\" border=\"1\">\n<thead>\n<tr style=\"text-align: right;\">\n<th><\/th>\n<th>gvkey<\/th>\n<th>cik<\/th>\n<th>filename<\/th>\n<th>finterms_litigious_count<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<th>0<\/th>\n<td>None<\/td>\n<td>0000000003<\/td>\n<td>000000\/3\/0000950103-94-000082.txt<\/td>\n<td>0.0<\/td>\n<\/tr>\n<tr>\n<th>1<\/th>\n<td>None<\/td>\n<td>0000000003<\/td>\n<td>000000\/3\/0000934850-95-001755.txt<\/td>\n<td>0.0<\/td>\n<\/tr>\n<tr>\n<th>2<\/th>\n<td>None<\/td>\n<td>0000000003<\/td>\n<td>000000\/3\/0000000003-96-000001.txt<\/td>\n<td>0.0<\/td>\n<\/tr>\n<tr>\n<th>3<\/th>\n<td>None<\/td>\n<td>0000000003<\/td>\n<td>000000\/3\/0000934850-97-000209.txt<\/td>\n<td>2.0<\/td>\n<\/tr>\n<tr>\n<th>4<\/th>\n<td>None<\/td>\n<td>0000000003<\/td>\n<td>000000\/3\/0000934850-98-001281.txt<\/td>\n<td>0.0<\/td>\n<\/tr>\n<tr>\n<th>5<\/th>\n<td>None<\/td>\n<td>0000000003<\/td>\n<td>000000\/3\/0000934850-98-002151.txt<\/td>\n<td>0.0<\/td>\n<\/tr>\n<tr>\n<th>6<\/th>\n<td>None<\/td>\n<td>0000000003<\/td>\n<td>000000\/3\/0000934850-98-002871.txt<\/td>\n<td>0.0<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>&nbsp;<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>&nbsp;<\/p>\n<style type=\"text\/css\">\npre {<br \/>\n  overflow: auto;<br \/>\n}<br \/>\ncode,<br \/>\npre {<br \/>\n  font-family: monospace, monospace;<br \/>\n  font-size: 1em;<br \/>\n}<br \/>\ntable {<br \/>\n  border-collapse: collapse;<br \/>\n  border-spacing: 0;<br \/>\n}<br \/>\ntd,<br \/>\nth {<br \/>\n  padding: 0;<br \/>\n}<\/p>\n<p>@media print {<br \/>\n  *,<br \/>\n  *:before,<br \/>\n  *:after {<br \/>\n    background: transparent !important;<br \/>\n    color: #000 !important;<br \/>\n    box-shadow: none !important;<br \/>\n    text-shadow: none !important;<br \/>\n  }<br \/>\n  a,<br \/>\n  a:visited {<br \/>\n    text-decoration: underline;<br \/>\n  }<br \/>\n  a[href]:after {<br \/>\n    content: \" (\" attr(href) \")\";<br \/>\n  }<br \/>\n  a[href^=\"#\"]:after {<br \/>\n    content: \"\";<br \/>\n  }<br \/>\n  pre {<br \/>\n    border: 1px solid #999;<br \/>\n    page-break-inside: avoid;<br \/>\n  }<br \/>\n  thead {<br \/>\n    display: table-header-group;<br \/>\n  }<br \/>\n  tr {<br \/>\n    page-break-inside: avoid;<br \/>\n  }<br \/>\n  p,<br \/>\n  h2,<br \/>\n  h3 {<br \/>\n    orphans: 3;<br \/>\n    widows: 3;<br \/>\n  }<br \/>\n  h2,<br \/>\n  h3 {<br \/>\n    page-break-after: avoid;<br \/>\n  }<br \/>\n}<\/p>\n<p>* {<br \/>\n  -webkit-box-sizing: border-box;<br \/>\n  -moz-box-sizing: border-box;<br \/>\n  box-sizing: border-box;<br \/>\n}<br \/>\n*:before,<br \/>\n*:after {<br \/>\n  -webkit-box-sizing: border-box;<br \/>\n  -moz-box-sizing: border-box;<br \/>\n  box-sizing: border-box;<br \/>\n}<\/p>\n<p>code,<br \/>\npre {<br \/>\n  font-family: monospace;<br \/>\n}<br \/>\ncode {<br \/>\n  padding: 2px 4px;<br \/>\n  font-size: 90%;<br \/>\n  color: #c7254e;<br \/>\n  background-color: #f9f2f4;<br \/>\n  border-radius: 2px;<br \/>\n}<br \/>\npre {<br \/>\n  display: block;<br \/>\n  padding: 8.5px;<br \/>\n  margin: 0 0 9px;<br \/>\n  font-size: 12px;<br \/>\n  line-height: 1.42857143;<br \/>\n  word-break: break-all;<br \/>\n  word-wrap: break-word;<br \/>\n  color: #333333;<br \/>\n  background-color: #f5f5f5;<br \/>\n  border: 1px solid #ccc;<br \/>\n  border-radius: 2px;<br \/>\n}<br \/>\ntable {<br \/>\n  background-color: transparent;<br \/>\n}<br \/>\nth {<br \/>\n  text-align: left;<br \/>\n}<br \/>\n@-ms-viewport {<br \/>\n  width: device-width;<br \/>\n}<\/p>\n<p>code {<br \/>\n  color: #000;<br \/>\n}<br \/>\npre {<br \/>\n  font-size: inherit;<br \/>\n  line-height: inherit;<br \/>\n}<br \/>\n\/* Make the page background atleast 100% the height of the view port *\/<br \/>\n\/* Make the page itself atleast 70% the height of the view port *\/<br \/>\n.border-box-sizing {<br \/>\n  box-sizing: border-box;<br \/>\n  -moz-box-sizing: border-box;<br \/>\n  -webkit-box-sizing: border-box;<br \/>\n}<\/p>\n<p>div.cell {<br \/>\n  \/* Old browsers *\/<br \/>\n  display: -webkit-box;<br \/>\n  -webkit-box-orient: vertical;<br \/>\n  -webkit-box-align: stretch;<br \/>\n  display: -moz-box;<br \/>\n  -moz-box-orient: vertical;<br \/>\n  -moz-box-align: stretch;<br \/>\n  display: box;<br \/>\n  box-orient: vertical;<br \/>\n  box-align: stretch;<br \/>\n  \/* Modern browsers *\/<br \/>\n  display: flex;<br \/>\n  flex-direction: column;<br \/>\n  align-items: stretch;<br \/>\n  border-radius: 2px;<br \/>\n  box-sizing: border-box;<br \/>\n  -moz-box-sizing: border-box;<br \/>\n  -webkit-box-sizing: border-box;<br \/>\n  border-width: 1px;<br \/>\n  border-style: solid;<br \/>\n  border-color: transparent;<br \/>\n  width: 100%;<br \/>\n  padding: 5px;<br \/>\n  \/* This acts as a spacer between cells, that is outside the border *\/<br \/>\n  margin: 0px;<br \/>\n  outline: none;<br \/>\n  border-left-width: 1px;<br \/>\n  padding-left: 5px;<br \/>\n  background: linear-gradient(to right, transparent -40px, transparent 1px, transparent 1px, transparent 100%);<br \/>\n}<br \/>\n.prompt {<br \/>\n  \/* This needs to be wide enough for 3 digit prompt numbers: In[100]: *\/<br \/>\n  min-width: 14ex;<br \/>\n  \/* This padding is tuned to match the padding on the CodeMirror editor. *\/<br \/>\n  padding: 0.4em;<br \/>\n  margin: 0px;<br \/>\n  font-family: monospace;<br \/>\n  text-align: right;<br \/>\n  \/* This has to match that of the the CodeMirror class line-height below *\/<br \/>\n  line-height: 1.21429em;<br \/>\n  \/* Don't highlight prompt number selection *\/<br \/>\n  -webkit-touch-callout: none;<br \/>\n  -webkit-user-select: none;<br \/>\n  -khtml-user-select: none;<br \/>\n  -moz-user-select: none;<br \/>\n  -ms-user-select: none;<br \/>\n  user-select: none;<br \/>\n  \/* Use default cursor *\/<br \/>\n  cursor: default;<br \/>\n}<br \/>\n@media (max-width: 540px) {<br \/>\n  .prompt {<br \/>\n    text-align: left;<br \/>\n  }<br \/>\n}<br \/>\ndiv.inner_cell {<br \/>\n  min-width: 0;<br \/>\n  \/* Old browsers *\/<br \/>\n  display: -webkit-box;<br \/>\n  -webkit-box-orient: vertical;<br \/>\n  -webkit-box-align: stretch;<br \/>\n  display: -moz-box;<br \/>\n  -moz-box-orient: vertical;<br \/>\n  -moz-box-align: stretch;<br \/>\n  display: box;<br \/>\n  box-orient: vertical;<br \/>\n  box-align: stretch;<br \/>\n  \/* Modern browsers *\/<br \/>\n  display: flex;<br \/>\n  flex-direction: column;<br \/>\n  align-items: stretch;<br \/>\n  \/* Old browsers *\/<br \/>\n  -webkit-box-flex: 1;<br \/>\n  -moz-box-flex: 1;<br \/>\n  box-flex: 1;<br \/>\n  \/* Modern browsers *\/<br \/>\n  flex: 1;<br \/>\n}<br \/>\n\/* input_area and input_prompt must match in top border and margin for alignment *\/<br \/>\ndiv.input_area {<br \/>\n  border: 1px solid #cfcfcf;<br \/>\n  border-radius: 2px;<br \/>\n  background: #f7f7f7;<br \/>\n  line-height: 1.21429em;<br \/>\n}<br \/>\n\/* This is needed so that empty prompt areas can collapse to zero height when there<br \/>\n   is no content in the output_subarea and the prompt. The main purpose of this is<br \/>\n   to make sure that empty JavaScript output_subareas have no height. *\/<br \/>\ndiv.prompt:empty {<br \/>\n  padding-top: 0;<br \/>\n  padding-bottom: 0;<br \/>\n}<br \/>\ndiv.code_cell {<br \/>\n  \/* avoid page breaking on code cells when printing *\/<br \/>\n}<br \/>\n@media print {<br \/>\n  div.code_cell {<br \/>\n    page-break-inside: avoid;<br \/>\n  }<br \/>\n}<br \/>\n\/* any special styling for code cells that are currently running goes here *\/<br \/>\ndiv.input {<br \/>\n  page-break-inside: avoid;<br \/>\n  \/* Old browsers *\/<br \/>\n  display: -webkit-box;<br \/>\n  -webkit-box-orient: horizontal;<br \/>\n  -webkit-box-align: stretch;<br \/>\n  display: -moz-box;<br \/>\n  -moz-box-orient: horizontal;<br \/>\n  -moz-box-align: stretch;<br \/>\n  display: box;<br \/>\n  box-orient: horizontal;<br \/>\n  box-align: stretch;<br \/>\n  \/* Modern browsers *\/<br \/>\n  display: flex;<br \/>\n  flex-direction: row;<br \/>\n  align-items: stretch;<br \/>\n}<br \/>\n@media (max-width: 540px) {<br \/>\n  div.input {<br \/>\n    \/* Old browsers *\/<br \/>\n    display: -webkit-box;<br \/>\n    -webkit-box-orient: vertical;<br \/>\n    -webkit-box-align: stretch;<br \/>\n    display: -moz-box;<br \/>\n    -moz-box-orient: vertical;<br \/>\n    -moz-box-align: stretch;<br \/>\n    display: box;<br \/>\n    box-orient: vertical;<br \/>\n    box-align: stretch;<br \/>\n    \/* Modern browsers *\/<br \/>\n    display: flex;<br \/>\n    flex-direction: column;<br \/>\n    align-items: stretch;<br \/>\n  }<br \/>\n}<br \/>\n\/* input_area and input_prompt must match in top border and margin for alignment *\/<br \/>\ndiv.input_prompt {<br \/>\n  color: #303F9F;<br \/>\n  border-top: 1px solid transparent;<br \/>\n}<br \/>\ndiv.input_area > div.highlight {<br \/>\n  margin: 0.4em;<br \/>\n  border: none;<br \/>\n  padding: 0px;<br \/>\n  background-color: transparent;<br \/>\n}<br \/>\ndiv.input_area > div.highlight > pre {<br \/>\n  margin: 0px;<br \/>\n  border: none;<br \/>\n  padding: 0px;<br \/>\n  background-color: transparent;<br \/>\n}<\/p>\n<p>div.output_wrapper {<br \/>\n  \/* this position must be relative to enable descendents to be absolute within it *\/<br \/>\n  position: relative;<br \/>\n  \/* Old browsers *\/<br \/>\n  display: -webkit-box;<br \/>\n  -webkit-box-orient: vertical;<br \/>\n  -webkit-box-align: stretch;<br \/>\n  display: -moz-box;<br \/>\n  -moz-box-orient: vertical;<br \/>\n  -moz-box-align: stretch;<br \/>\n  display: box;<br \/>\n  box-orient: vertical;<br \/>\n  box-align: stretch;<br \/>\n  \/* Modern browsers *\/<br \/>\n  display: flex;<br \/>\n  flex-direction: column;<br \/>\n  align-items: stretch;<br \/>\n  z-index: 1;<br \/>\n}<br \/>\n\/* class for the output area when it should be height-limited *\/<br \/>\n\/* output div while it is collapsed *\/<br \/>\ndiv.output_prompt {<br \/>\n  color: #D84315;<br \/>\n}<br \/>\n\/* This class is the outer container of all output sections. *\/<br \/>\ndiv.output_area {<br \/>\n  padding: 0px;<br \/>\n  page-break-inside: avoid;<br \/>\n  \/* Old browsers *\/<br \/>\n  display: -webkit-box;<br \/>\n  -webkit-box-orient: horizontal;<br \/>\n  -webkit-box-align: stretch;<br \/>\n  display: -moz-box;<br \/>\n  -moz-box-orient: horizontal;<br \/>\n  -moz-box-align: stretch;<br \/>\n  display: box;<br \/>\n  box-orient: horizontal;<br \/>\n  box-align: stretch;<br \/>\n  \/* Modern browsers *\/<br \/>\n  display: flex;<br \/>\n  flex-direction: row;<br \/>\n  align-items: stretch;<br \/>\n}<br \/>\ndiv.output_area .rendered_html table {<br \/>\n  margin-left: 0;<br \/>\n  margin-right: 0;<br \/>\n}<br \/>\n\/* This is needed to protect the pre formating from global settings such<br \/>\n   as that of bootstrap *\/<br \/>\n.output {<br \/>\n  \/* Old browsers *\/<br \/>\n  display: -webkit-box;<br \/>\n  -webkit-box-orient: vertical;<br \/>\n  -webkit-box-align: stretch;<br \/>\n  display: -moz-box;<br \/>\n  -moz-box-orient: vertical;<br \/>\n  -moz-box-align: stretch;<br \/>\n  display: box;<br \/>\n  box-orient: vertical;<br \/>\n  box-align: stretch;<br \/>\n  \/* Modern browsers *\/<br \/>\n  display: flex;<br \/>\n  flex-direction: column;<br \/>\n  align-items: stretch;<br \/>\n}<br \/>\n@media (max-width: 540px) {<br \/>\n  div.output_area {<br \/>\n    \/* Old browsers *\/<br \/>\n    display: -webkit-box;<br \/>\n    -webkit-box-orient: vertical;<br \/>\n    -webkit-box-align: stretch;<br \/>\n    display: -moz-box;<br \/>\n    -moz-box-orient: vertical;<br \/>\n    -moz-box-align: stretch;<br \/>\n    display: box;<br \/>\n    box-orient: vertical;<br \/>\n    box-align: stretch;<br \/>\n    \/* Modern browsers *\/<br \/>\n    display: flex;<br \/>\n    flex-direction: column;<br \/>\n    align-items: stretch;<br \/>\n  }<br \/>\n}<br \/>\ndiv.output_area pre {<br \/>\n  margin: 0;<br \/>\n  padding: 0;<br \/>\n  border: 0;<br \/>\n  vertical-align: baseline;<br \/>\n  color: black;<br \/>\n  background-color: transparent;<br \/>\n  border-radius: 0;<br \/>\n}<br \/>\n\/* This class is for the output subarea inside the output_area and after<br \/>\n   the prompt div. *\/<br \/>\ndiv.output_subarea {<br \/>\n  overflow-x: auto;<br \/>\n  padding: 0.4em;<br \/>\n  \/* Old browsers *\/<br \/>\n  -webkit-box-flex: 1;<br \/>\n  -moz-box-flex: 1;<br \/>\n  box-flex: 1;<br \/>\n  \/* Modern browsers *\/<br \/>\n  flex: 1;<br \/>\n  max-width: calc(100% - 14ex);<br \/>\n}<br \/>\n\/* The rest of the output_* classes are for special styling of the different<br \/>\n   output types *\/<br \/>\n\/* all text output has this class: *\/<br \/>\ndiv.output_text {<br \/>\n  text-align: left;<br \/>\n  color: #000;<br \/>\n  \/* This has to match that of the the CodeMirror class line-height below *\/<br \/>\n  line-height: 1.21429em;<br \/>\n}<\/p>\n<p>\/* raw_input styles *\/<br \/>\n.rendered_html {<br \/>\n  color: #000;<br \/>\n  \/* any extras will just be numbers: *\/<br \/>\n}<br \/>\n.rendered_html :link {<br \/>\n  text-decoration: underline;<br \/>\n}<br \/>\n.rendered_html :visited {<br \/>\n  text-decoration: underline;<br \/>\n}<br \/>\n.rendered_html h2 {<br \/>\n  font-size: 157.1%;<br \/>\n  margin: 1.27em 0 0 0;<br \/>\n  font-weight: bold;<br \/>\n  line-height: 1.0;<br \/>\n}<br \/>\n.rendered_html h3 {<br \/>\n  font-size: 128.6%;<br \/>\n  margin: 1.55em 0 0 0;<br \/>\n  font-weight: bold;<br \/>\n  line-height: 1.0;<br \/>\n}<br \/>\n.rendered_html h2:first-child {<br \/>\n  margin-top: 0.636em;<br \/>\n}<br \/>\n.rendered_html h3:first-child {<br \/>\n  margin-top: 0.777em;<br \/>\n}<br \/>\n.rendered_html ol {<br \/>\n  list-style: decimal;<br \/>\n  margin: 0em 2em;<br \/>\n  padding-left: 0px;<br \/>\n}<br \/>\n.rendered_html * + ol {<br \/>\n  margin-top: 1em;<br \/>\n}<br \/>\n.rendered_html code {<br \/>\n  border: 0;<br \/>\n  background-color: #fff;<br \/>\n  color: #000;<br \/>\n  font-size: 100%;<br \/>\n  padding: 0px;<br \/>\n}<br \/>\n.rendered_html table {<br \/>\n  margin-left: auto;<br \/>\n  margin-right: auto;<br \/>\n  border: 1px solid black;<br \/>\n  border-collapse: collapse;<br \/>\n}<br \/>\n.rendered_html tr,<br \/>\n.rendered_html th,<br \/>\n.rendered_html td {<br \/>\n  border: 1px solid black;<br \/>\n  border-collapse: collapse;<br \/>\n  margin: 1em 2em;<br \/>\n}<br \/>\n.rendered_html td,<br \/>\n.rendered_html th {<br \/>\n  text-align: left;<br \/>\n  vertical-align: middle;<br \/>\n  padding: 4px;<br \/>\n}<br \/>\n.rendered_html th {<br \/>\n  font-weight: bold;<br \/>\n}<br \/>\n.rendered_html * + table {<br \/>\n  margin-top: 1em;<br \/>\n}<br \/>\n.rendered_html p {<br \/>\n  text-align: left;<br \/>\n}<br \/>\ndiv.text_cell {<br \/>\n  \/* Old browsers *\/<br \/>\n  display: -webkit-box;<br \/>\n  -webkit-box-orient: horizontal;<br \/>\n  -webkit-box-align: stretch;<br \/>\n  display: -moz-box;<br \/>\n  -moz-box-orient: horizontal;<br \/>\n  -moz-box-align: stretch;<br \/>\n  display: box;<br \/>\n  box-orient: horizontal;<br \/>\n  box-align: stretch;<br \/>\n  \/* Modern browsers *\/<br \/>\n  display: flex;<br \/>\n  flex-direction: row;<br \/>\n  align-items: stretch;<br \/>\n}<br \/>\n@media (max-width: 540px) {<br \/>\n  div.text_cell > div.prompt {<br \/>\n    display: none;<br \/>\n  }<br \/>\n}<br \/>\ndiv.text_cell_render {<br \/>\n  \/*font-family: \"Helvetica Neue\", Arial, Helvetica, Geneva, sans-serif;*\/<br \/>\n  outline: none;<br \/>\n  resize: none;<br \/>\n  width: inherit;<br \/>\n  border-style: none;<br \/>\n  padding: 0.5em 0.5em 0.5em 0.4em;<br \/>\n  color: #000;<br \/>\n  box-sizing: border-box;<br \/>\n  -moz-box-sizing: border-box;<br \/>\n  -webkit-box-sizing: border-box;<br \/>\n}<br \/>\na.anchor-link:link {<br \/>\n  text-decoration: none;<br \/>\n  padding: 0px 20px;<br \/>\n  visibility: hidden;<br \/>\n}<br \/>\nh2:hover .anchor-link,<br \/>\nh3:hover .anchor-link {<br \/>\n  visibility: visible;<br \/>\n}<br \/>\n.text_cell.rendered .rendered_html {<br \/>\n  overflow-x: auto;<br \/>\n  overflow-y: hidden;<br \/>\n}<\/p>\n<p>pre,<br \/>\ncode {<br \/>\n  white-space: pre-wrap;<br \/>\n}<br \/>\np {<br \/>\n  margin-bottom: 0;<br \/>\n}<\/style>\n<style type=\"text\/css\">\n.highlight .hll { background-color: #ffffcc }<br \/>\n.highlight  { background: #f8f8f8; } \/* Comment *\/ \/* Error *\/ \/* Keyword *\/<br \/>\n.highlight .o { color: #666666 } \/* Operator *\/ \/* Comment.Hashbang *\/ \/* Comment.Multiline *\/ \/* Comment.Preproc *\/ \/* Comment.PreprocFile *\/ \/* Comment.Single *\/ \/* Comment.Special *\/ \/* Generic.Deleted *\/ \/* Generic.Emph *\/ \/* Generic.Error *\/ \/* Generic.Heading *\/ \/* Generic.Inserted *\/ \/* Generic.Output *\/ \/* Generic.Prompt *\/ \/* Generic.Strong *\/ \/* Generic.Subheading *\/ \/* Generic.Traceback *\/ \/* Keyword.Constant *\/ \/* Keyword.Declaration *\/<br \/>\n.highlight .kn { color: #008000; font-weight: bold } \/* Keyword.Namespace *\/ \/* Keyword.Pseudo *\/ \/* Keyword.Reserved *\/ \/* Keyword.Type *\/ \/* Literal.Number *\/ \/* Literal.String *\/ \/* Name.Attribute *\/ \/* Name.Builtin *\/ \/* Name.Class *\/ \/* Name.Constant *\/ \/* Name.Decorator *\/ \/* Name.Entity *\/ \/* Name.Exception *\/ \/* Name.Function *\/ \/* Name.Label *\/<br \/>\n.highlight .nn { color: #0000FF; font-weight: bold } \/* Name.Namespace *\/ \/* Name.Tag *\/ \/* Name.Variable *\/ \/* Operator.Word *\/ \/* Text.Whitespace *\/ \/* Literal.Number.Bin *\/ \/* Literal.Number.Float *\/ \/* Literal.Number.Hex *\/<br \/>\n.highlight .mi { color: #666666 } \/* Literal.Number.Integer *\/ \/* Literal.Number.Oct *\/ \/* Literal.String.Affix *\/ \/* Literal.String.Backtick *\/ \/* Literal.String.Char *\/ \/* Literal.String.Delimiter *\/ \/* Literal.String.Doc *\/<br \/>\n.highlight .s2 { color: #BA2121 } \/* Literal.String.Double *\/ \/* Literal.String.Escape *\/ \/* Literal.String.Heredoc *\/ \/* Literal.String.Interpol *\/ \/* Literal.String.Other *\/ \/* Literal.String.Regex *\/<br \/>\n.highlight .s1 { color: #BA2121 } \/* Literal.String.Single *\/ \/* Literal.String.Symbol *\/ \/* Name.Builtin.Pseudo *\/ \/* Name.Function.Magic *\/ \/* Name.Variable.Class *\/ \/* Name.Variable.Global *\/ \/* Name.Variable.Instance *\/ \/* Name.Variable.Magic *\/ \/* Literal.Number.Integer.Long *\/<\/style>\n<style type=\"text\/css\">\n\/* Temporary definitions which will become obsolete with Notebook release 5.0 *\/<br \/>\n.ansi-black-fg { color: #3E424D; }<\/style>\n<style type=\"text\/css\">\n.rendered_html ol {<br \/>\n    list-style:decimal;<br \/>\n    margin: 1em 2em;<br \/>\n}<\/p>\n<p>.text_cell, .text_cell_render {<br \/>\n    font-family: \"Charis SIL\", \"Hoefler Text\", Garamond, Palatino, serif;<br \/>\n    font-size: 16px;<br \/>\n    line-height:1.4em;<br \/>\n    padding-left:3em;<br \/>\n    padding-right:3em;<br \/>\n    max-width: 100%;<br \/>\n    text-rendering: optimizeLegibility;<br \/>\n    font-variant-ligatures: contextual no-historical-ligatures common-ligatures;<br \/>\n}<\/p>\n<p>.code_cell {  \/* Area containing both code and output *\/<br \/>\n    font-family: \"Source Code Pro\", \"Droid Sans Mono\", Consolas, \"Ubuntu Mono\", \"Liberation Mono\", monospace;<br \/>\n    background-color:#F8FBF9; \/* light blue *\/<br \/>\n    border-radius: 0.8em;<br \/>\n    padding: 1em;<br \/>\n}<\/p>\n<p>code, pre {<br \/>\n    font-family: \"Source Code Pro\", \"Droid Sans Mono\", Consolas, \"Ubuntu Mono\", \"Liberation Mono\", monospace;<br \/>\n    line-height:1.25em;<br \/>\n    font-size: 16px;<br \/>\n  text-rendering: geometricPrecision;<br \/>\n}<\/p>\n<p>div.prompt {<br \/>\n    font-family: \"Source Code Pro\", \"Droid Sans Mono\", Consolas, \"Ubuntu Mono\", \"Liberation Mono\", monospace;<br \/>\n    font-size: 11px;<br \/>\n}<\/p>\n<p>div.output_area pre {<br \/>\n    font-family: \"Source Code Pro\", \"Droid Sans Mono\", Consolas, \"Ubuntu Mono\", \"Liberation Mono\", monospace;<br \/>\n    line-height:1.25em;<br \/>\n    font-size: 16px;<br \/>\n    background-color: #F8FBF9;<br \/>\n}<\/p>\n<p>.rendered_html h2 {<br \/>\n    font-family: \"Charis SIL\", \"Hoefler Text\", Garamond, Palatino, serif;<br \/>\n    font-size: 23px;<br \/>\n    font-weight: bold;<br \/>\n  margin-top: 0 !important;<br \/>\n    text-rendering: optimizeLegibility;<br \/>\n    font-variant-ligatures: contextual no-historical-ligatures common-ligatures;<br \/>\n}<\/p>\n<p>.rendered_html h3 {<br \/>\n    font-family: \"Charis SIL\", \"Hoefler Text\", Garamond, Palatino, serif;<br \/>\n    font-size: 17px;<br \/>\n    font-weight: bold;<br \/>\n  \/*font-style: italic;*\/<br \/>\n  margin-top: 0 !important;<br \/>\n    text-rendering: optimizeLegibility;<br \/>\n    font-variant-ligatures: contextual no-historical-ligatures common-ligatures;<br \/>\n}<\/p>\n<p>.rendered_html td {<br \/>\n    font-variant-numeric: tabular-nums;<br \/>\n}<\/p>\n<p>\/* Pretty Pandas Dataframes *\/<br \/>\n.dataframe * {border-color: #c0c0c0 !important;}<br \/>\n.dataframe th{background: #eee;}<br \/>\n.dataframe td{<br \/>\n  font-family: \"Source Code Pro\", \"Droid Sans Mono\", Consolas, \"Ubuntu Mono\", \"Liberation Mono\", monospace;<br \/>\n    background: #fff;<br \/>\n    text-align: center !important;<br \/>\n    min-width:5em;<br \/>\n}<\/style>\n<style type=\"text\/css\">\n\/* Overrides of notebook CSS for static HTML export *\/<br \/>\nbody {<br \/>\n  overflow: visible;<br \/>\n  padding: 8px;<br \/>\n}@media print {<br \/>\n  div.cell {<br \/>\n    display: block;<br \/>\n    page-break-inside: avoid;<br \/>\n  }<br \/>\n  div.output_wrapper {<br \/>\n    display: block;<br \/>\n    page-break-inside: avoid;<br \/>\n  }<br \/>\n  div.output {<br \/>\n    display: block;<br \/>\n    page-break-inside: avoid;<br \/>\n  }<br \/>\n}<\/style>\n","protected":false},"excerpt":{"rendered":"<p>Downloading data from the WRDS website is convenient but not the most transparent and replicable as it requires a workflow along the lines of: Create a list of identifiers using your program (i.e. Python) Load the identifiers into the WRDS web interface + make your query Download the resulting data from WRDS into a file [&hellip;]<\/p>\n","protected":false},"author":10,"featured_media":631,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0},"categories":[125],"tags":[4],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.12 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Retrieving data from WRDS directly using Python, R, and Stata - ARC<\/title>\n<meta name=\"robots\" content=\"noindex, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Retrieving data from WRDS directly using Python, R, and Stata - ARC\" \/>\n<meta property=\"og:description\" content=\"Downloading data from the WRDS website is convenient but not the most transparent and replicable as it requires a workflow along the lines of: Create a list of identifiers using your program (i.e. Python) Load the identifiers into the WRDS web interface + make your query Download the resulting data from WRDS into a file [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/eaa-online.org\/arc\/blog\/2018\/02\/08\/retrieving-data-wrds-directly-using-python-r-and-stata\/\" \/>\n<meta property=\"og:site_name\" content=\"ARC\" \/>\n<meta property=\"article:published_time\" content=\"2018-02-08T10:50:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-10-17T13:22:56+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/eaa-online.org\/app\/uploads\/sites\/3\/2018\/02\/bannerimage_narrow.png\" \/>\n\t<meta property=\"og:image:width\" content=\"341\" \/>\n\t<meta property=\"og:image:height\" content=\"235\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Ties de Kok\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ties de Kok\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"12 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/eaa-online.org\/arc\/blog\/2018\/02\/08\/retrieving-data-wrds-directly-using-python-r-and-stata\/\",\"url\":\"https:\/\/eaa-online.org\/arc\/blog\/2018\/02\/08\/retrieving-data-wrds-directly-using-python-r-and-stata\/\",\"name\":\"Retrieving data from WRDS directly using Python, R, and Stata - ARC\",\"isPartOf\":{\"@id\":\"https:\/\/eaa-online.org\/arc\/#website\"},\"datePublished\":\"2018-02-08T10:50:00+00:00\",\"dateModified\":\"2022-10-17T13:22:56+00:00\",\"author\":{\"@id\":\"https:\/\/eaa-online.org\/arc\/#\/schema\/person\/22bbbc46473ac498a1a1015c02482474\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/eaa-online.org\/arc\/blog\/2018\/02\/08\/retrieving-data-wrds-directly-using-python-r-and-stata\/\"]}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/eaa-online.org\/arc\/#website\",\"url\":\"https:\/\/eaa-online.org\/arc\/\",\"name\":\"ARC\",\"description\":\"Advanced Resources Center\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/eaa-online.org\/arc\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/eaa-online.org\/arc\/#\/schema\/person\/22bbbc46473ac498a1a1015c02482474\",\"name\":\"Ties de Kok\",\"sameAs\":[\"https:\/\/www.tiesdekok.com\"],\"url\":\"https:\/\/eaa-online.org\/arc\/blog\/members\/10\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Retrieving data from WRDS directly using Python, R, and Stata - ARC","robots":{"index":"noindex","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"og_locale":"en_US","og_type":"article","og_title":"Retrieving data from WRDS directly using Python, R, and Stata - ARC","og_description":"Downloading data from the WRDS website is convenient but not the most transparent and replicable as it requires a workflow along the lines of: Create a list of identifiers using your program (i.e. Python) Load the identifiers into the WRDS web interface + make your query Download the resulting data from WRDS into a file [&hellip;]","og_url":"https:\/\/eaa-online.org\/arc\/blog\/2018\/02\/08\/retrieving-data-wrds-directly-using-python-r-and-stata\/","og_site_name":"ARC","article_published_time":"2018-02-08T10:50:00+00:00","article_modified_time":"2022-10-17T13:22:56+00:00","og_image":[{"width":341,"height":235,"url":"https:\/\/eaa-online.org\/app\/uploads\/sites\/3\/2018\/02\/bannerimage_narrow.png","type":"image\/png"}],"author":"Ties de Kok","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Ties de Kok","Est. reading time":"12 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/eaa-online.org\/arc\/blog\/2018\/02\/08\/retrieving-data-wrds-directly-using-python-r-and-stata\/","url":"https:\/\/eaa-online.org\/arc\/blog\/2018\/02\/08\/retrieving-data-wrds-directly-using-python-r-and-stata\/","name":"Retrieving data from WRDS directly using Python, R, and Stata - ARC","isPartOf":{"@id":"https:\/\/eaa-online.org\/arc\/#website"},"datePublished":"2018-02-08T10:50:00+00:00","dateModified":"2022-10-17T13:22:56+00:00","author":{"@id":"https:\/\/eaa-online.org\/arc\/#\/schema\/person\/22bbbc46473ac498a1a1015c02482474"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/eaa-online.org\/arc\/blog\/2018\/02\/08\/retrieving-data-wrds-directly-using-python-r-and-stata\/"]}]},{"@type":"WebSite","@id":"https:\/\/eaa-online.org\/arc\/#website","url":"https:\/\/eaa-online.org\/arc\/","name":"ARC","description":"Advanced Resources Center","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/eaa-online.org\/arc\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/eaa-online.org\/arc\/#\/schema\/person\/22bbbc46473ac498a1a1015c02482474","name":"Ties de Kok","sameAs":["https:\/\/www.tiesdekok.com"],"url":"https:\/\/eaa-online.org\/arc\/blog\/members\/10\/"}]}},"jetpack_featured_media_url":"https:\/\/eaa-online.org\/app\/uploads\/sites\/3\/2018\/02\/bannerimage_narrow.png","_links":{"self":[{"href":"https:\/\/eaa-online.org\/arc\/wp-json\/wp\/v2\/posts\/630"}],"collection":[{"href":"https:\/\/eaa-online.org\/arc\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eaa-online.org\/arc\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eaa-online.org\/arc\/wp-json\/wp\/v2\/users\/10"}],"replies":[{"embeddable":true,"href":"https:\/\/eaa-online.org\/arc\/wp-json\/wp\/v2\/comments?post=630"}],"version-history":[{"count":1,"href":"https:\/\/eaa-online.org\/arc\/wp-json\/wp\/v2\/posts\/630\/revisions"}],"predecessor-version":[{"id":3963,"href":"https:\/\/eaa-online.org\/arc\/wp-json\/wp\/v2\/posts\/630\/revisions\/3963"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/eaa-online.org\/arc\/wp-json\/wp\/v2\/media\/631"}],"wp:attachment":[{"href":"https:\/\/eaa-online.org\/arc\/wp-json\/wp\/v2\/media?parent=630"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eaa-online.org\/arc\/wp-json\/wp\/v2\/categories?post=630"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eaa-online.org\/arc\/wp-json\/wp\/v2\/tags?post=630"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}