diff --git a/wosis/analysis/stats.py b/wosis/analysis/stats.py index 95b5d5c..955bbd4 100644 --- a/wosis/analysis/stats.py +++ b/wosis/analysis/stats.py @@ -2,9 +2,9 @@ def calc_average_citations(in_df, max_year=None, sort=False): """Calculate the average citations since year of publication. - - If no `max_year` is specified, calculate using the latest - year in given dataset. + + If no `max_year` is specified, calculate using the latest + year in given dataset. Example ========== @@ -18,7 +18,7 @@ def calc_average_citations(in_df, max_year=None, sort=False): Parameters ========== * in_df : Pandas DataFrame - * max_year: int or None, year to calculate average citations from. + * max_year: int or None, year to calculate average citations from. Returns ========== @@ -27,15 +27,15 @@ def calc_average_citations(in_df, max_year=None, sort=False): assert hasattr(in_df, 'citations'), \ 'DataFrame has to have `citation` column. Use `get_num_citations()` first' out_df = in_df.copy() - - max_year_in_data = out_df.year.max() - - if max_year not None: - max_year = int(max_year) - assert max_year_in_data <= max_year, \ - "Given max_year must be later than any year found in dataset." + + max_year_in_data = out_df.year.max() + + if max_year not None: + max_year = int(max_year) + assert max_year_in_data <= max_year, \ + "Given max_year must be later than any year found in dataset." else: - max_year = out_df.year.max() + max_year = out_df.year.max() out_df.loc[:, 'Avg. Citations'] = (out_df.citations / ((max_year - out_df.year) + 1)).astype(float).round(2) if sort: