# Path: openaq/utils.py
# def to_naive_timestamp(timestamp):
#     """
#         Convert a timezone aware timestamp (as a string) and return the
#         python datetime in the local timezone, but without the tzinfo attribute
#     """
#     return dateutil.parser.parse(timestamp).replace(tzinfo=None).isoformat()
# 
# def clean_encodings(unit):
#     if unit not in ('ppm', 'ppb', 'ppt', 'ugm3'):
#         unit = unit.encode('utf-8')
# 
#         if unit == '\xc2\xb5g/m\xc2\xb3':
#             unit = 'ugm3'
# 
#     return unit


from functools import wraps
from unittest import SkipTest
from .utils import to_naive_timestamp, clean_encodings
import warnings
    import pandas as pd
        def decorated_function(*args, **kwargs):
            df = kwargs.pop('df', False)
            index = kwargs.pop('index', 'local')

            if df == True and _no_pandas == False:
                status, resp = f(*args, **kwargs)

                if status == 200:
                    resp = resp['results']

                    if f.__name__ == 'latest':
                        d = []
                        for i in resp:
                            for m in i['measurements']:
                                tmp = m
                                tmp['country'] = i['country']
                                tmp['city'] = i['city']
                                tmp['location'] = i['location']

                                tmp['lastUpdated'] = pd.to_datetime(tmp['lastUpdated'])

                                d.append(tmp)

                            resp = d

                    data = pd.io.json.json_normalize(resp)

                    # If there are any datetimes, make them datetimes!
                    for each in [i for i in data.columns if 'date' in i]:
                        if 'local' in each:

# Path: openaq/utils.py
# def to_naive_timestamp(timestamp):
#     """
#         Convert a timezone aware timestamp (as a string) and return the
#         python datetime in the local timezone, but without the tzinfo attribute
#     """
#     return dateutil.parser.parse(timestamp).replace(tzinfo=None).isoformat()
# 
# def clean_encodings(unit):
#     if unit not in ('ppm', 'ppb', 'ppt', 'ugm3'):
#         unit = unit.encode('utf-8')
# 
#         if unit == '\xc2\xb5g/m\xc2\xb3':
#             unit = 'ugm3'
# 
#     return unit


# Path: openaq/decorators.py
from functools import wraps
from unittest import SkipTest
from .utils import to_naive_timestamp, clean_encodings
import warnings
    import pandas as pd

        def decorated_function(*args, **kwargs):
            df = kwargs.pop('df', False)
            index = kwargs.pop('index', 'local')

            if df == True and _no_pandas == False:
                status, resp = f(*args, **kwargs)

                if status == 200:
                    resp = resp['results']

                    if f.__name__ == 'latest':
                        d = []
                        for i in resp:
                            for m in i['measurements']:
                                tmp = m
                                tmp['country'] = i['country']
                                tmp['city'] = i['city']
                                tmp['location'] = i['location']

                                tmp['lastUpdated'] = pd.to_datetime(tmp['lastUpdated'])

                                d.append(tmp)

                            resp = d

                    data = pd.io.json.json_normalize(resp)

                    # If there are any datetimes, make them datetimes!
                    for each in [i for i in data.columns if 'date' in i]:
                        if 'local' in each:

                            data[each] = pd.to_datetime(data[each].apply(lambda x: to_naive_timestamp(x)))