Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python2.7 and encoding of city names #17

Open
dhhagan opened this issue Feb 3, 2017 · 9 comments
Open

Python2.7 and encoding of city names #17

dhhagan opened this issue Feb 3, 2017 · 9 comments
Assignees

Comments

@dhhagan
Copy link
Owner

dhhagan commented Feb 3, 2017

Seems to be something wonky with v1.0.0 and python2.7 (look at cities in Chile)

@dhhagan dhhagan added the bug label Feb 3, 2017
@dhhagan dhhagan self-assigned this Feb 3, 2017
@sergiolucero
Copy link

David: this does NOT generate problems with 2.7

`from openaq import OpenAQ
coldict = {'coordinates.latitude':'lat', 'coordinates.longitude': 'lon'}
api = OpenAQ()

df = api.measurements(country='CL', limit=10000, df=True).rename(columns=coldict)
out = {};stats = {}

for loc, data in df.groupby(['city', 'location', 'parameter']):
data = data.resample('1h').mean()
out[loc] = data
stats[loc] = (len(data), min(data.value), max(data.value))`

@dhhagan
Copy link
Owner Author

dhhagan commented Feb 7, 2017

@sergiolucero Interesting. Can you provide me with an example where it does fail to properly encode them?

@sergiolucero
Copy link

sergiolucero commented Feb 7, 2017

This will produce an error when the location has an accent (Estación Centro):

from openaq import OpenAQ
api=OpenAQ()
df=api.measurements(country='CL',city='Calama',df=True,limit=100)
for loc, data in df.groupby(['city','location']):
print loc
dfloc = api.latest(city=loc[0],location=loc[1])

@dhhagan
Copy link
Owner Author

dhhagan commented Feb 7, 2017

Ahh okay. So the first one didn't raise an error just by chance...since there were no accented cities?

@sergiolucero
Copy link

No, somehow requesting again exposes the encoding problem?

@dhhagan
Copy link
Owner Author

dhhagan commented Feb 7, 2017

Hmm. Okay. That seems like it's probably on the end of the OpenAQ API then?

@dolugen
Copy link

dolugen commented Sep 29, 2017

@dhhagan It's a known issue on the API, see openaq/openaq-api#275

@dhhagan
Copy link
Owner Author

dhhagan commented Sep 29, 2017

@dolugen Ahh good to know. I began to make a spreadsheet of all the offending instances, but once it reached a few hundred I gave up :/ It would certainly be nice to fix though! Hopefully, someone has time to tackle it this October.

@jflasher
Copy link

I'm not sure if this'll be fixed in OpenAQ. Looking over the issue history, looks like it's an issue with the source. So if we're getting bad characters from the source, I think we're just capturing them. Maybe we could always check for UTF-8 and discard items that don't pass?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants