YchKhan commited on
Commit
33bdc38
1 Parent(s): e1cf54a

Update chart_generation.py

Browse files
Files changed (1) hide show
  1. chart_generation.py +2 -2
chart_generation.py CHANGED
@@ -10,7 +10,7 @@ def create_bar_plot(file, x_values, y_values):
10
  df['Simple_X'] = df[x_values].apply(lambda x: ' '.join(x.split(',')[0].split()[:2]) if type(x)==str else np.nan)
11
 
12
  if y_values == "":
13
- counts = df['Simple_Source'].value_counts()
14
  fig = plt.figure(figsize=(16, 7))
15
  counts.plot(kind='bar')
16
  plt.title(f'Count of First Words in {x_values}')
@@ -19,7 +19,7 @@ def create_bar_plot(file, x_values, y_values):
19
  else:
20
  df['Simple_Y'] = df[y_values].apply(lambda x: ' '.join(x.split(',')[0].split()[:2]) if type(x)==str else np.nan)
21
 
22
- count_df = df.groupby(['Simple_Source', 'Simple_Y']).size().unstack(fill_value=0)
23
  fig, ax = plt.subplots(figsize=(16, 7))
24
 
25
  count_df.plot(kind='bar', stacked=True, ax=ax)
 
10
  df['Simple_X'] = df[x_values].apply(lambda x: ' '.join(x.split(',')[0].split()[:2]) if type(x)==str else np.nan)
11
 
12
  if y_values == "":
13
+ counts = df['Simple_X'].value_counts()
14
  fig = plt.figure(figsize=(16, 7))
15
  counts.plot(kind='bar')
16
  plt.title(f'Count of First Words in {x_values}')
 
19
  else:
20
  df['Simple_Y'] = df[y_values].apply(lambda x: ' '.join(x.split(',')[0].split()[:2]) if type(x)==str else np.nan)
21
 
22
+ count_df = df.groupby(['Simple_X', 'Simple_Y']).size().unstack(fill_value=0)
23
  fig, ax = plt.subplots(figsize=(16, 7))
24
 
25
  count_df.plot(kind='bar', stacked=True, ax=ax)