nodes: 0, module; 1, function_definition; 2, function_name:value_counts; 3, parameters; 4, block; 5, identifier:values; 6, default_parameter; 7, default_parameter; 8, default_parameter; 9, default_parameter; 10, default_parameter; 11, expression_statement; 12, import_from_statement; 13, expression_statement; 14, if_statement; 15, if_statement; 16, if_statement; 17, return_statement; 18, identifier:sort; 19, True; 20, identifier:ascending; 21, False; 22, identifier:normalize; 23, False; 24, identifier:bins; 25, None; 26, identifier:dropna; 27, True; 28, comment:"""
      Compute a histogram of the counts of non-null values.
  
      Parameters
      ----------
      values : ndarray (1-d)
      sort : boolean, default True
          Sort by values
      ascending : boolean, default False
          Sort in ascending order
      normalize: boolean, default False
          If True then compute a relative histogram
      bins : integer, optional
          Rather than count values, group them into half-open bins,
          convenience for pd.cut, only works with numeric data
      dropna : boolean, default True
          Don't include counts of NaN
  
      Returns
      -------
      value_counts : Series
  
      """; 29, dotted_name; 30, dotted_name; 31, dotted_name; 32, assignment; 33, comparison_operator:bins is not None; 34, block; 35, else_clause; 36, identifier:sort; 37, block; 38, identifier:normalize; 39, block; 40, identifier:result; 41, identifier:pandas; 42, identifier:core; 43, identifier:series; 44, identifier:Series; 45, identifier:Index; 46, identifier:name; 47, call; 48, identifier:bins; 49, None; 50, try_statement; 51, comment:# count, remove nulls (from the index), and but the bins; 52, expression_statement; 53, expression_statement; 54, expression_statement; 55, expression_statement; 56, comment:# if we are dropna and we have NO values; 57, if_statement; 58, comment:# normalizing is by len of all (regardless of dropna); 59, expression_statement; 60, block; 61, expression_statement; 62, expression_statement; 63, identifier:getattr; 64, argument_list; 65, block; 66, except_clause; 67, assignment; 68, assignment; 69, assignment; 70, assignment; 71, boolean_operator; 72, block; 73, assignment; 74, if_statement; 75, assignment; 76, assignment; 77, identifier:values; 78, string; 79, None; 80, import_from_statement; 81, expression_statement; 82, expression_statement; 83, identifier:TypeError; 84, block; 85, identifier:result; 86, call; 87, identifier:result; 88, subscript; 89, attribute; 90, call; 91, identifier:result; 92, call; 93, identifier:dropna; 94, call; 95, expression_statement; 96, identifier:counts; 97, call; 98, boolean_operator; 99, comment:# handle Categorical and sparse,; 100, block; 101, else_clause; 102, identifier:result; 103, call; 104, identifier:result; 105, binary_operator:result / float(counts.sum()); 106, string_content:name; 107, dotted_name; 108, dotted_name; 109, assignment; 110, assignment; 111, raise_statement; 112, attribute; 113, argument_list; 114, identifier:result; 115, call; 116, identifier:result; 117, identifier:index; 118, attribute; 119, argument_list; 120, attribute; 121, argument_list; 122, attribute; 123, argument_list; 124, assignment; 125, attribute; 126, argument_list; 127, call; 128, call; 129, expression_statement; 130, expression_statement; 131, expression_statement; 132, block; 133, attribute; 134, argument_list; 135, identifier:result; 136, call; 137, identifier:pandas; 138, identifier:core; 139, identifier:reshape; 140, identifier:tile; 141, identifier:cut; 142, identifier:values; 143, call; 144, identifier:ii; 145, call; 146, call; 147, identifier:ii; 148, identifier:value_counts; 149, keyword_argument; 150, attribute; 151, argument_list; 152, attribute; 153, identifier:astype; 154, string; 155, identifier:result; 156, identifier:sort_index; 157, parenthesized_expression; 158, identifier:all; 159, identifier:result; 160, subscript; 161, identifier:np; 162, identifier:array; 163, list; 164, identifier:is_extension_array_dtype; 165, argument_list; 166, identifier:is_sparse; 167, argument_list; 168, assignment; 169, assignment; 170, assignment; 171, expression_statement; 172, if_statement; 173, expression_statement; 174, identifier:result; 175, identifier:sort_values; 176, keyword_argument; 177, identifier:float; 178, argument_list; 179, identifier:Series; 180, argument_list; 181, identifier:cut; 182, argument_list; 183, identifier:TypeError; 184, argument_list; 185, identifier:dropna; 186, identifier:dropna; 187, attribute; 188, identifier:notna; 189, identifier:result; 190, identifier:index; 191, string_content:interval; 192, comparison_operator:result.values == 0; 193, attribute; 194, slice; 195, call; 196, identifier:values; 197, identifier:values; 198, identifier:result; 199, call; 200, attribute; 201, identifier:name; 202, identifier:counts; 203, attribute; 204, assignment; 205, not_operator; 206, block; 207, assignment; 208, identifier:ascending; 209, identifier:ascending; 210, call; 211, identifier:values; 212, identifier:values; 213, identifier:bins; 214, keyword_argument; 215, string:"bins argument only works with numeric data."; 216, identifier:result; 217, identifier:index; 218, attribute; 219, integer:0; 220, identifier:result; 221, identifier:iloc; 222, integer:0; 223, integer:0; 224, identifier:len; 225, argument_list; 226, attribute; 227, argument_list; 228, identifier:result; 229, identifier:name; 230, identifier:result; 231, identifier:values; 232, pattern_list; 233, call; 234, call; 235, expression_statement; 236, identifier:result; 237, call; 238, attribute; 239, argument_list; 240, identifier:include_lowest; 241, True; 242, identifier:result; 243, identifier:values; 244, identifier:ii; 245, attribute; 246, identifier:value_counts; 247, keyword_argument; 248, identifier:keys; 249, identifier:counts; 250, identifier:_value_counts_arraylike; 251, argument_list; 252, identifier:isinstance; 253, argument_list; 254, assignment; 255, identifier:Series; 256, argument_list; 257, identifier:counts; 258, identifier:sum; 259, call; 260, identifier:_values; 261, identifier:dropna; 262, identifier:dropna; 263, identifier:values; 264, identifier:dropna; 265, identifier:keys; 266, identifier:Index; 267, identifier:keys; 268, call; 269, identifier:counts; 270, keyword_argument; 271, keyword_argument; 272, identifier:Series; 273, argument_list; 274, identifier:Index; 275, argument_list; 276, identifier:index; 277, identifier:keys; 278, identifier:name; 279, identifier:name; 280, identifier:values; 281, identifier:keys
