@@ -744,14 +744,14 @@ def describe(self, years: Tuple[int, ...] = (1, 5, 10), tickers: bool = True) ->
744744 6 Risk 17 years, 10 months 0.037796 0.158301 NaN
745745 7 CVAR 17 years, 10 months 0.023107 0.399398 NaN
746746 """
747- description = pd . DataFrame ()
747+ rows_list = []
748748 dt0 = self .last_date
749749 df = self ._add_inflation ()
750750 # YTD return
751751 ytd_return = self .get_cumulative_return (period = "YTD" )
752752 row = ytd_return .to_dict ()
753753 row .update (period = "YTD" , property = "Compound return" )
754- description = pd . concat ([ description , pd . DataFrame ( row , index = [ 0 ])], ignore_index = True )
754+ rows_list . append ( row )
755755 # CAGR for a list of periods
756756 if self .pl .years >= 1 :
757757 for i in years :
@@ -761,39 +761,39 @@ def describe(self, years: Tuple[int, ...] = (1, 5, 10), tickers: bool = True) ->
761761 else :
762762 row = {x : None for x in df .columns }
763763 row .update (period = f"{ i } years" , property = "CAGR" )
764- description = pd . concat ([ description , pd . DataFrame ( row , index = [ 0 ])], ignore_index = True )
764+ rows_list . append ( row )
765765 # CAGR for full period
766766 row = self .get_cagr (period = None ).to_dict ()
767767 row .update (period = self ._pl_txt , property = "CAGR" )
768- description = pd . concat ([ description , pd . DataFrame ( row , index = [ 0 ])], ignore_index = True )
768+ rows_list . append ( row )
769769 # Mean rate of return (arithmetic mean)
770770 row = self .mean_return .to_dict ()
771771 row .update (
772772 period = self ._pl_txt ,
773773 property = "Annualized mean return" ,
774774 )
775- description = pd . concat ([ description , pd . DataFrame ( row , index = [ 0 ])], ignore_index = True )
775+ rows_list . append ( row )
776776 # Dividend Yield
777777 row = self ._assets_dividend_yield .iloc [- 1 ].to_dict ()
778778 row .update (period = "LTM" , property = "Dividend yield" )
779- description = pd . concat ([ description , pd . DataFrame ( row , index = [ 0 ])], ignore_index = True )
779+ rows_list . append ( row )
780780 # risk for full period
781781 row = self .risk_annual .iloc [- 1 , :].to_dict ()
782782 row .update (period = self ._pl_txt , property = "Risk" )
783- description = pd . concat ([ description , pd . DataFrame ( row , index = [ 0 ])], ignore_index = True )
783+ rows_list . append ( row )
784784 # CVAR
785785 if self .pl .years >= 1 :
786786 row = self .get_cvar_historic ().to_dict ()
787787 row .update (period = self ._pl_txt , property = "CVAR" )
788- description = pd . concat ([ description , pd . DataFrame ( row , index = [ 0 ])], ignore_index = True )
788+ rows_list . append ( row )
789789 # max drawdowns
790790 row = self .drawdowns .min ().to_dict ()
791791 row .update (period = self ._pl_txt , property = "Max drawdowns" )
792- description = pd . concat ([ description , pd . DataFrame ( row , index = [ 0 ])], ignore_index = True )
792+ rows_list . append ( row )
793793 # max drawdowns dates
794794 row = self .drawdowns .idxmin ().to_dict ()
795795 row .update (period = self ._pl_txt , property = "Max drawdowns dates" )
796- description = pd . concat ([ description , pd . DataFrame ( row , index = [ 0 ])], ignore_index = True )
796+ rows_list . append ( row )
797797 # inception dates
798798 row = {}
799799 for ti in self .symbols :
@@ -803,7 +803,7 @@ def describe(self, years: Tuple[int, ...] = (1, 5, 10), tickers: bool = True) ->
803803 row .update (period = None , property = "Inception date" )
804804 if hasattr (self , "inflation" ):
805805 row .update ({self .inflation : self .inflation_first_date .strftime ("%Y-%m" )})
806- description = pd . concat ([ description , pd . DataFrame ( row , index = [ 0 ])], ignore_index = True )
806+ rows_list . append ( row )
807807 # last asset date
808808 row = {}
809809 for ti in self .symbols :
@@ -813,11 +813,13 @@ def describe(self, years: Tuple[int, ...] = (1, 5, 10), tickers: bool = True) ->
813813 row .update (period = None , property = "Last asset date" )
814814 if hasattr (self , "inflation" ):
815815 row .update ({self .inflation : self .inflation_last_date .strftime ("%Y-%m" )})
816- description = pd . concat ([ description , pd . DataFrame ( row , index = [ 0 ])], ignore_index = True )
816+ rows_list . append ( row )
817817 # last data date
818818 row = {x : self .last_date .strftime ("%Y-%m" ) for x in df .columns }
819819 row .update (period = None , property = "Common last data date" )
820- description = pd .concat ([description , pd .DataFrame (row , index = [0 ])], ignore_index = True )
820+ rows_list .append (row )
821+ # Create DataFrame from list of rows
822+ description = pd .DataFrame (rows_list )
821823 # rename columns
822824 if hasattr (self , "inflation" ):
823825 description .rename (columns = {self .inflation : "inflation" }, inplace = True )
0 commit comments