Creates a new SparseArray from the input value.

        Parameters
        ----------
        key : object
        value : scalar, Series, or array-like
        kwargs : dict

        Returns
        -------
        sanitized_column : SparseArray
554775
def _sanitize_column(self, key, value, **kwargs):
        
        def sp_maker(x, index=None):
            return SparseArray(x, index=index,
                               fill_value=self._default_fill_value,
                               kind=self._default_kind)
        if isinstance(value, SparseSeries):
            clean = value.reindex(self.index).as_sparse_array(
                fill_value=self._default_fill_value, kind=self._default_kind)

        elif isinstance(value, SparseArray):
            if len(value) != len(self.index):
                raise ValueError('Length of values does not match '
                                 'length of index')
            clean = value

        elif hasattr(value, '__iter__'):
            if isinstance(value, Series):
                clean = value.reindex(self.index)
                if not isinstance(value, SparseSeries):
                    clean = sp_maker(clean)
            else:
                if len(value) != len(self.index):
                    raise ValueError('Length of values does not match '
                                     'length of index')
                clean = sp_maker(value)

        # Scalar
        else:
            clean = sp_maker(value, self.index)

        # always return a SparseArray!
        return clean
1296844
def []=(key, value)
      h = self[key]      
      if h
        h.value = value
      else
        new_header = Redhead::Header.new(key, TO_RAW[key], value)
        self << new_header
      end
    end
429627
def unmarshall_key(self, key):
        
        key = str(key)
        if self.escapeKeys:
            key = key.decode('hex')
        if self.compressKeys:
            key = zlib.decompress(key)
        key = pickle.loads(key)
        return key
199137
def add(self, key, value):
        # type: (Hashable, Any) -> None
        
        dict.setdefault(self, key, []).append(value)
1228035
def create_binary_array(self, key, value):
        
        data = None
        if key is not None and value is not None:
            value_encoded = []
            for v in value:
                try:
                    # py2
                    # convert to bytes as required for b64encode
                    # decode bytes for json serialization as required for json dumps
                    value_encoded.append(base64.b64encode(bytes(v)).decode('utf-8'))
                except TypeError:
                    # py3
                    # set encoding on string and convert to bytes as required for b64encode
                    # decode bytes for json serialization as required for json dumps
                    value_encoded.append(base64.b64encode(bytes(v, 'utf-8')).decode('utf-8'))
            data = self.db.create(key.strip(), json.dumps(value_encoded))
        else:
            self.tcex.log.warning(u'The key or value field was None.')
        return data
723574
def col_append(self, col_key, value_list):
        
        if col_key in self._col_keys:
            raise KeyError('Key %s already exists col keys.' % col_key)
        if not isinstance(value_list, (tuple, list)):
            value_list = [value_list] * len(self._row_keys)
        if not len(value_list) == len(self._row_keys):
            raise ValueError('Length of data to set does not meet expected col length of %i' % len(self._row_keys))
        self._col_keys.append(col_key)
        for r, v in zip(self._row_keys, value_list):
            self[r, col_key] = v
1158900
def _create_dataframe(cls, value):
        
        try:

            ordered_jo = json.loads(six.text_type(value), object_pairs_hook=collections.OrderedDict)

            #Pandas does not maintain the order of dicts, so we must break the dict
            #up and put it into the dataframe manually to maintain the order.

            cols = list(ordered_jo.keys())

            if len(cols) == 0:
                raise ValueError("Dataframe has no columns")

            #Assume all sub-dicts have the same set of keys
            if isinstance(ordered_jo[cols[0]], list):
                index = range(len(ordered_jo[cols[0]]))
            else:
                index = list(ordered_jo[cols[0]].keys())
            data = []
            for c in cols:
                if isinstance(ordered_jo[c], list):
                    data.append(ordered_jo[c])
                else:
                    data.append(list(ordered_jo[c].values()))

            # This goes in 'sideways' (cols=index, index=cols), so it needs to be transposed after to keep
            # the correct structure
            # We also try to coerce the data to a regular numpy array first. If the shape is correct
            # this is a much faster way of creating the DataFrame instance.
            try:
                np_data = np.array(data)
            except ValueError:
                np_data = None

            if np_data is not None and np_data.shape == (len(cols), len(index)):
                df = pd.DataFrame(np_data, columns=index, index=cols).transpose()
            else:
                # TODO should these heterogenous structure be supported?
                # See https://github.com/hydraplatform/hydra-base/issues/72
                df = pd.DataFrame(data, columns=index, index=cols).transpose()


        except ValueError as e:
            """ Raised on scalar types used as pd.DataFrame values
                in absence of index arg
            """
            raise HydraError(str(e))

        except AssertionError as e:
            log.warning("An error occurred creating the new data frame: %s. Defaulting to a simple read_json"%(e))
            df = pd.read_json(value).fillna(0)

        return df
533918
def parse_column_key_value(table_schema, setting_string):
        
        if ':' in setting_string:
            # splits <column>:<key>=<value> into <column> and <key>=<value>
            column, value = setting_string.split(':', 1)
        elif '=' in setting_string:
            # splits <column>=<value> into <column> and <value>
            column, value = setting_string.split('=', 1)
        else:
            # stores <column> and <value>=None
            column = setting_string
            value = None

        if value is not None:
            type_ = table_schema.columns[column].type
            value = datum_from_string(type_, value)

        return column, value
