import pandas as pd
import matplotlib.pyplot as plt
rdf = pd.read_csv('https://frdata.wikimedia.org/yeardata-day-vs-sum.csv')
dates = []
dollars = []
for column, series in rdf.transpose().iterrows():
if len(dates) > 0:
d = dates.copy()
for index, value in series.items():
if column == 'date':
dates.append(value)
else:
if value > 0: # drop zeros and nans
try: # drop impossible leap days, why aren't they nans or zeros lol?
dollars.append((pd.to_datetime(column + d.pop(0)[4:]), value))
except:
pass
df = pd.DataFrame(dollars, columns=['date', 'dollars'])
df.set_index('date', inplace=True)
colors = ['orange', 'purple', 'brown', 'red', 'green', 'blue']
fig, ax = plt.subplots()
for year in range(2017, 2023):
pdf = df.loc[(df.index >= str(year) + '-11-22') &
(df.index <= str(year+1) + '-01-05')]
ax.plot((pdf.index - pd.Timestamp(str(year) + '-11-22')).days,
pdf['dollars']/1000000, color=colors.pop(0), label=str(year))
ax.set_xlabel('Days since November 22nd')
ax.set_ylabel('Dollars (millions)')
ax.set_title('Fundraising amount received per day')
plt.legend(loc='best')
plt.show()
Licensing
I, the copyright holder of this work, hereby publish it under the following license:
to share – to copy, distribute and transmit the work
to remix – to adapt the work
Under the following conditions:
attribution – You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
share alike – If you remix, transform, or build upon the material, you must distribute your contributions under the same or compatible license as the original.