someone pointed me function in pandas.algos couple of days ago (see https://stackoverflow.com/a/17705498/2565842) , can't find documentation on this. when type "algos" or "is_monotonic_float64" (the function in question) in pandas search box on http://pandas.pydata.org/pandas-docs/dev/, don't results. similarly, when ask google don't useful either.
the reason why looking docs having trouble types function accepts. have written 2 functions this:
def is_monotonic(time_series, cols): return time_series.loc[:,cols].apply(lambda x: pandas.algos.is_monotonic_float64(x)[0] if is_type(x, float) else "non_numeric data", axis=1) def is_type(series, t): return series.apply(lambda x: type(x) == t).all() i run on following dataframe
0 1 2 3 4 t t t t t b 0.2583974 0.3311106 0.933452 nan 0.1908287 c 0.4400121 0.9548238 0.2953693 0.7027355 0.6149148 d 0.4049013 0.5930965 0.7073495 0.3801416 0.4931772 but error
valueerror: ("buffer dtype mismatch, expected 'float64_t' got python object" when check types in dataframe, first row strings, others of type 'float'. need sort of type conversion numpy.float64 here?
not sure algos documentation. if undocumented can always, find in source code. function written cython high performance, it's particularly dense example.
but valueerror, might expect, each column's datatype has general enough accomodate of data. override executing df.convert_objects(convert_numeric). not number (e.g., t) replaced nan. numbers should become float64 type, , expect is_monotonic_float64 work.
alternatively, see there pd.algos.is_monotonic_object, i'm not sure how behaves, e.g. how compares t 0.25823974.
Comments
Post a Comment