Spaces:
Sleeping
Sleeping
from excel_chat import get_columns | |
import matplotlib.pyplot as plt | |
def create_bar_plot(file, x_values): | |
df = pd.read_excel(file) | |
counts = df[x_values].apply(lambda x: x.split()[0].split(',')[0] if type(x)==str else np.nan).value_counts() | |
fig = plt.figure(figsize=(10, 6)) | |
counts.plot(kind='bar') | |
plt.title(f'Count of First Words in {x_values}') | |
plt.xlabel('First Word') | |
plt.ylabel('Count') | |
return fig |