from datetime import datetime
import pytz


def ns_to_datetime(ns):
    """
    Converts nanoseconds to a datetime object (UTC)

    Parameters
    ----------
    ns : int
        nanoseconds since epoch

    Returns
    -------
    nanoseconds since epoch as a datetime object : datetime

    """
    dt = datetime.utcfromtimestamp(ns / 1e9)
    return dt.replace(tzinfo=pytz.utc)