File size: 433 Bytes
dc06294
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
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