128683
def []=(key, value)
      if not valid_type? value, @columns[key.to_sym].try(:[],:type)
        # Try to adapt the value
        adapter = get_adapter key, value
        raise ExtendModelAt::ArgumentError, "#{value.inspect} is not a valid type, expected #{@columns[key.to_sym][:type]}" if adapter.nil? # We can't adapt the value
        value = value.send adapter
      end
      @value[key.to_s] = value
      @model_manager.assign(key,value)
    end
152613
def _create_dict(self, format, args):
        """"""

        builder = None
        if args is None or not args[0]:
            # empty value: we need to call _create() to parse the subtype,
            # and specify the element type precisely
            rest_format = self._create(format[2:], None)[1]
            rest_format = self._create(rest_format, None)[1]
            if not rest_format.startswith('}'):
                raise TypeError('dictionary type string not closed with }')
            rest_format = rest_format[1:]  # eat the }
            element_type = format[:len(format) - len(rest_format)]
            builder = GLib.VariantBuilder.new(variant_type_from_string(element_type))
        else:
            builder = GLib.VariantBuilder.new(variant_type_from_string('a{?*}'))
            for k, v in args[0].items():
                (key_v, rest_format, _) = self._create(format[2:], [k])
                (val_v, rest_format, _) = self._create(rest_format, [v])

                if not rest_format.startswith('}'):
                    raise TypeError('dictionary type string not closed with }')
                rest_format = rest_format[1:]  # eat the }

                entry = GLib.VariantBuilder.new(variant_type_from_string('{?*}'))
                entry.add_value(key_v)
                entry.add_value(val_v)
                builder.add_value(entry.end())

        if args is not None:
            args = args[1:]
        return (builder.end(), rest_format, args)
1284845
def []=(key, value)
      key = self.class.normalize_key(key)
      if (header_class = self.class.attributes[key])
        value = header_class.parse(value)
      end
      super(key, value)
    end
636904
def get_value(self, series, key):
        

        # if we have something that is Index-like, then
        # use this, e.g. DatetimeIndex
        # Things like `Series._get_value` (via .at) pass the EA directly here.
        s = getattr(series, '_values', series)
        if isinstance(s, (ExtensionArray, Index)) and is_scalar(key):
            # GH 20882, 21257
            # Unify Index and ExtensionArray treatment
            # First try to convert the key to a location
            # If that fails, raise a KeyError if an integer
            # index, otherwise, see if key is an integer, and
            # try that
            try:
                iloc = self.get_loc(key)
                return s[iloc]
            except KeyError:
                if (len(self) > 0 and
                        (self.holds_integer() or self.is_boolean())):
                    raise
                elif is_integer(key):
                    return s[key]

        s = com.values_from_object(series)
        k = com.values_from_object(key)

        k = self._convert_scalar_indexer(k, kind='getitem')
        try:
            return self._engine.get_value(s, k,
                                          tz=getattr(series.dtype, 'tz', None))
        except KeyError as e1:
            if len(self) > 0 and (self.holds_integer() or self.is_boolean()):
                raise

            try:
                return libindex.get_value_box(s, key)
            except IndexError:
                raise
            except TypeError:
                # generator/iterator-like
                if is_iterator(key):
                    raise InvalidIndexError(key)
                else:
                    raise e1
            except Exception:  # pragma: no cover
                raise e1
        except TypeError:
            # python 3
            if is_scalar(key):  # pragma: no cover
                raise IndexError(key)
            raise InvalidIndexError(key)
100370
def from_array(cls, arr, index=None, name=None, dtype=None, copy=False,
                   fastpath=False):
        
        warnings.warn("'from_array' is deprecated and will be removed in a "
                      "future version. Please use the pd.Series(..) "
                      "constructor instead.", FutureWarning, stacklevel=2)
        if isinstance(arr, ABCSparseArray):
            from pandas.core.sparse.series import SparseSeries
            cls = SparseSeries
        return cls(arr, index=index, name=name, dtype=dtype,
                   copy=copy, fastpath=fastpath)
609100
def create_string_array(self, key, value):
        
        data = None
        if key is not None and value is not None:
            if isinstance(value, (list)):
                data = self.db.create(key.strip(), json.dumps(value))
            else:
                # used to save raw value with embedded variables
                data = self.db.create(key.strip(), value)
        else:
            self.tcex.log.warning(u'The key or value field was None.')
        return data
367177
function create(key, value) {
  if (!Buffer.isBuffer(key)) {
    throw new TypeError('expected buffer')
  }

  return {
    key,
    value,
    left: null,
    right: null,
    height: 0
  }
}
188294
def add(self, key, value=None):
        
        if value is None:
            value = 2 ** (len(self))

        self[key] = value
        setattr(self, key, self[key])
        return value
980166
def sanitize(value)
      case value

      when Integer
        value.to_s

      when Numeric, String
        connection.quote value

      when Array
        raise BadValue.new(value, "an empty array") if value.empty?
        raise BadValue.new(value, "a nested array") if value.any? { |v| v.is_a? Array }

        "(" + value.map { |v| sanitize v }.join(", ") + ")"

      when Literal
        value.value

      when Rows # rows for insertion
        value.values.map { |v| sanitize v }.join(", ")

      when Class
        connection.quote value.name

      when DateTime, Time, Date
        enforce_timezone do
          connection.quote value.to_s(:db)
        end

      when true
        connection.quoted_true

      when false
        connection.quoted_false

      when Symbol
        connection.quote value.to_s

      else
        raise BadValue, value
      end
    end