Skip to content

Commit

Permalink
tab to space
Browse files Browse the repository at this point in the history
  • Loading branch information
ConnectedSystems committed May 1, 2019
1 parent ad74668 commit 38caf12
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions wosis/analysis/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
==========
Expand All @@ -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
==========
Expand All @@ -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:
Expand Down

0 comments on commit 38caf12

Please sign in to comment.