code: def value_counts(values, sort=True, ascending=False, normalize=False,
                   bins=None, dropna=True):
      """
      Compute a histogram of the counts of non-null values.
  
      Parameters
      ----------
      values : ndarray (1-d)
      sort : boolean, default True
          Sort by values
      ascending : boolean, default False
          Sort in ascending order
      normalize: boolean, default False
          If True then compute a relative histogram
      bins : integer, optional
          Rather than count values, group them into half-open bins,
          convenience for pd.cut, only works with numeric data
      dropna : boolean, default True
          Don't include counts of NaN
  
      Returns
      -------
      value_counts : Series
  
      """
      from pandas.core.series import Series, Index
      name = getattr(values, 'name', None)
  
      if bins is not None:
          try:
              from pandas.core.reshape.tile import cut
              values = Series(values)
              ii = cut(values, bins, include_lowest=True)
          except TypeError:
              raise TypeError("bins argument only works with numeric data.")
  
          # count, remove nulls (from the index), and but the bins
          result = ii.value_counts(dropna=dropna)
          result = result[result.index.notna()]
          result.index = result.index.astype('interval')
          result = result.sort_index()
  
          # if we are dropna and we have NO values
          if dropna and (result.values == 0).all():
              result = result.iloc[0:0]
  
          # normalizing is by len of all (regardless of dropna)
          counts = np.array([len(ii)])
  
      else:
  
          if is_extension_array_dtype(values) or is_sparse(values):
  
              # handle Categorical and sparse,
              result = Series(values)._values.value_counts(dropna=dropna)
              result.name = name
              counts = result.values
  
          else:
              keys, counts = _value_counts_arraylike(values, dropna)
  
              if not isinstance(keys, Index):
                  keys = Index(keys)
              result = Series(counts, index=keys, name=name)
  
      if sort:
          result = result.sort_values(ascending=ascending)
  
      if normalize:
          result = result / float(counts.sum())
  
      return result