50-state polls coming soon, only with ?state=US

78 views
Skip to first unread message

Adam Hooper

unread,
Oct 20, 2016, 3:38:08 PM10/20/16
to pollste...@googlegroups.com
This applies to API users who request GET /api/polls?state=... (as JSON or XML).

Some tracker polls are conducted across all states. This year, we are going to publish one "poll" on Pollster for each poll the (lowercase-p) pollster publishes.

We will begin doing this for UPI/CVoter, Ipsos/Reuters, SurveyMonkey, and any other pollsters that send us multiple state surveys in one release. This will apply to the presidential race and senate races.

You'll see these 50-state polls when you make an API request with the ?state=US query parameter, as in: GET /api/polls?state=US. You will not see these 50-state polls when you use individual states' codes -- for instance, GET /api/polls?state=NY.

A reminder: most users don't need the ?state= query parameter in the first place. The ?question= query parameter is the correct way to track specific presidential or senate races. (After the election, don't be surprised if we deprecate and then remove the ?state= query parameter altogether.)

Enjoy life,
Adam

rgo

unread,
Oct 25, 2016, 5:10:58 PM10/25/16
to pollster-users
Augh! When I request

    chart = huffpost_pollster.chart("2016-arizona-president-trump-vs-clinton")
    polls = chart.polls()
    
using the Python API, I expect to see questions only relating to Arizona. Instead, I get questions from every state chart.

Am I crazy or did you deploy this breaking change 2 weeks before the election?

Adam Hooper

unread,
Oct 25, 2016, 5:31:09 PM10/25/16
to rgo, pollster-users
Er, is there a breaking change in here? I don't see it.

The chart.polls() endpoint has always returned a bucketload of poll "questions", most of which don't relate to the chart in question. In Python, the best way to filter questions is by chart:

>>> import pollster
>>> api = pollster.Pollster()
>>> chart = api.chart('2016-arizona-president-trump-vs-clinton')
>>> poll0_questions = [q for q in polls[0].questions if q['chart'] == '2016-arizona-president-trump-vs-clinton']
>>> poll0_questions
[{'chart': '2016-arizona-president-trump-vs-clinton', 'name': '2016 Arizona President: Trump vs. Clinton', 'code': '16-AZ-Pres-GE TrumpvClinton', 'topic': '2016-president', 'subpopulations': [{'margin_of_error': None, 'name': 'Likely Voters', 'observations': 410, 'responses': [{'value': 40.0, 'first_name': 'Hillary', 'incumbent': False, 'choice': 'Clinton', 'last_name': 'Clinton', 'party': 'Dem'}, {'value': 41.0, 'first_name': 'Donald', 'incumbent': False, 'choice': 'Trump', 'last_name': 'Trump', 'party': 'Rep'}, {'value': 13.0, 'first_name': 'Gary', 'incumbent': False, 'choice': 'Johnson', 'last_name': 'Johnson', 'party': 'Lib'}, {'value': 4.0, 'first_name': None, 'incumbent': None, 'choice': 'Stein', 'last_name': None, 'party': None}, {'value': 2.0, 'first_name': None, 'incumbent': None, 'choice': 'No answer', 'last_name': None, 'party': None}]}], 'state': 'AZ'}]

If your code hasn't been filtering polls up until now, I'm not sure it's been doing what you hoped. If you've been filtering questions by responses (e.g., "Trump" and "Clinton"), for instance, your code has picked up duplicate questions from pollsters who ask, "Trump v Clinton" and then ask, "Trump v Clinton v Johnson" immediately after.

