mirror of
https://github.com/arnaucube/faircoopDataAnalytics.git
synced 2026-02-06 18:56:40 +01:00
botc
This commit is contained in:
12
README.md
12
README.md
@@ -18,3 +18,15 @@ Products
|
|||||||

|

|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
#### BotC
|
||||||
|
|
||||||
|
Members
|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|||||||
77
botc-membersAnalytics.py
Normal file
77
botc-membersAnalytics.py
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
# coding=utf-8
|
||||||
|
import sys
|
||||||
|
reload(sys)
|
||||||
|
sys.setdefaultencoding('utf8')
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
import pandas as pd
|
||||||
|
import matplotlib.pyplot as plt
|
||||||
|
from datetime import datetime, date, timedelta
|
||||||
|
|
||||||
|
members = pd.read_csv('datasets/BotC.csv')
|
||||||
|
|
||||||
|
print members.head(1)
|
||||||
|
|
||||||
|
#generate the full set of days from the first date to the last in the dataset
|
||||||
|
months = []
|
||||||
|
days = []
|
||||||
|
dInit = date(2017, 6, 8)
|
||||||
|
dEnd = date(2017, 1, 9)
|
||||||
|
delta = dEnd - dInit
|
||||||
|
for i in range(delta.days+1):
|
||||||
|
day = dInit + timedelta(days=i)
|
||||||
|
dayString = day.strftime("%d/%m/%y")
|
||||||
|
dayDatetime = datetime.strptime(dayString, '%d/%m/%y')
|
||||||
|
days.append(dayDatetime)
|
||||||
|
|
||||||
|
#add the dates of shops creation to the days array
|
||||||
|
for memberDate in members['Date']:
|
||||||
|
if isinstance(memberDate, basestring):
|
||||||
|
memberDay = memberDate
|
||||||
|
memberDayDatetime = datetime.strptime(memberDay, '%B %d, %Y')
|
||||||
|
days.append(memberDayDatetime)
|
||||||
|
|
||||||
|
#count days frequency in days array
|
||||||
|
unique, counts = np.unique(days, return_counts=True)
|
||||||
|
countDays = dict(zip(unique, counts))
|
||||||
|
realCounts = []
|
||||||
|
for count in counts:
|
||||||
|
realCounts.append(count-1)
|
||||||
|
|
||||||
|
#count the total acumulation of shops created in each days
|
||||||
|
totalCount = 0
|
||||||
|
globalCount = []
|
||||||
|
for k in realCounts:
|
||||||
|
totalCount = totalCount + k
|
||||||
|
globalCount.append(totalCount)
|
||||||
|
|
||||||
|
dates = countDays.values()
|
||||||
|
counts = countDays.values()
|
||||||
|
|
||||||
|
#plot the data
|
||||||
|
plt.title("New members registered each day")
|
||||||
|
plt.plot(unique, realCounts)
|
||||||
|
plt.show()
|
||||||
|
|
||||||
|
plt.title("Total members each day")
|
||||||
|
plt.plot(unique, globalCount)
|
||||||
|
plt.show()
|
||||||
|
|
||||||
|
plt.title("New members and total members each day")
|
||||||
|
plt.plot(unique, realCounts, label="new members registered each day")
|
||||||
|
plt.plot(unique, globalCount, label="total members each day")
|
||||||
|
plt.legend(loc='upper left')
|
||||||
|
plt.show()
|
||||||
|
|
||||||
|
|
||||||
|
# place of the account
|
||||||
|
places = []
|
||||||
|
for place in members["Place"]:
|
||||||
|
if isinstance(place, basestring):
|
||||||
|
places.append(place)
|
||||||
|
|
||||||
|
placesNames, placesCount = np.unique(places, return_counts=True)
|
||||||
|
plt.title("Membership places")
|
||||||
|
plt.pie(placesCount, labels=placesNames, autopct='%1.1f%%', shadow=True, startangle=90)
|
||||||
|
plt.axis('equal')
|
||||||
|
plt.show()
|
||||||
BIN
chartsResults/botc-members01.png
Normal file
BIN
chartsResults/botc-members01.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 46 KiB |
BIN
chartsResults/botc-members02.png
Normal file
BIN
chartsResults/botc-members02.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
BIN
chartsResults/botc-members03.png
Normal file
BIN
chartsResults/botc-members03.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 45 KiB |
BIN
chartsResults/botc-members04.png
Normal file
BIN
chartsResults/botc-members04.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 256 KiB |
BIN
chartsResults/fairmarket-products04.png
Normal file
BIN
chartsResults/fairmarket-products04.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 167 KiB |
@@ -1,11 +1,20 @@
|
|||||||
|
# coding=utf-8
|
||||||
|
import sys
|
||||||
|
reload(sys)
|
||||||
|
sys.setdefaultencoding('utf8')
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
|
|
||||||
|
import mpld3
|
||||||
|
from mpld3 import plugins, utils
|
||||||
|
|
||||||
from datetime import datetime, date, timedelta
|
from datetime import datetime, date, timedelta
|
||||||
|
|
||||||
products = pd.read_csv('datasets/fairMarket-products.csv')
|
products = pd.read_csv('datasets/fairMarket-products.csv')
|
||||||
|
|
||||||
print products.tail(1)
|
#print products.tail(1)
|
||||||
|
|
||||||
#generate the full set of days from the first date to the last in the dataset
|
#generate the full set of days from the first date to the last in the dataset
|
||||||
months = []
|
months = []
|
||||||
@@ -57,3 +66,18 @@ plt.plot(unique, realCounts, label="new products offered each day")
|
|||||||
plt.plot(unique, globalCount, label="total products in FairMarket each day")
|
plt.plot(unique, globalCount, label="total products in FairMarket each day")
|
||||||
plt.legend(loc='upper left')
|
plt.legend(loc='upper left')
|
||||||
plt.show()
|
plt.show()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# now, product categories analytics
|
||||||
|
categories = []
|
||||||
|
for category in products["Categoría pública/Display Name"]:
|
||||||
|
if isinstance(category, basestring):
|
||||||
|
categories.append(category)
|
||||||
|
|
||||||
|
categoriesNames, categoriesCount = np.unique(categories, return_counts=True)
|
||||||
|
plt.title("Products categories")
|
||||||
|
plt.pie(categoriesCount, labels=categoriesNames, autopct='%1.1f%%', shadow=True, startangle=90)
|
||||||
|
plt.axis('equal')
|
||||||
|
mpld3.show()
|
||||||
@@ -1,3 +1,8 @@
|
|||||||
|
# coding=utf-8
|
||||||
|
import sys
|
||||||
|
reload(sys)
|
||||||
|
sys.setdefaultencoding('utf8')
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
Reference in New Issue
Block a user