Exemplo n.º 1
0
	def stack_cols(self, other):
		"""Stack two :class:`Dataset` instances together by
		joining at the column level, and return a new
		combined ``Dataset`` instance. If either ``Dataset``
		has headers set, than the other must as well."""

		if not isinstance(other, Dataset):
			return

		if self.headers or other.headers:
			if not self.headers or not other.headers:
				raise HeadersNeeded

		if self.height != other.height:
			raise InvalidDimensions

		try:
			new_headers = self.headers + other.headers
		except TypeError:
			new_headers = None

		_dset = Dataset()

		for column in self.headers:
			_dset.append_col(col=self[column])

		for column in other.headers:
			_dset.append_col(col=other[column])

		_dset.headers = new_headers

		return _dset