diff --git a/pandas/core/internals.py b/pandas/core/internals.py index 8d4473301a00a..159393be38b07 100644 --- a/pandas/core/internals.py +++ b/pandas/core/internals.py @@ -486,7 +486,7 @@ def where(self, other, cond, raise_on_error = True, try_cast = False): # our where function def func(c,v,o): - if c.flatten().all(): + if c.ravel().all(): return v try: @@ -649,7 +649,7 @@ class ObjectBlock(Block): @property def is_bool(self): """ we can be a bool if we have only bool values but are of type object """ - return lib.is_bool_array(self.values.flatten()) + return lib.is_bool_array(self.values.ravel()) def convert(self, convert_dates = True, convert_numeric = True, copy = True): """ attempt to coerce any object types to better types @@ -751,7 +751,7 @@ def make_block(values, items, ref_items): # try to infer a datetimeblock if klass is None and np.prod(values.shape): - flat = values.flatten() + flat = values.ravel() inferred_type = lib.infer_dtype(flat) if inferred_type == 'datetime': diff --git a/pandas/io/pytables.py b/pandas/io/pytables.py index 1db60eb92863d..8067d7e0be17f 100644 --- a/pandas/io/pytables.py +++ b/pandas/io/pytables.py @@ -1088,7 +1088,7 @@ def set_atom(self, block, existing_col, min_itemsize, nan_rep, **kwargs): self.values = list(block.items) dtype = block.dtype.name - inferred_type = lib.infer_dtype(block.values.flatten()) + inferred_type = lib.infer_dtype(block.values.ravel()) if inferred_type == 'datetime64': self.set_atom_datetime64(block) @@ -1116,7 +1116,7 @@ def set_atom_string(self, block, existing_col, min_itemsize, nan_rep): data = block.fillna(nan_rep).values # itemsize is the maximum length of a string (along any dimension) - itemsize = lib.max_len_string_array(data.flatten()) + itemsize = lib.max_len_string_array(data.ravel()) # specified min_itemsize? if isinstance(min_itemsize, dict): @@ -1209,7 +1209,7 @@ def convert(self, values, nan_rep): # convert nans if self.kind == 'string': self.data = lib.array_replace_from_nan_rep( - self.data.flatten(), nan_rep).reshape(self.data.shape) + self.data.ravel(), nan_rep).reshape(self.data.shape) return self def get_attr(self): @@ -1628,7 +1628,7 @@ def write_array(self, key, value): if value.dtype.type == np.object_: # infer the type, warn if we have a non-string type here (for performance) - inferred_type = lib.infer_dtype(value.flatten()) + inferred_type = lib.infer_dtype(value.ravel()) if empty_array: pass elif inferred_type == 'string': diff --git a/pandas/stats/var.py b/pandas/stats/var.py index 9390eef95700a..e993b60e18a39 100644 --- a/pandas/stats/var.py +++ b/pandas/stats/var.py @@ -342,7 +342,7 @@ def _forecast_cov_beta_raw(self, n): for t in xrange(T + 1): index = t + p - y = values.take(xrange(index, index - p, -1), axis=0).flatten() + y = values.take(xrange(index, index - p, -1), axis=0).ravel() trans_Z = np.hstack(([1], y)) trans_Z = trans_Z.reshape(1, len(trans_Z)) diff --git a/vb_suite/io_bench.py b/vb_suite/io_bench.py index 0fe0dd511e1b5..ba386bd0e9649 100644 --- a/vb_suite/io_bench.py +++ b/vb_suite/io_bench.py @@ -45,6 +45,20 @@ frame_to_csv = Benchmark("df.to_csv('__test__.csv')", setup, start_date=datetime(2011, 1, 1)) +#---------------------------------- +setup = common_setup + """ +from pandas import concat, Timestamp + +df_float = DataFrame(np.random.randn(1000, 30),dtype='float64') +df_int = DataFrame(np.random.randn(1000, 30),dtype='int64') +df_bool = DataFrame(True,index=df_float.index,columns=df_float.columns) +df_object = DataFrame('foo',index=df_float.index,columns=df_float.columns) +df_dt = DataFrame(Timestamp('20010101'),index=df_float.index,columns=df_float.columns) +df = concat([ df_float, df_int, df_bool, df_object, df_dt ], axis=1) +""" +frame_to_csv_mixed = Benchmark("df.to_csv('__test__.csv')", setup, + start_date=datetime(2012, 6, 1)) + #---------------------------------------------------------------------- # parse dates, ISO8601 format