|
|
import streamlit as st |
|
|
import pandas as pd |
|
|
import matplotlib.pyplot as plt |
|
|
import seaborn as sns |
|
|
|
|
|
|
|
|
@st.cache_data |
|
|
def load_data(): |
|
|
data = pd.read_csv('SME Survey.csv') |
|
|
return data |
|
|
|
|
|
data = load_data() |
|
|
|
|
|
|
|
|
st.title('SME Survey Data Exploration') |
|
|
|
|
|
|
|
|
st.subheader('Raw Data') |
|
|
st.dataframe(data) |
|
|
|
|
|
|
|
|
st.sidebar.header('Filters') |
|
|
business_nature = st.sidebar.multiselect('Select Business Nature', data['What is the nature of your business?'].unique(), default=data['What is the nature of your business?'].unique()) |
|
|
employee_range = st.sidebar.multiselect('Select Employee Range', data['How many employees does your business have?'].unique(), default=data['How many employees does your business have?'].unique()) |
|
|
familiar_with_ai = st.sidebar.multiselect('Familiarity with AI', data['Are you familiar with the concept of Artificial Intelligence (AI)?'].unique(), default=data['Are you familiar with the concept of Artificial Intelligence (AI)?'].unique()) |
|
|
|
|
|
|
|
|
filtered_data = data[ |
|
|
(data['What is the nature of your business?'].isin(business_nature)) & |
|
|
(data['How many employees does your business have?'].isin(employee_range)) & |
|
|
(data['Are you familiar with the concept of Artificial Intelligence (AI)?'].isin(familiar_with_ai)) |
|
|
] |
|
|
|
|
|
|
|
|
st.subheader('Filtered Data') |
|
|
st.dataframe(filtered_data) |
|
|
|
|
|
|
|
|
st.subheader('Analysis and Visualizations') |
|
|
|
|
|
|
|
|
st.write('### Distribution of Business Nature') |
|
|
fig, ax = plt.subplots(figsize=(10, 6)) |
|
|
sns.countplot(y=filtered_data['What is the nature of your business?'], order=filtered_data['What is the nature of your business?'].value_counts().index) |
|
|
plt.title('Number of Businesses by Nature') |
|
|
plt.xlabel('Count') |
|
|
plt.ylabel('Business Nature') |
|
|
st.pyplot(fig) |
|
|
|
|
|
|
|
|
st.write('### Distribution of Employee Range') |
|
|
fig, ax = plt.subplots(figsize=(10, 6)) |
|
|
sns.countplot(y=filtered_data['How many employees does your business have?'], order=filtered_data['How many employees does your business have?'].value_counts().index) |
|
|
plt.title('Number of Businesses by Employee Range') |
|
|
plt.xlabel('Count') |
|
|
plt.ylabel('Employee Range') |
|
|
st.pyplot(fig) |
|
|
|
|
|
|
|
|
st.write('### Familiarity with AI') |
|
|
fig, ax = plt.subplots(figsize=(8, 8)) |
|
|
filtered_data['Are you familiar with the concept of Artificial Intelligence (AI)?'].value_counts().plot(kind='pie', autopct='%1.1f%%', startangle=90) |
|
|
plt.title('Familiarity with AI') |
|
|
plt.ylabel('') |
|
|
st.pyplot(fig) |
|
|
|
|
|
|
|
|
st.write('### Concerns about Adopting AI') |
|
|
fig, ax = plt.subplots(figsize=(10, 6)) |
|
|
sns.countplot(y=filtered_data['What concerns do you have about adopting AI in your business?'], order=filtered_data['What concerns do you have about adopting AI in your business?'].value_counts().index) |
|
|
plt.title('Concerns about Adopting AI') |
|
|
plt.xlabel('Count') |
|
|
plt.ylabel('Concerns') |
|
|
st.pyplot(fig) |
|
|
|
|
|
|
|
|
st.write('### Willingness to Invest in AI Solutions Annually') |
|
|
fig, ax = plt.subplots(figsize=(10, 6)) |
|
|
sns.countplot(y=filtered_data['How much are you willing to invest in AI solutions annually?'], order=filtered_data['How much are you willing to invest in AI solutions annually?'].value_counts().index) |
|
|
plt.title('Willingness to Invest in AI Solutions Annually') |
|
|
plt.xlabel('Count') |
|
|
plt.ylabel('Investment Range') |
|
|
st.pyplot(fig) |
|
|
|
|
|
|
|
|
st.write('### Primary Goal in Adopting AI') |
|
|
fig, ax = plt.subplots(figsize=(10, 6)) |
|
|
sns.countplot(y=filtered_data['What would be your primary goal in adopting AI for your business?'], order=filtered_data['What would be your primary goal in adopting AI for your business?'].value_counts().index) |
|
|
plt.title('Primary Goal in Adopting AI') |
|
|
plt.xlabel('Count') |
|
|
plt.ylabel('Primary Goal') |
|
|
st.pyplot(fig) |
|
|
|
|
|
|
|
|
st.write('### Top Business Challenges by Business Nature') |
|
|
challenges = filtered_data['Which business challenges do you face most often? (Rank top 3)'].str.split(';').explode().str.strip() |
|
|
challenge_counts = challenges.value_counts() |
|
|
challenge_df = filtered_data.merge(challenges.rename('Business Challenge'), left_index=True, right_index=True) |
|
|
challenge_pivot = challenge_df.pivot_table(index='Business Challenge', columns='What is the nature of your business?', aggfunc='size', fill_value=0) |
|
|
|
|
|
fig, ax = plt.subplots(figsize=(12, 8)) |
|
|
challenge_pivot.plot(kind='bar', ax=ax) |
|
|
plt.title('Top Business Challenges by Business Nature') |
|
|
plt.xlabel('Business Challenge') |
|
|
plt.ylabel('Count') |
|
|
plt.xticks(rotation=45) |
|
|
st.pyplot(fig) |
|
|
|
|
|
|
|
|
st.write('### Willingness to Invest in AI by Business Nature') |
|
|
investment_df = filtered_data.copy() |
|
|
investment_df['Investment Range'] = pd.Categorical(investment_df['How much are you willing to invest in AI solutions annually?'], categories=[ |
|
|
'Below R 5000 per year', |
|
|
'Between R 6000 - R 10 000 per year', |
|
|
'Between R 20 000 - R 50 000 per year', |
|
|
'More than R50 000 per year' |
|
|
], ordered=True) |
|
|
|
|
|
investment_pivot = investment_df.pivot_table(index='Investment Range', columns='What is the nature of your business?', aggfunc='size', fill_value=0) |
|
|
|
|
|
fig, ax = plt.subplots(figsize=(12, 8)) |
|
|
investment_pivot.plot(kind='bar', ax=ax) |
|
|
plt.title('Willingness to Invest in AI by Business Nature') |
|
|
plt.xlabel('Investment Range') |
|
|
plt.ylabel('Count') |
|
|
plt.xticks(rotation=45) |
|
|
st.pyplot(fig) |
|
|
|
|
|
|
|
|
st.write('### Primary Goal in Adopting AI by Business Nature') |
|
|
goal_df = filtered_data.copy() |
|
|
goal_df['Primary Goal'] = goal_df['What would be your primary goal in adopting AI for your business?'] |
|
|
|
|
|
goal_pivot = goal_df.pivot_table(index='Primary Goal', columns='What is the nature of your business?', aggfunc='size', fill_value=0) |
|
|
|
|
|
fig, ax = plt.subplots(figsize=(12, 8)) |
|
|
goal_pivot.plot(kind='bar', ax=ax) |
|
|
plt.title('Primary Goal in Adopting AI by Business Nature') |
|
|
plt.xlabel('Primary Goal') |
|
|
plt.ylabel('Count') |
|
|
plt.xticks(rotation=45) |
|
|
st.pyplot(fig) |
|
|
|
|
|
|
|
|
st.write('### Number of Businesses Using AI Tools') |
|
|
ai_usage = filtered_data['Have you used any AI tools in your business?'].value_counts() |
|
|
st.bar_chart(ai_usage) |
|
|
|
|
|
|
|
|
st.write('### Number of Businesses Interested in a Free Trial of AI Tools') |
|
|
free_trial_interest = filtered_data['Would you be interested in a free trial of AI tools tailored to your business?'].value_counts() |
|
|
st.bar_chart(free_trial_interest) |
|
|
|
|
|
|
|
|
st.write('### Number of Businesses Knowing Sales Revenue in Real Time') |
|
|
real_time_revenue = filtered_data['Do you know your sales revenue in real time?'].value_counts() |
|
|
st.bar_chart(real_time_revenue) |
|
|
|
|
|
|
|
|
st.write('### Preferred Method of Learning about New Technologies') |
|
|
learning_method = filtered_data['How do you prefer to learn about new technologies like AI?'].value_counts() |
|
|
st.bar_chart(learning_method) |
|
|
|
|
|
|
|
|
st.write('### Number of Businesses by Primary Goal in Adopting AI') |
|
|
primary_goal = filtered_data['What would be your primary goal in adopting AI for your business?'].value_counts() |
|
|
st.bar_chart(primary_goal) |
|
|
|
|
|
|
|
|
st.write('### Number of Businesses by Familiarity with AI') |
|
|
familiarity_with_ai = filtered_data['Are you familiar with the concept of Artificial Intelligence (AI)?'].value_counts() |
|
|
st.bar_chart(familiarity_with_ai) |
|
|
|
|
|
|
|
|
st.write('### Number of Businesses by Concerns about AI') |
|
|
concerns_about_ai = filtered_data['What concerns do you have about adopting AI in your business?'].value_counts() |
|
|
st.bar_chart(concerns_about_ai) |
|
|
|
|
|
|
|
|
st.write('### Number of Businesses by Willingness to Invest in AI') |
|
|
willingness_to_invest = filtered_data['How much are you willing to invest in AI solutions annually?'].value_counts() |
|
|
st.bar_chart(willingness_to_invest) |
|
|
|
|
|
|
|
|
st.write('### Number of Businesses by Current Technological Solutions') |
|
|
current_tech_solutions = filtered_data['What technological solutions do you currently use?'].str.split(';').explode().str.strip().value_counts() |
|
|
st.bar_chart(current_tech_solutions) |
|
|
|
|
|
|
|
|
st.write('### Number of Businesses by Needed Technology Solutions') |
|
|
needed_tech_solutions = filtered_data['What technology solutions do you need for your business?'].str.split(';').explode().str.strip().value_counts() |
|
|
st.bar_chart(needed_tech_solutions) |
|
|
|
|
|
|
|
|
st.write('### Number of Businesses by Operational Tasks Handling') |
|
|
operational_tasks = filtered_data['How do you currently handle the operational tasks of Customer support; Inventory management; Accounting/Finance and etc?'].str.split(';').explode().str.strip().value_counts() |
|
|
st.bar_chart(operational_tasks) |
|
|
|
|
|
|
|
|
st.write('### Number of Businesses by Business Challenges') |
|
|
business_challenges = filtered_data['Which business challenges do you face most often? (Rank top 3)'].str.split(';').explode().str.strip().value_counts() |
|
|
st.bar_chart(business_challenges) |
|
|
|