By the way: the best way of filtering poll questions is using the 'code' ('16-AZ-Pres-GE TrumpvClinton' in this chart). But we haven't been pushing users to adopt that API yet because we're in the lead-up to the election. (We don't publish a comprehensive list of "code"s yet.) We've informally committed to not show the same poll question on two charts -- at least, poll questions that relate to presidential and senate elections.

Enjoy life,
Adam

--
You received this message because you are subscribed to the Google Groups "pollster-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pollster-user...@googlegroups.com.
To post to this group, send email to pollste...@googlegroups.com.
Visit this group at https://groups.google.com/group/pollster-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/pollster-users/7c4cf85a-3337-4aa8-b7ca-ac1cd83ccb55%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

rgo

unread,
Oct 25, 2016, 5:37:54 PM10/25/16
to pollster-users
Thanks.

It broke my model since I've been filtering questions by taking the one that has the most responses given that it has at least Trump and Clinton (so it prefers Trump/Clinton/Johnson to Trump/Clinton, for example.) Previously, all questions did "relate" to the chart in that the '2016-arizona-president-trump-vs-clinton' chart only had questions about Arizona that included Trump and Clinton.

rgo

unread,
Oct 25, 2016, 5:39:16 PM10/25/16
to pollster-users
By "responses" I mean possible responses to the question.

Thanks again for your prompt help.

Adam Hooper

unread,
Oct 25, 2016, 5:47:57 PM10/25/16
to rgo, pollster-users
On Tue, Oct 25, 2016 at 5:37 PM rgo <ost...@gmail.com> wrote:
Thanks.

It broke my model since I've been filtering questions by taking the one that has the most responses given that it has at least Trump and Clinton (so it prefers Trump/Clinton/Johnson to Trump/Clinton, for example.) Previously, all questions did "relate" to the chart in that the '2016-arizona-president-trump-vs-clintonchart only had questions about Arizona that included Trump and Clinton.

Ah, my guess was close.

I hope you don't take offense at this "change". We can't predict the assumptions our users will make about the data our API returns -- and indeed, in this case, that assumption was incorrect.

And perhaps I can spot another incorrect assumption. Did you know that some polls that include Johnson don't appear on the 2016-arizona-president-trump-vs-clinton chart?

Assuming you want those poll responses, too, you should be using the API like this:

1. Download all polls for 
2016-arizona-president-trump-vs-clinton-vs-johnson. Maintain a Set of all the poll IDs you've seen, and extract the relevant poll questions (filtering by question.chart).
2. Download all polls for 2016-arizona-president-trump-vs-clinton. Filter out all the poll IDs you've seen (from the Set in step 1), and extract the relevant poll questions (filtering by question.chart).

Enjoy life,
Adam

rgo

unread,
Oct 25, 2016, 5:52:16 PM10/25/16
to pollster-users
Oh, and topic=2016-president.

No offense about the change. Though I don't quite with your sentiment that "we can't predict the assumptions our users will make..." I strongly believe that it's the job of the API documentation to make this unambiguous. 

Natalie Jackson

unread,
Oct 25, 2016, 5:59:36 PM10/25/16
to rgo, pollster-users
Hi,

I'm in charge of the Pollster site, and I would just like to point out that we are providing the data for free. Adam has been very kind to help with your code. Our obligation is to HuffPost readers first and foremost. We provide the data as a secondary service and try to be very accommodating -- but we cannot anticipate every problem for users. We have to do what works on our end. 

Thanks,
Natalie

--
You received this message because you are subscribed to the Google Groups "pollster-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pollster-users+unsubscribe@googlegroups.com.
To post to this group, send email to pollster-users@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Natalie M. Jackson, PhD
Senior Polling Editor, The Huffington Post/Pollster.com
Twitter: @nataliemjb

rgo

unread,
Oct 25, 2016, 6:15:01 PM10/25/16
to pollster-users
Hi Natalie,

Absolutely, I can't tell you how much I appreciate the service. I don't expect 24/7 (or any!) support, and Adam has been incredibly gracious to help me out. HuffPost is obviously not an open-source company and there's no reasonable expectation of stability.

My previous comment was more philosophical than anything. Given that you did write API documentation, I felt justified in my expectation that it explained the behavior of the API. (Though I wouldn't be justified in expecting you to write it in the first place.)

Cheers,
Robbie


On Tuesday, October 25, 2016 at 5:59:36 PM UTC-4, natalie.jackson wrote:
Hi,

I'm in charge of the Pollster site, and I would just like to point out that we are providing the data for free. Adam has been very kind to help with your code. Our obligation is to HuffPost readers first and foremost. We provide the data as a secondary service and try to be very accommodating -- but we cannot anticipate every problem for users. We have to do what works on our end. 

Thanks,
Natalie
On Tue, Oct 25, 2016 at 5:52 PM, rgo <ost...@gmail.com> wrote:
Oh, and topic=2016-president.

No offense about the change. Though I don't quite with your sentiment that "we can't predict the assumptions our users will make..." I strongly believe that it's the job of the API documentation to make this unambiguous. 

On Tuesday, October 25, 2016 at 5:47:57 PM UTC-4, adam.hooper wrote:
On Tue, Oct 25, 2016 at 5:37 PM rgo <ost...@gmail.com> wrote:
Thanks.

It broke my model since I've been filtering questions by taking the one that has the most responses given that it has at least Trump and Clinton (so it prefers Trump/Clinton/Johnson to Trump/Clinton, for example.) Previously, all questions did "relate" to the chart in that the '2016-arizona-president-trump-vs-clintonchart only had questions about Arizona that included Trump and Clinton.

Ah, my guess was close.

I hope you don't take offense at this "change". We can't predict the assumptions our users will make about the data our API returns -- and indeed, in this case, that assumption was incorrect.

And perhaps I can spot another incorrect assumption. Did you know that some polls that include Johnson don't appear on the 2016-arizona-president-trump-vs-clinton chart?

Assuming you want those poll responses, too, you should be using the API like this:

1. Download all polls for 
2016-arizona-president-trump-vs-clinton-vs-johnson. Maintain a Set of all the poll IDs you've seen, and extract the relevant poll questions (filtering by question.chart).
2. Download all polls for 2016-arizona-president-trump-vs-clinton. Filter out all the poll IDs you've seen (from the Set in step 1), and extract the relevant poll questions (filtering by question.chart).

Enjoy life,
Adam

--
You received this message because you are subscribed to the Google Groups "pollster-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pollster-user...@googlegroups.com.
To post to this group, send email to pollste...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages