<jupyter_start><jupyter_text>FEEDBACK ANALYSIS During the Beta Phase, a google form will appear in the banner of the project. You will be able to access an exel file with the answers. In this script we visualize the answers with pie charts, bar plots, and simple print statements. Since this google form is the same for every project, you can easily use this script for your data.<jupyter_code>import pandas as pd
import json
import seaborn as sns
import matplotlib.pyplot as plt
import numpy as np
# Here you can put instead your data file's path
filename_feedback = '/home/anna/Desktop/SUNDIAL/feedback.txt'
def read(path):
    with open(path, 'r', encoding="utf-8") as f:
        return f.read().splitlines()
feedback = read(filename_feedback)
def answers_count(answer, question_number):
    answers = 0 
    for line in feedback[1:]:
        row = line.split('\t')
        if len(row) == 19 and row[question_number]== answer:
            answers += 1
    return answers


def all_yes_pie(question_asked, answers, how_many):
    fig, ax = plt.subplots()
    ax.pie(only_yes,labels=['Yes'], autopct='%1.1f%%', startangle=90,textprops=dict(color="w", size =30), colors = ['lightseagreen'])
    ax.axis('equal')  # Equal aspect ratio ensures that pie is drawn as a circle.
    ax.set_title(question_asked, size = 20)
    ax.legend(answers,
      title="Answers",
      loc="center left",
      bbox_to_anchor=(1, 0, 0.5, 1))
    plt.show()

    
def mixed_pie(question_asked, answers, how_many):
    fig, ax = plt.subplots()
    ax.pie(how_many,labels=answers, autopct='%1.1f%%', startangle=90,textprops=dict(color="w", size =20), colors = ['lightseagreen','orange'])
    ax.axis('equal')  # Equal aspect ratio ensures that pie is drawn as a circle.
    ax.set_title(question_asked, size = 20)
    ax.legend(answers,
      title="Answers",
      loc="center left",
      bbox_to_anchor=(1, 0, 0.5, 1))
    plt.show()
    
    
def pie_chart(question_number):

    answers = ['Yes', 'No'] 
    question_asked = feedback[0].split('\t')[question_number]
    
    answer_yes = answers_count('Yes', question_number)
    answer_no = answers_count('No', question_number)
    

    how_many = [answer_yes, answer_no]
    only_yes = [answer_yes]
    
    if answer_no == 0:
        all_yes_pie(question_asked, answers, how_many)
    else:    
        mixed_pie(question_asked, answers, how_many)


def bars(question_asked, answers, how_many):
    fig = plt.figure()
    ax = fig.add_axes([0,0,1,1])
    ax.set_title(question_asked, size = 20)
    ax.bar(answers, how_many, color = ['darkorange', 'orange','lightseagreen', 'turquoise'])
    plt.show()
        
def bar_plot(question_number):
    
    very_easy = answers_count('Very easy', question_number )
    somewhat_hard = answers_count('Somewhat hard', question_number)
    mod_easy = answers_count('Moderately easy', question_number)
    very_hard = answers_count('Very hard', question_number)
    
    question_asked = feedback[0].split('\t')[question_number]
    answers = ['Very hard', 'Somewhat hard', 'Moderately easy', 'Very easy']
    how_many = [very_hard, somewhat_hard, mod_easy, very_easy]
    
    bars(question_asked, answers, how_many)
    
def bar_plot_field(question_number):
    
    yes = answers_count('Yes', question_number )
    no = answers_count('No', question_number)
    not_read = answers_count('I didn\'t read it', question_number)
    no_guide = answers_count('There is no field guide', question_number)
    
    question_asked = feedback[0].split('\t')[question_number]
    answers = ['No', 'Yes' , 'I didn\'t read it', 'There is no field guide']
    how_many = [no, yes, not_read, no_guide]
    
    bars(question_asked, answers, how_many)
    
def bar_plot_friends(question_number):
    
    no = answers_count('No', question_number )
    not_sure = answers_count('Not sure', question_number)
    yes = answers_count('Yes', question_number)
    super_yes = answers_count('Yes and I\'ll bring friends!', question_number)
    
    question_asked = feedback[0].split('\t')[question_number]
    answers = ['No', 'Not sure' , 'Yes', 'Yes and I\'ll bring friends!']
    how_many = [no, not_sure, yes, super_yes]
    
    bars(question_asked, answers, how_many)
    
    
def comments(question_number):
    question_asked = feedback[0].split('\t')[question_number]
    
    print('Q: ',question_asked)
    print(' ')
    for line in feedback[1:]:
        row = line.split('\t')
        if len(row) == 19 and row[question_number] != '':
            print('A: ', row[question_number])

pie_chart_cleancode(1)
pie_chart(2)
bar_plot(3)
comments(4)
pie_chart(5)
pie_chart(6)
pie_chart(7)
bar_plot_field(7)
pie_chart(8)
pie_chart(9)
comments(10)
pie_chart(11)
comments(12)
pie_chart(13)
comments(14)
pie_chart(15)
comments(16)
comments(17)
bar_plot_friends(18)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1279093717816684, 'fraction_numerical': 0.015447991761071062, 'mean_word_length': 3.91497975708502, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '207511', 'license': 'MIT', 'n_tokens_mistral': 1696, 'n_tokens_neox': 1636, 'n_words': 405, 'path': 'Feedback_form_dataviz.ipynb', 'repo_name': 'hwiks/SpaceFluff', 'size': '4855'}