src/tropycal/tracks/season.py
def to_dataframe(self):
        
        r"""
        Converts the season dict into a pandas DataFrame object.
        
        Returns
        -------
        `pandas.DataFrame`
            A pandas DataFrame object containing information about the season.
        """
        
        #Try importing pandas
        try:
            import pandas as pd
        except ImportError as e:
            raise RuntimeError("Error: pandas is not available. Install pandas in order to use this function.") from e
        
        #Get season info
        season_info = self.summary()
        season_info_keys = season_info['id']
        
        #Set up empty dict for dataframe
        ds = {'id':[],'name':[],'vmax':[],'mslp':[],'category':[],'ace':[],'start_time':[],'end_time':[],'start_lat':[],'start_lon':[]}
        
        #Add every key containing a list into the dict
        keys = [k for k in self.dict.keys()]
        for key in keys:
            #Get tropical duration
            temp_type = np.array(self.dict[key]['type'])
            tropical_idx = np.where((temp_type == 'SS') | (temp_type == 'SD') | (temp_type == 'TD') | (temp_type == 'TS') | (temp_type == 'HU'))
            if key in season_info_keys:
                sidx = season_info_keys.index(key)
                ds['id'].append(key)
                ds['name'].append(self.dict[key]['name'])
                ds['vmax'].append(season_info['max_wspd'][sidx])
                ds['mslp'].append(season_info['min_mslp'][sidx])
                ds['category'].append(season_info['category'][sidx])
                ds['start_time'].append(np.array(self.dict[key]['date'])[tropical_idx][0])
                ds['end_time'].append(np.array(self.dict[key]['date'])[tropical_idx][-1])
                ds['start_lat'].append(np.array(self.dict[key]['lat'])[tropical_idx][0])
                ds['start_lon'].append(np.array(self.dict[key]['lon'])[tropical_idx][0])
                ds['ace'].append(np.round(season_info['ace'][sidx],1))
                    
        #Convert entire dict to a DataFrame
        ds = pd.DataFrame(ds)

        #Return dataset
        return ds
r"""
        Converts the season dict into a pandas DataFrame object.
        
        Returns
        -------
        `pandas.DataFrame`
            A pandas DataFrame object containing information about the season.
        
r"""
Converts the season dict into a pandas DataFrame object.

Returns

`pandas.DataFrame`
A pandas DataFrame object containing information about the season.
r " " " Converts the season dict into a pandas DataFrame object . Returns ` pandas . DataFrame ` A pandas DataFrame object containing information about the season .
def to_dataframe(self):
        try:
            import pandas as pd
        except ImportError as e:
            raise RuntimeError("Error: pandas is not available. Install pandas in order to use this function.") from e
        season_info = self.summary()
        season_info_keys = season_info['id']
        ds = {'id':[],'name':[],'vmax':[],'mslp':[],'category':[],'ace':[],'start_time':[],'end_time':[],'start_lat':[],'start_lon':[]}
        keys = [k for k in self.dict.keys()]
        for key in keys:
            temp_type = np.array(self.dict[key]['type'])
            tropical_idx = np.where((temp_type == 'SS') | (temp_type == 'SD') | (temp_type == 'TD') | (temp_type == 'TS') | (temp_type == 'HU'))
            if key in season_info_keys:
                sidx = season_info_keys.index(key)
                ds['id'].append(key)
                ds['name'].append(self.dict[key]['name'])
                ds['vmax'].append(season_info['max_wspd'][sidx])
                ds['mslp'].append(season_info['min_mslp'][sidx])
                ds['category'].append(season_info['category'][sidx])
                ds['start_time'].append(np.array(self.dict[key]['date'])[tropical_idx][0])
                ds['end_time'].append(np.array(self.dict[key]['date'])[tropical_idx][-1])
                ds['start_lat'].append(np.array(self.dict[key]['lat'])[tropical_idx][0])
                ds['start_lon'].append(np.array(self.dict[key]['lon'])[tropical_idx][0])
                ds['ace'].append(np.round(season_info['ace'][sidx],1))
        ds = pd.DataFrame(ds)
        return ds
def to_dataframe ( self ) : try : import pandas as pd except ImportError as e : raise RuntimeError ( "Error: pandas is not available. Install pandas in order to use this function." ) from e season_info = self . summary ( ) season_info_keys = season_info [ 'id' ] ds = { 'id' : [ ] , 'name' : [ ] , 'vmax' : [ ] , 'mslp' : [ ] , 'category' : [ ] , 'ace' : [ ] , 'start_time' : [ ] , 'end_time' : [ ] , 'start_lat' : [ ] , 'start_lon' : [ ] } keys = [ k for k in self . dict . keys ( ) ] for key in keys : temp_type = np . array ( self . dict [ key ] [ 'type' ] ) tropical_idx = np . where ( ( temp_type == 'SS' ) | ( temp_type == 'SD' ) | ( temp_type == 'TD' ) | ( temp_type == 'TS' ) | ( temp_type == 'HU' ) ) if key in season_info_keys : sidx = season_info_keys . index ( key ) ds [ 'id' ] . append ( key ) ds [ 'name' ] . append ( self . dict [ key ] [ 'name' ] ) ds [ 'vmax' ] . append ( season_info [ 'max_wspd' ] [ sidx ] ) ds [ 'mslp' ] . append ( season_info [ 'min_mslp' ] [ sidx ] ) ds [ 'category' ] . append ( season_info [ 'category' ] [ sidx ] ) ds [ 'start_time' ] . append ( np . array ( self . dict [ key ] [ 'date' ] ) [ tropical_idx ] [ 0 ] ) ds [ 'end_time' ] . append ( np . array ( self . dict [ key ] [ 'date' ] ) [ tropical_idx ] [ - 1 ] ) ds [ 'start_lat' ] . append ( np . array ( self . dict [ key ] [ 'lat' ] ) [ tropical_idx ] [ 0 ] ) ds [ 'start_lon' ] . append ( np . array ( self . dict [ key ] [ 'lon' ] ) [ tropical_idx ] [ 0 ] ) ds [ 'ace' ] . append ( np . round ( season_info [ 'ace' ] [ sidx ] , 1 ) ) ds = pd . DataFrame ( ds ) return ds
r"""
Converts the season dict into a pandas DataFrame object.
r " " " Converts the season dict into a pandas DataFrame object .
r"""
        Converts the season dict into a pandas DataFrame object.
        
        Returns
        -------
        `pandas.DataFrame`
            A pandas DataFrame object containing information about the season.
        """ #Try importing pandas #Get season info #Set up empty dict for dataframe #Add every key containing a list into the dict #Get tropical duration #Convert entire dict to a DataFrame #Return dataset
self