series = [ordered_words(archive.data) for archive in archives]

"""
Explanation: The line below creates a list of three pairs, each pair containing two pandas.Series objects.
A Series is like a dictionary, only its items are ordered and its values must share a data type. The order keys of the series are its index. It is easy to compose Series objects into a DataFrame.
End of explanation
"""


rankings = pd.concat([series[0][0],
                      series[0][1],
                      series[1][0],
                      series[1][1],
                      series[2][0],
                      series[2][1]],axis=1)

# display the first 5 rows of the DataFrame
rankings[:5]

"""
Explanation: This creates a DataFrame from each of the series.
The columns alternate between representing word rankings and representing word counts.
End of explanation
"""


rankings.rename(columns={0: 'ipc-gnso rankings',
                         1: 'ipc-gnso counts',
                         2: 'wp4 rankings',
                         3: 'wp4 counts',
                         4: 'ncuc-discuss rankings',
                         5: 'ncuc-discuss counts'},inplace=True)

rankings[:5]

"""
Explanation: We should rename the columns to be more descriptive of the data.
End of explanation
"""


rankings.to_csv("rankings_all.csv",encoding="utf-8")

"""
Explanation: Use the to_csv() function on the DataFrame object to export the data to CSV format, which you can open easily in Excel.
End of explanation
"""


authors = ["Greg Shatan",
           "Niels ten Oever"]

ordered_words(archives[0].data, authors=authors)

"""
Explanation: To filter the data by certain authors before computing the word rankings, provide a list of author names as an argument.
Only emails whose From header includes on of the author names within it will be included in the calculation.
Note that for detecting the author name, the program for now uses simple string inclusion. You may need to try multiple variations of the authors' names in order to catch all emails written by persons of interest.
End of explanation
"""


