This method returns the number of #taps divided by the test duration

            :param data_frame: the data frame
            :type data_frame: pandas.DataFrame
            :return frequency: frequency
            :rtype frequency: float
341844
def frequency(self, data_frame):
        
        freq = sum(data_frame.action_type == 1) / data_frame.td[-1]
        duration = math.ceil(data_frame.td[-1])

        return freq, duration
841319
def histogram_hour_counts(
    df,
    variable
    ):
    
    if not df.index.dtype in ["datetime64[ns]", "<M8[ns]", ">M8[ns]"]:
        log.error("index is not datetime")
        return False
    counts = df.groupby(df.index.hour)[variable].count()
    counts.plot(kind = "bar", width = 1, rot = 0, alpha = 0.7)
753720
def _iter_frequencies(self):
        
        # work out how many frequencies we need
        minf, maxf = self.frange
        fcum_mismatch = log(maxf / minf) * (2 + self.q**2)**(1/2.) / 2.
        nfreq = int(max(1, ceil(fcum_mismatch / self.deltam)))
        fstep = fcum_mismatch / nfreq
        fstepmin = 1 / self.duration
        # for each frequency, yield a QTile
        for i in xrange(nfreq):
            yield (minf *
                   exp(2 / (2 + self.q**2)**(1/2.) * (i + .5) * fstep) //
                   fstepmin * fstepmin)
361150
def timeseries(self, dataframe=False):
        

        self.query.get_cardinality("author_uuid").by_period()
        return super().timeseries(dataframe)
819279
def _check_for_duplicates(durations, events):
        
        # Setting up DataFrame to detect duplicates
        df = pd.DataFrame({"t": durations, "e": events})

        # Finding duplicated event times
        dup_times = df.loc[df["e"] != 0, "t"].duplicated(keep=False)

        # Finding duplicated events and event times
        dup_events = df.loc[df["e"] != 0, ["t", "e"]].duplicated(keep=False)

        # Detect duplicated times with different event types
        return (dup_times & (~dup_events)).any()
1223539
def T(t, step=30):
    
    if hasattr(t, 'timestamp'):
        timestamp = t.timestamp()
    else:
        # python 2
        if t.tzinfo is None:
            timestamp = time.mktime(t.timetuple())
        else:
            utc_naive  = t.replace(tzinfo=None) - t.utcoffset()
            timestamp = (utc_naive - datetime.datetime(1970, 1, 1)).total_seconds()

    return int(timestamp) // step
89509
def get_metadata_freq_df(self, label_append=' freq'):
        '''
        
        '''
        row = self._row_category_ids_for_meta()
        newX = csr_matrix((self._mX.data, (row, self._mX.indices)))
        return self._metadata_freq_df_from_matrix(newX, label_append)
623001
def frequency(self):
        
        freqOptions = ("YEARLY", "MONTHLY", "WEEKLY", "DAILY")
        if self.rule._freq < len(freqOptions):
            return freqOptions[self.rule._freq]
        else:
            return "unsupported_frequency_{}".format(self.rule._freq)
611091
def read_frame_nowait(self) -> Optional[DataFrame]:
        
        try:
            frame = self._data_frames.get_nowait()
        except asyncio.QueueEmpty:
            if self.closed:
                raise StreamConsumedError(self.id)
            return None
        self._data_frames.task_done()
        if frame is None:
            raise StreamConsumedError(self.id)
        return frame
800849
def frame_to_seconds(self, frame_index, sr):
        
        start_sample, end_sample = self.frame_to_sample(frame_index)
        return sample_to_seconds(start_sample, sampling_rate=sr), sample_to_seconds(end_sample, sampling_rate=sr)
1311423
def get_term_category_frequencies(self, scatterchartdata):
		'''
		
		'''

		df = self.term_category_freq_df.rename(
			columns={c: c + ' freq' for c in self.term_category_freq_df}
		)
		df.index.name = 'term'
		return df
857988
def _get_wr(cls, df, n_days):
        
        n_days = int(n_days)
        ln = df['low'].rolling(min_periods=1, window=n_days,
                               center=False).min()

        hn = df['high'].rolling(min_periods=1, window=n_days,
                                center=False).max()
        column_name = 'wr_{}'.format(n_days)
        df[column_name] = (hn - df['close']) / (hn - ln) * 100
233157
def asfreq(self, freq):
        
        frame = self.frame
        if freq == 'B':
            resampled = frame.groupby(frame.index.date).apply(lambda f: f.sum())
            resampled.index = pd.DatetimeIndex([i for i in resampled.index])
            return ProfitAndLossDetails(resampled)
        else:
            resampled = frame.resample(freq, how='sum')
            return ProfitAndLossDetails(resampled)
1323191
def check_ups_input_frequency(the_session, the_helper, the_snmp_value):
    
    a_frequency = calc_frequency_from_snmpvalue(the_snmp_value)
    the_helper.add_metric(
        label=the_helper.options.type,
        value=a_frequency,
        uom='Hz')

    the_helper.set_summary("Input Frequency is {} Hz".format(a_frequency))
1124760
def check_frequencies(
    feed: "Feed", *, as_df: bool = False, include_warnings: bool = False
) -> List:
    
    table = "frequencies"
    problems = []

    # Preliminary checks
    if feed.frequencies is None:
        return problems

    f = feed.frequencies.copy()
    problems = check_for_required_columns(problems, table, f)
    if problems:
        return format_problems(problems, as_df=as_df)

    if include_warnings:
        problems = check_for_invalid_columns(problems, table, f)

    # Check trip_id
    problems = check_column_linked_id(
        problems, table, f, "trip_id", feed.trips
    )

    # Check start_time and end_time
    time_cols = ["start_time", "end_time"]
    for col in time_cols:
        problems = check_column(problems, table, f, col, valid_time)

    for col in time_cols:
        f[col] = f[col].map(hp.timestr_to_seconds)

    # Start_time should be earlier than end_time
    cond = f["start_time"] >= f["end_time"]
    problems = check_table(
        problems, table, f, cond, "start_time not earlier than end_time"
    )

    # Headway periods should not overlap
    f = f.sort_values(["trip_id", "start_time"])
    for __, group in f.groupby("trip_id"):
        a = group["start_time"].values
        b = group["end_time"].values
        indices = np.flatnonzero(a[1:] < b[:-1]).tolist()
        if indices:
            problems.append(
                [
                    "error",
                    "Headway periods for the same trip overlap",
                    table,
                    indices,
                ]
            )

    # Check headway_secs
    v = lambda x: x >= 0
    problems = check_column(problems, table, f, "headway_secs", v)

    # Check exact_times
    v = lambda x: x in range(2)
    problems = check_column(
        problems, table, f, "exact_times", v, column_required=False
    )

    return format_problems(problems, as_df=as_df)
1074637
def get_freq_tuples(my_list, print_total_threshold):
    
    d = {}
    for token in my_list:
        d.setdefault(token, 0)
        d[token] += 1
    return sorted(d.items(), key=operator.itemgetter(1), reverse=True)[:print_total_threshold]
502905
def get_total_term_frequency(self, term):
        
        if term not in self._terms:
            raise IndexError(TERM_DOES_NOT_EXIST)

        return sum(self._terms[term].values())