def as_pd_freq(freq):
    """Convert frequency expressed in Hz to pandas-compatible frequency.

    When pandas says they want frequency, what they're actually asking for
    is period, which is stupid and confusing. This method converts a
    frequency expressed in Hz to its equivalent pandas frequency, aka its
    period in microseconds. WARNING: Don't use this with data sampled at
    >1MHz, since this will run into precision errors!

    Args:
        freq (float): data series frequency (in Hz), <1e6

    Returns:
        str pandas frequency corresponding to freq

    Raises:
        ValueError if freq is >1e6
    """
    if freq > 1e6:
        raise ValueError('Specified frequency is too high for this method',
                         'and will result in catastrophic precision loss.')

    freq_pd = int(1e6 / freq)
    freq_pd_str = str(freq_pd) + 'U'
    return freq_pd_str