floatfmt -- tab
This commit is contained in:
parent
2bdc741e65
commit
833cb4a3fd
@ -43,8 +43,56 @@
|
|||||||
"command": "html_threads_ranking_year",
|
"command": "html_threads_ranking_year",
|
||||||
"replace": "<--html_threads_ranking_year-->"
|
"replace": "<--html_threads_ranking_year-->"
|
||||||
},
|
},
|
||||||
|
{ "format": "text",
|
||||||
|
"command": "tab_msgs_threads_replies",
|
||||||
|
"replace": "<--tab_msgs_threads_replies-->"
|
||||||
|
},
|
||||||
|
{ "format": "text",
|
||||||
|
"command": "tab_avg_rep_msg_thrd",
|
||||||
|
"replace": "<--tab_avg_rep_msg_thrd-->"
|
||||||
|
},
|
||||||
|
{ "format": "text",
|
||||||
|
"command": "tab_activity_from_ranking",
|
||||||
|
"replace": "<--tab_activity_from_ranking-->"
|
||||||
|
},
|
||||||
|
{ "format": "text",
|
||||||
|
"command": "tab_threads_replies_to_ranking",
|
||||||
|
"replace": "<--tab_threads_replies_to_ranking-->"
|
||||||
|
},
|
||||||
|
{ "format": "text",
|
||||||
|
"command": "tab_threads_initiated_from_ranking",
|
||||||
|
"replace": "<--tab_threads_initiated_from_ranking-->"
|
||||||
|
},
|
||||||
|
{ "format": "text",
|
||||||
|
"command": "tab_threads_activity_threads_initiated_avg_ranking",
|
||||||
|
"replace": "<--tab_threads_activity_threads_initiated_avg_ranking-->"
|
||||||
|
},
|
||||||
|
{ "format": "text",
|
||||||
|
"command": "tab_threads_initiated_replies_avg_ranking",
|
||||||
|
"replace": "<--tab_threads_initiated_replies_avg_ranking-->"
|
||||||
|
},
|
||||||
|
{ "format": "text",
|
||||||
|
"command": "tab_content_length_from_ranking",
|
||||||
|
"replace": "<--tab_content_length_from_ranking-->"
|
||||||
|
},
|
||||||
|
{ "format": "text",
|
||||||
|
"command": "tab_threads_ranking",
|
||||||
|
"replace": "<--tab_threads_ranking-->"
|
||||||
|
},
|
||||||
|
{ "format": "text",
|
||||||
|
"command": "tab_threads_ranking_year",
|
||||||
|
"replace": "<--tab_threads_ranking_year-->"
|
||||||
|
},
|
||||||
|
{ "format": "text",
|
||||||
|
"command": "tab_msgs_threads_replies_avg_rep_msg_thrd",
|
||||||
|
"replace": "<--tab_msgs_threads_replies_avg_rep_msg_thrd-->"
|
||||||
|
},
|
||||||
{ "format": "text",
|
{ "format": "text",
|
||||||
"command": "tab_replies_ranking",
|
"command": "tab_replies_ranking",
|
||||||
"replace": "<--tab_replies_ranking-->"
|
"replace": "<--tab_replies_ranking-->"
|
||||||
|
},
|
||||||
|
{ "format": "text",
|
||||||
|
"command": "tab_replies_avg_ranking",
|
||||||
|
"replace": "<--tab_replies_avg_ranking-->"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -215,5 +215,5 @@ To our mind the content of the posts and conversations in Nettime is, in fact, w
|
|||||||
|
|
||||||
#Nettime Surveyors
|
#Nettime Surveyors
|
||||||
|
|
||||||
David Gauthier and Marc Tuters. Special thanks to Geert Lovink for is insights.
|
David Gauthier and Marc Tuters. Special thanks to Geert Lovink for his insights.
|
||||||
|
|
||||||
|
|||||||
@ -114,7 +114,7 @@ class Html:
|
|||||||
class Tab:
|
class Tab:
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def from_dataframe(data_frame, name_map={}):
|
def from_dataframe(data_frame, name_map={}, format=".0f"):
|
||||||
|
|
||||||
header = []
|
header = []
|
||||||
header.append(data_frame.index.name)
|
header.append(data_frame.index.name)
|
||||||
@ -123,6 +123,6 @@ class Tab:
|
|||||||
h = name_map[h]
|
h = name_map[h]
|
||||||
header.append(h)
|
header.append(h)
|
||||||
|
|
||||||
return tabulate(data_frame, headers=header, floatfmt=".4f")
|
return tabulate(data_frame, headers=header, floatfmt=format)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -27,13 +27,13 @@ class Report:
|
|||||||
mat = self.query.activity_overall()
|
mat = self.query.activity_overall()
|
||||||
|
|
||||||
# nbr threads
|
# nbr threads
|
||||||
mat['nbr-threads'] = self.query.threads_overall(aggregate='count')['nbr-threads']
|
mat['nbr-threads'] = self.query.threads_overall(aggregate='count')['nbr-threads'].astype(int)
|
||||||
|
|
||||||
# nbr replies
|
# nbr replies
|
||||||
mat['nbr-replies'] = self.query.threads_overall(aggregate='sum')['nbr-references']
|
mat['nbr-replies'] = self.query.threads_overall(aggregate='sum')['nbr-references'].astype(int)
|
||||||
|
|
||||||
# nbr non-replies (aka. non-threads)
|
# nbr non-replies (aka. non-threads)
|
||||||
mat['nbr-single-messages'] = mat['nbr-messages'] - mat['nbr-replies'] - mat['nbr-threads']
|
mat['nbr-single-messages'] = mat['nbr-messages'].astype(int) - mat['nbr-replies'] - mat['nbr-threads']
|
||||||
|
|
||||||
# avg. threads per message
|
# avg. threads per message
|
||||||
mat['avg-thrd-per-msg'] = mat['nbr-threads'] / mat['nbr-messages']
|
mat['avg-thrd-per-msg'] = mat['nbr-threads'] / mat['nbr-messages']
|
||||||
@ -129,20 +129,22 @@ class Report:
|
|||||||
|
|
||||||
def tab_msgs_threads_replies(self):
|
def tab_msgs_threads_replies(self):
|
||||||
self.matrix_msgs_threads()
|
self.matrix_msgs_threads()
|
||||||
return format.Tab.from_dataframe(self.matrix[['nbr-messages', 'nbr-threads', 'nbr-replies']],
|
a = self.matrix[['nbr-messages', 'nbr-threads', 'nbr-replies']].astype(int)
|
||||||
|
print a
|
||||||
|
return format.Tab.from_dataframe(self.matrix[['nbr-messages', 'nbr-threads', 'nbr-replies']].astype(int),
|
||||||
name_map={'nbr-messages': 'messages', 'nbr-threads': 'threads', 'nbr-replies': 'replies in threads'})
|
name_map={'nbr-messages': 'messages', 'nbr-threads': 'threads', 'nbr-replies': 'replies in threads'})
|
||||||
|
|
||||||
def tab_avg_rep_msg_thrd(self):
|
def tab_avg_rep_msg_thrd(self):
|
||||||
self.matrix_msgs_threads()
|
self.matrix_msgs_threads()
|
||||||
return format.Tab.from_dataframe(self.matrix[['avg-thrd-per-msg', 'avg-rep-per-thrd']],
|
return format.Tab.from_dataframe(self.matrix[['avg-thrd-per-msg', 'avg-rep-per-thrd']],
|
||||||
name_map={'avg-thrd-per-msg': 'avg. thread per message', 'avg-rep-per-thrd': 'avg. replies per thread'})
|
name_map={'avg-thrd-per-msg': 'avg. thread per message', 'avg-rep-per-thrd': 'avg. replies per thread'}, format=".4f")
|
||||||
|
|
||||||
def tab_msgs_threads_replies_avg_rep_msg_thrd(self):
|
def tab_msgs_threads_replies_avg_rep_msg_thrd(self):
|
||||||
self.matrix_msgs_threads()
|
self.matrix_msgs_threads()
|
||||||
return format.Tab.from_dataframe(self.matrix[['nbr-messages', 'nbr-threads', 'nbr-replies', 'avg-thrd-per-msg', 'avg-rep-per-thrd']],
|
return format.Tab.from_dataframe(self.matrix[['nbr-messages', 'nbr-threads', 'nbr-replies', 'avg-thrd-per-msg', 'avg-rep-per-thrd']],
|
||||||
name_map={'nbr-messages': 'messages', 'nbr-threads': 'threads', 'nbr-replies': 'replies in threads', 'avg-thrd-per-msg': 'avg. thread per message', 'avg-rep-per-thrd': 'avg. replies per thread'})
|
name_map={'nbr-messages': 'messages', 'nbr-threads': 'threads', 'nbr-replies': 'replies in threads', 'avg-thrd-per-msg': 'avg. thread per message', 'avg-rep-per-thrd': 'avg. replies per thread'}, format=".4f")
|
||||||
|
|
||||||
def tab_activity_from_ranking(self, rank=5):
|
def tab_activity_from_ranking(self, rank=10):
|
||||||
d = self.query.activity_from_ranking(rank=rank)
|
d = self.query.activity_from_ranking(rank=rank)
|
||||||
return format.Tab.from_dataframe(d, name_map={'nbr-messages': 'messages'})
|
return format.Tab.from_dataframe(d, name_map={'nbr-messages': 'messages'})
|
||||||
|
|
||||||
@ -154,17 +156,17 @@ class Report:
|
|||||||
#
|
#
|
||||||
def tab_threads_initiated_from_ranking(self, rank=10):
|
def tab_threads_initiated_from_ranking(self, rank=10):
|
||||||
d = self.query.threads_initiated_from_ranking(rank=rank)
|
d = self.query.threads_initiated_from_ranking(rank=rank)
|
||||||
return format.Tab.from_dataframe(d)
|
return format.Tab.from_dataframe(d, name_map={'nbr-initiated-threads': 'nbr. initiated threads'})
|
||||||
|
|
||||||
#
|
#
|
||||||
def tab_threads_activity_threads_initiated_avg_ranking(self, rank=10):
|
def tab_threads_activity_threads_initiated_avg_ranking(self, rank=10):
|
||||||
d = self.query.threads_activity_threads_initiated_avg_ranking(rank=rank)
|
d = self.query.threads_activity_threads_initiated_avg_ranking(rank=rank)
|
||||||
return format.Tab.from_dataframe(d)
|
return format.Tab.from_dataframe(d, format=".4f")
|
||||||
|
|
||||||
#
|
#
|
||||||
def tab_threads_initiated_replies_avg_ranking(self, rank=10):
|
def tab_threads_initiated_replies_avg_ranking(self, rank=10):
|
||||||
d = self.query.threads_initiated_replies_avg_ranking(rank=rank)
|
d = self.query.threads_initiated_replies_avg_ranking(rank=rank)
|
||||||
return format.Tab.from_dataframe(d)
|
return format.Tab.from_dataframe(d, format=".4f")
|
||||||
|
|
||||||
def tab_content_length_from_ranking(self, rank=5):
|
def tab_content_length_from_ranking(self, rank=5):
|
||||||
d = self.query.activity_from_ranking(rank=rank)
|
d = self.query.activity_from_ranking(rank=rank)
|
||||||
@ -186,7 +188,7 @@ class Report:
|
|||||||
|
|
||||||
def tab_replies_ranking(self, rank=10):
|
def tab_replies_ranking(self, rank=10):
|
||||||
d = self.query.replies_ranking(rank=rank)
|
d = self.query.replies_ranking(rank=rank)
|
||||||
return format.Tab.from_dataframe(d, name_map={'nbr_replies': 'nbr. replies'})
|
return format.Tab.from_dataframe(d, name_map={'nbr_replies': 'nbr. replies to threads'})
|
||||||
|
|
||||||
def tab_replies_avg_ranking(self, rank=10):
|
def tab_replies_avg_ranking(self, rank=10):
|
||||||
d = self.query.replies_avg_ranking(rank=rank)
|
d = self.query.replies_avg_ranking(rank=rank)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user