def resample(self, rule: Union[str, int] = "1s") -> "Flight":
        """Resamples a Flight at a one point per second rate."""

        if isinstance(rule, str):
            data = (
                self._handle_last_position()
                .data.assign(start=self.start, stop=self.stop)
                .set_index("timestamp")
                .resample(rule)
                .first()  # better performance than min() for duplicate index
                .interpolate()
                .reset_index()
                .fillna(method="pad")
            )
        elif isinstance(rule, int):
            data = (
                self._handle_last_position()
                .data.set_index("timestamp")
                .asfreq(
                    (self.stop - self.start) / (rule - 1),  # type: ignore
                    method="nearest",
                )
                .reset_index()
            )
        else:
            raise TypeError("rule must be a str or an int")

        return self.__class__(data)
def resample ( self , rule : Union [ str , int ] = "1s" ) -> "Flight" : if isinstance ( rule , str ) : data = ( self . _handle_last_position ( ) . data . assign ( start = self . start , stop = self . stop ) . set_index ( "timestamp" ) . resample ( rule ) . first ( ) . interpolate ( ) . reset_index ( ) . fillna ( method = "pad" ) ) elif isinstance ( rule , int ) : data = ( self . _handle_last_position ( ) . data . set_index ( "timestamp" ) . asfreq ( ( self . stop - self . start ) / ( rule - 1 ) , method = "nearest" , ) . reset_index ( ) ) else : raise TypeError ( "rule must be a str or an int" ) return self . __class__ ( data )
Resamples a Flight at a one point per second rate.