Spaces:
Sleeping
Sleeping
Create chart_generation.py
Browse files- chart_generation.py +12 -0
chart_generation.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from excel_chat import get_columns
|
| 2 |
+
import matplotlib.pyplot as plt
|
| 3 |
+
|
| 4 |
+
def create_bar_plot(file, x_values):
|
| 5 |
+
df = pd.read_excel(file)
|
| 6 |
+
counts = df[x_values].apply(lambda x: x.split()[0].split(',')[0] if type(x)==str else np.nan).value_counts()
|
| 7 |
+
fig = plt.figure(figsize=(10, 6))
|
| 8 |
+
counts.plot(kind='bar')
|
| 9 |
+
plt.title(f'Count of First Words in {x_values}')
|
| 10 |
+
plt.xlabel('First Word')
|
| 11 |
+
plt.ylabel('Count')
|
| 12 |
+
return fig
|