doc_content
stringlengths
1
386k
doc_id
stringlengths
5
188
pandas.tseries.offsets.WeekOfMonth.rollback WeekOfMonth.rollback() Roll provided date backward to next offset only if not on offset. Returns TimeStamp Rolled timestamp if not on offset, otherwise unchanged timestamp.
pandas.reference.api.pandas.tseries.offsets.weekofmonth.rollback
pandas.tseries.offsets.WeekOfMonth.rollforward WeekOfMonth.rollforward() Roll provided date forward to next offset only if not on offset. Returns TimeStamp Rolled timestamp if not on offset, otherwise unchanged timestamp.
pandas.reference.api.pandas.tseries.offsets.weekofmonth.rollforward
pandas.tseries.offsets.WeekOfMonth.rule_code WeekOfMonth.rule_code
pandas.reference.api.pandas.tseries.offsets.weekofmonth.rule_code
pandas.tseries.offsets.WeekOfMonth.week WeekOfMonth.week
pandas.reference.api.pandas.tseries.offsets.weekofmonth.week
pandas.tseries.offsets.WeekOfMonth.weekday WeekOfMonth.weekday
pandas.reference.api.pandas.tseries.offsets.weekofmonth.weekday
pandas.tseries.offsets.YearBegin classpandas.tseries.offsets.YearBegin DateOffset increments between calendar year begin dates. Attributes base Returns a copy of the calling offset object with n=1 and all other attributes equal. freqstr kwds month n name nanos normalize rule_code Methods __call__(*args, **kwargs) Call self as a function. rollback Roll provided date backward to next offset only if not on offset. rollforward Roll provided date forward to next offset only if not on offset. apply apply_index copy isAnchored is_anchored is_month_end is_month_start is_on_offset is_quarter_end is_quarter_start is_year_end is_year_start onOffset
pandas.reference.api.pandas.tseries.offsets.yearbegin
pandas.tseries.offsets.YearBegin.__call__ YearBegin.__call__(*args, **kwargs) Call self as a function.
pandas.reference.api.pandas.tseries.offsets.yearbegin.__call__
pandas.tseries.offsets.YearBegin.apply YearBegin.apply()
pandas.reference.api.pandas.tseries.offsets.yearbegin.apply
pandas.tseries.offsets.YearBegin.apply_index YearBegin.apply_index(other)
pandas.reference.api.pandas.tseries.offsets.yearbegin.apply_index
pandas.tseries.offsets.YearBegin.base YearBegin.base Returns a copy of the calling offset object with n=1 and all other attributes equal.
pandas.reference.api.pandas.tseries.offsets.yearbegin.base
pandas.tseries.offsets.YearBegin.copy YearBegin.copy()
pandas.reference.api.pandas.tseries.offsets.yearbegin.copy
pandas.tseries.offsets.YearBegin.freqstr YearBegin.freqstr
pandas.reference.api.pandas.tseries.offsets.yearbegin.freqstr
pandas.tseries.offsets.YearBegin.is_anchored YearBegin.is_anchored()
pandas.reference.api.pandas.tseries.offsets.yearbegin.is_anchored
pandas.tseries.offsets.YearBegin.is_month_end YearBegin.is_month_end()
pandas.reference.api.pandas.tseries.offsets.yearbegin.is_month_end
pandas.tseries.offsets.YearBegin.is_month_start YearBegin.is_month_start()
pandas.reference.api.pandas.tseries.offsets.yearbegin.is_month_start
pandas.tseries.offsets.YearBegin.is_on_offset YearBegin.is_on_offset()
pandas.reference.api.pandas.tseries.offsets.yearbegin.is_on_offset
pandas.tseries.offsets.YearBegin.is_quarter_end YearBegin.is_quarter_end()
pandas.reference.api.pandas.tseries.offsets.yearbegin.is_quarter_end
pandas.tseries.offsets.YearBegin.is_quarter_start YearBegin.is_quarter_start()
pandas.reference.api.pandas.tseries.offsets.yearbegin.is_quarter_start
pandas.tseries.offsets.YearBegin.is_year_end YearBegin.is_year_end()
pandas.reference.api.pandas.tseries.offsets.yearbegin.is_year_end
pandas.tseries.offsets.YearBegin.is_year_start YearBegin.is_year_start()
pandas.reference.api.pandas.tseries.offsets.yearbegin.is_year_start
pandas.tseries.offsets.YearBegin.isAnchored YearBegin.isAnchored()
pandas.reference.api.pandas.tseries.offsets.yearbegin.isanchored
pandas.tseries.offsets.YearBegin.kwds YearBegin.kwds
pandas.reference.api.pandas.tseries.offsets.yearbegin.kwds
pandas.tseries.offsets.YearBegin.month YearBegin.month
pandas.reference.api.pandas.tseries.offsets.yearbegin.month
pandas.tseries.offsets.YearBegin.n YearBegin.n
pandas.reference.api.pandas.tseries.offsets.yearbegin.n
pandas.tseries.offsets.YearBegin.name YearBegin.name
pandas.reference.api.pandas.tseries.offsets.yearbegin.name
pandas.tseries.offsets.YearBegin.nanos YearBegin.nanos
pandas.reference.api.pandas.tseries.offsets.yearbegin.nanos
pandas.tseries.offsets.YearBegin.normalize YearBegin.normalize
pandas.reference.api.pandas.tseries.offsets.yearbegin.normalize
pandas.tseries.offsets.YearBegin.onOffset YearBegin.onOffset()
pandas.reference.api.pandas.tseries.offsets.yearbegin.onoffset
pandas.tseries.offsets.YearBegin.rollback YearBegin.rollback() Roll provided date backward to next offset only if not on offset. Returns TimeStamp Rolled timestamp if not on offset, otherwise unchanged timestamp.
pandas.reference.api.pandas.tseries.offsets.yearbegin.rollback
pandas.tseries.offsets.YearBegin.rollforward YearBegin.rollforward() Roll provided date forward to next offset only if not on offset. Returns TimeStamp Rolled timestamp if not on offset, otherwise unchanged timestamp.
pandas.reference.api.pandas.tseries.offsets.yearbegin.rollforward
pandas.tseries.offsets.YearBegin.rule_code YearBegin.rule_code
pandas.reference.api.pandas.tseries.offsets.yearbegin.rule_code
pandas.tseries.offsets.YearEnd classpandas.tseries.offsets.YearEnd DateOffset increments between calendar year ends. Attributes base Returns a copy of the calling offset object with n=1 and all other attributes equal. freqstr kwds month n name nanos normalize rule_code Methods __call__(*args, **kwargs) Call self as a function. rollback Roll provided date backward to next offset only if not on offset. rollforward Roll provided date forward to next offset only if not on offset. apply apply_index copy isAnchored is_anchored is_month_end is_month_start is_on_offset is_quarter_end is_quarter_start is_year_end is_year_start onOffset
pandas.reference.api.pandas.tseries.offsets.yearend
pandas.tseries.offsets.YearEnd.__call__ YearEnd.__call__(*args, **kwargs) Call self as a function.
pandas.reference.api.pandas.tseries.offsets.yearend.__call__
pandas.tseries.offsets.YearEnd.apply YearEnd.apply()
pandas.reference.api.pandas.tseries.offsets.yearend.apply
pandas.tseries.offsets.YearEnd.apply_index YearEnd.apply_index(other)
pandas.reference.api.pandas.tseries.offsets.yearend.apply_index
pandas.tseries.offsets.YearEnd.base YearEnd.base Returns a copy of the calling offset object with n=1 and all other attributes equal.
pandas.reference.api.pandas.tseries.offsets.yearend.base
pandas.tseries.offsets.YearEnd.copy YearEnd.copy()
pandas.reference.api.pandas.tseries.offsets.yearend.copy
pandas.tseries.offsets.YearEnd.freqstr YearEnd.freqstr
pandas.reference.api.pandas.tseries.offsets.yearend.freqstr
pandas.tseries.offsets.YearEnd.is_anchored YearEnd.is_anchored()
pandas.reference.api.pandas.tseries.offsets.yearend.is_anchored
pandas.tseries.offsets.YearEnd.is_month_end YearEnd.is_month_end()
pandas.reference.api.pandas.tseries.offsets.yearend.is_month_end
pandas.tseries.offsets.YearEnd.is_month_start YearEnd.is_month_start()
pandas.reference.api.pandas.tseries.offsets.yearend.is_month_start
pandas.tseries.offsets.YearEnd.is_on_offset YearEnd.is_on_offset()
pandas.reference.api.pandas.tseries.offsets.yearend.is_on_offset
pandas.tseries.offsets.YearEnd.is_quarter_end YearEnd.is_quarter_end()
pandas.reference.api.pandas.tseries.offsets.yearend.is_quarter_end
pandas.tseries.offsets.YearEnd.is_quarter_start YearEnd.is_quarter_start()
pandas.reference.api.pandas.tseries.offsets.yearend.is_quarter_start
pandas.tseries.offsets.YearEnd.is_year_end YearEnd.is_year_end()
pandas.reference.api.pandas.tseries.offsets.yearend.is_year_end
pandas.tseries.offsets.YearEnd.is_year_start YearEnd.is_year_start()
pandas.reference.api.pandas.tseries.offsets.yearend.is_year_start
pandas.tseries.offsets.YearEnd.isAnchored YearEnd.isAnchored()
pandas.reference.api.pandas.tseries.offsets.yearend.isanchored
pandas.tseries.offsets.YearEnd.kwds YearEnd.kwds
pandas.reference.api.pandas.tseries.offsets.yearend.kwds
pandas.tseries.offsets.YearEnd.month YearEnd.month
pandas.reference.api.pandas.tseries.offsets.yearend.month
pandas.tseries.offsets.YearEnd.n YearEnd.n
pandas.reference.api.pandas.tseries.offsets.yearend.n
pandas.tseries.offsets.YearEnd.name YearEnd.name
pandas.reference.api.pandas.tseries.offsets.yearend.name
pandas.tseries.offsets.YearEnd.nanos YearEnd.nanos
pandas.reference.api.pandas.tseries.offsets.yearend.nanos
pandas.tseries.offsets.YearEnd.normalize YearEnd.normalize
pandas.reference.api.pandas.tseries.offsets.yearend.normalize
pandas.tseries.offsets.YearEnd.onOffset YearEnd.onOffset()
pandas.reference.api.pandas.tseries.offsets.yearend.onoffset
pandas.tseries.offsets.YearEnd.rollback YearEnd.rollback() Roll provided date backward to next offset only if not on offset. Returns TimeStamp Rolled timestamp if not on offset, otherwise unchanged timestamp.
pandas.reference.api.pandas.tseries.offsets.yearend.rollback
pandas.tseries.offsets.YearEnd.rollforward YearEnd.rollforward() Roll provided date forward to next offset only if not on offset. Returns TimeStamp Rolled timestamp if not on offset, otherwise unchanged timestamp.
pandas.reference.api.pandas.tseries.offsets.yearend.rollforward
pandas.tseries.offsets.YearEnd.rule_code YearEnd.rule_code
pandas.reference.api.pandas.tseries.offsets.yearend.rule_code
pandas.UInt16Dtype classpandas.UInt16Dtype[source] An ExtensionDtype for uint16 integer data. Changed in version 1.0.0: Now uses pandas.NA as its missing value, rather than numpy.nan. Attributes None Methods None
pandas.reference.api.pandas.uint16dtype
pandas.UInt32Dtype classpandas.UInt32Dtype[source] An ExtensionDtype for uint32 integer data. Changed in version 1.0.0: Now uses pandas.NA as its missing value, rather than numpy.nan. Attributes None Methods None
pandas.reference.api.pandas.uint32dtype
pandas.UInt64Dtype classpandas.UInt64Dtype[source] An ExtensionDtype for uint64 integer data. Changed in version 1.0.0: Now uses pandas.NA as its missing value, rather than numpy.nan. Attributes None Methods None
pandas.reference.api.pandas.uint64dtype
pandas.UInt64Index classpandas.UInt64Index(data=None, dtype=None, copy=False, name=None)[source] Immutable sequence used for indexing and alignment. The basic object storing axis labels for all pandas objects. UInt64Index is a special case of Index with purely unsigned integer labels. . Deprecated since version 1.4.0: In pandas v2.0 UInt64Index will be removed and NumericIndex used instead. UInt64Index will remain fully functional for the duration of pandas 1.x. Parameters data:array-like (1-dimensional) dtype:NumPy dtype (default: uint64) copy:bool Make a copy of input ndarray. name:object Name to be stored in the index. See also Index The base pandas Index type. NumericIndex Index of numpy int/uint/float data. Notes An Index instance can only contain hashable objects. Attributes None Methods None
pandas.reference.api.pandas.uint64index
pandas.UInt8Dtype classpandas.UInt8Dtype[source] An ExtensionDtype for uint8 integer data. Changed in version 1.0.0: Now uses pandas.NA as its missing value, rather than numpy.nan. Attributes None Methods None
pandas.reference.api.pandas.uint8dtype
pandas.unique pandas.unique(values)[source] Return unique values based on a hash table. Uniques are returned in order of appearance. This does NOT sort. Significantly faster than numpy.unique for long enough sequences. Includes NA values. Parameters values:1d array-like Returns numpy.ndarray or ExtensionArray The return can be: Index : when the input is an Index Categorical : when the input is a Categorical dtype ndarray : when the input is a Series/ndarray Return numpy.ndarray or ExtensionArray. See also Index.unique Return unique values from an Index. Series.unique Return unique values of Series object. Examples >>> pd.unique(pd.Series([2, 1, 3, 3])) array([2, 1, 3]) >>> pd.unique(pd.Series([2] + [1] * 5)) array([2, 1]) >>> pd.unique(pd.Series([pd.Timestamp("20160101"), pd.Timestamp("20160101")])) array(['2016-01-01T00:00:00.000000000'], dtype='datetime64[ns]') >>> pd.unique( ... pd.Series( ... [ ... pd.Timestamp("20160101", tz="US/Eastern"), ... pd.Timestamp("20160101", tz="US/Eastern"), ... ] ... ) ... ) <DatetimeArray> ['2016-01-01 00:00:00-05:00'] Length: 1, dtype: datetime64[ns, US/Eastern] >>> pd.unique( ... pd.Index( ... [ ... pd.Timestamp("20160101", tz="US/Eastern"), ... pd.Timestamp("20160101", tz="US/Eastern"), ... ] ... ) ... ) DatetimeIndex(['2016-01-01 00:00:00-05:00'], dtype='datetime64[ns, US/Eastern]', freq=None) >>> pd.unique(list("baabc")) array(['b', 'a', 'c'], dtype=object) An unordered Categorical will return categories in the order of appearance. >>> pd.unique(pd.Series(pd.Categorical(list("baabc")))) ['b', 'a', 'c'] Categories (3, object): ['a', 'b', 'c'] >>> pd.unique(pd.Series(pd.Categorical(list("baabc"), categories=list("abc")))) ['b', 'a', 'c'] Categories (3, object): ['a', 'b', 'c'] An ordered Categorical preserves the category ordering. >>> pd.unique( ... pd.Series( ... pd.Categorical(list("baabc"), categories=list("abc"), ordered=True) ... ) ... ) ['b', 'a', 'c'] Categories (3, object): ['a' < 'b' < 'c'] An array of tuples >>> pd.unique([("a", "b"), ("b", "a"), ("a", "c"), ("b", "a")]) array([('a', 'b'), ('b', 'a'), ('a', 'c')], dtype=object)
pandas.reference.api.pandas.unique
pandas.util.hash_array pandas.util.hash_array(vals, encoding='utf8', hash_key='0123456789123456', categorize=True)[source] Given a 1d array, return an array of deterministic integers. Parameters vals:ndarray or ExtensionArray encoding:str, default ‘utf8’ Encoding for data & key when strings. hash_key:str, default _default_hash_key Hash_key for string key to encode. categorize:bool, default True Whether to first categorize object arrays before hashing. This is more efficient when the array contains duplicate values. Returns ndarray[np.uint64, ndim=1] Hashed values, same length as the vals.
pandas.reference.api.pandas.util.hash_array
pandas.util.hash_pandas_object pandas.util.hash_pandas_object(obj, index=True, encoding='utf8', hash_key='0123456789123456', categorize=True)[source] Return a data hash of the Index/Series/DataFrame. Parameters obj:Index, Series, or DataFrame index:bool, default True Include the index in the hash (if Series/DataFrame). encoding:str, default ‘utf8’ Encoding for data & key when strings. hash_key:str, default _default_hash_key Hash_key for string key to encode. categorize:bool, default True Whether to first categorize object arrays before hashing. This is more efficient when the array contains duplicate values. Returns Series of uint64, same length as the object
pandas.reference.api.pandas.util.hash_pandas_object
pandas.wide_to_long pandas.wide_to_long(df, stubnames, i, j, sep='', suffix='\\d+')[source] Unpivot a DataFrame from wide to long format. Less flexible but more user-friendly than melt. With stubnames [‘A’, ‘B’], this function expects to find one or more group of columns with format A-suffix1, A-suffix2,…, B-suffix1, B-suffix2,… You specify what you want to call this suffix in the resulting long format with j (for example j=’year’) Each row of these wide variables are assumed to be uniquely identified by i (can be a single column name or a list of column names) All remaining variables in the data frame are left intact. Parameters df:DataFrame The wide-format DataFrame. stubnames:str or list-like The stub name(s). The wide format variables are assumed to start with the stub names. i:str or list-like Column(s) to use as id variable(s). j:str The name of the sub-observation variable. What you wish to name your suffix in the long format. sep:str, default “” A character indicating the separation of the variable names in the wide format, to be stripped from the names in the long format. For example, if your column names are A-suffix1, A-suffix2, you can strip the hyphen by specifying sep=’-’. suffix:str, default ‘\d+’ A regular expression capturing the wanted suffixes. ‘\d+’ captures numeric suffixes. Suffixes with no numbers could be specified with the negated character class ‘\D+’. You can also further disambiguate suffixes, for example, if your wide variables are of the form A-one, B-two,.., and you have an unrelated column A-rating, you can ignore the last one by specifying suffix=’(!?one|two)’. When all suffixes are numeric, they are cast to int64/float64. Returns DataFrame A DataFrame that contains each stub name as a variable, with new index (i, j). See also melt Unpivot a DataFrame from wide to long format, optionally leaving identifiers set. pivot Create a spreadsheet-style pivot table as a DataFrame. DataFrame.pivot Pivot without aggregation that can handle non-numeric data. DataFrame.pivot_table Generalization of pivot that can handle duplicate values for one index/column pair. DataFrame.unstack Pivot based on the index values instead of a column. Notes All extra variables are left untouched. This simply uses pandas.melt under the hood, but is hard-coded to “do the right thing” in a typical case. Examples >>> np.random.seed(123) >>> df = pd.DataFrame({"A1970" : {0 : "a", 1 : "b", 2 : "c"}, ... "A1980" : {0 : "d", 1 : "e", 2 : "f"}, ... "B1970" : {0 : 2.5, 1 : 1.2, 2 : .7}, ... "B1980" : {0 : 3.2, 1 : 1.3, 2 : .1}, ... "X" : dict(zip(range(3), np.random.randn(3))) ... }) >>> df["id"] = df.index >>> df A1970 A1980 B1970 B1980 X id 0 a d 2.5 3.2 -1.085631 0 1 b e 1.2 1.3 0.997345 1 2 c f 0.7 0.1 0.282978 2 >>> pd.wide_to_long(df, ["A", "B"], i="id", j="year") ... X A B id year 0 1970 -1.085631 a 2.5 1 1970 0.997345 b 1.2 2 1970 0.282978 c 0.7 0 1980 -1.085631 d 3.2 1 1980 0.997345 e 1.3 2 1980 0.282978 f 0.1 With multiple id columns >>> df = pd.DataFrame({ ... 'famid': [1, 1, 1, 2, 2, 2, 3, 3, 3], ... 'birth': [1, 2, 3, 1, 2, 3, 1, 2, 3], ... 'ht1': [2.8, 2.9, 2.2, 2, 1.8, 1.9, 2.2, 2.3, 2.1], ... 'ht2': [3.4, 3.8, 2.9, 3.2, 2.8, 2.4, 3.3, 3.4, 2.9] ... }) >>> df famid birth ht1 ht2 0 1 1 2.8 3.4 1 1 2 2.9 3.8 2 1 3 2.2 2.9 3 2 1 2.0 3.2 4 2 2 1.8 2.8 5 2 3 1.9 2.4 6 3 1 2.2 3.3 7 3 2 2.3 3.4 8 3 3 2.1 2.9 >>> l = pd.wide_to_long(df, stubnames='ht', i=['famid', 'birth'], j='age') >>> l ... ht famid birth age 1 1 1 2.8 2 3.4 2 1 2.9 2 3.8 3 1 2.2 2 2.9 2 1 1 2.0 2 3.2 2 1 1.8 2 2.8 3 1 1.9 2 2.4 3 1 1 2.2 2 3.3 2 1 2.3 2 3.4 3 1 2.1 2 2.9 Going from long back to wide just takes some creative use of unstack >>> w = l.unstack() >>> w.columns = w.columns.map('{0[0]}{0[1]}'.format) >>> w.reset_index() famid birth ht1 ht2 0 1 1 2.8 3.4 1 1 2 2.9 3.8 2 1 3 2.2 2.9 3 2 1 2.0 3.2 4 2 2 1.8 2.8 5 2 3 1.9 2.4 6 3 1 2.2 3.3 7 3 2 2.3 3.4 8 3 3 2.1 2.9 Less wieldy column names are also handled >>> np.random.seed(0) >>> df = pd.DataFrame({'A(weekly)-2010': np.random.rand(3), ... 'A(weekly)-2011': np.random.rand(3), ... 'B(weekly)-2010': np.random.rand(3), ... 'B(weekly)-2011': np.random.rand(3), ... 'X' : np.random.randint(3, size=3)}) >>> df['id'] = df.index >>> df A(weekly)-2010 A(weekly)-2011 B(weekly)-2010 B(weekly)-2011 X id 0 0.548814 0.544883 0.437587 0.383442 0 0 1 0.715189 0.423655 0.891773 0.791725 1 1 2 0.602763 0.645894 0.963663 0.528895 1 2 >>> pd.wide_to_long(df, ['A(weekly)', 'B(weekly)'], i='id', ... j='year', sep='-') ... X A(weekly) B(weekly) id year 0 2010 0 0.548814 0.437587 1 2010 1 0.715189 0.891773 2 2010 1 0.602763 0.963663 0 2011 0 0.544883 0.383442 1 2011 1 0.423655 0.791725 2 2011 1 0.645894 0.528895 If we have many columns, we could also use a regex to find our stubnames and pass that list on to wide_to_long >>> stubnames = sorted( ... set([match[0] for match in df.columns.str.findall( ... r'[A-B]\(.*\)').values if match != []]) ... ) >>> list(stubnames) ['A(weekly)', 'B(weekly)'] All of the above examples have integers as suffixes. It is possible to have non-integers as suffixes. >>> df = pd.DataFrame({ ... 'famid': [1, 1, 1, 2, 2, 2, 3, 3, 3], ... 'birth': [1, 2, 3, 1, 2, 3, 1, 2, 3], ... 'ht_one': [2.8, 2.9, 2.2, 2, 1.8, 1.9, 2.2, 2.3, 2.1], ... 'ht_two': [3.4, 3.8, 2.9, 3.2, 2.8, 2.4, 3.3, 3.4, 2.9] ... }) >>> df famid birth ht_one ht_two 0 1 1 2.8 3.4 1 1 2 2.9 3.8 2 1 3 2.2 2.9 3 2 1 2.0 3.2 4 2 2 1.8 2.8 5 2 3 1.9 2.4 6 3 1 2.2 3.3 7 3 2 2.3 3.4 8 3 3 2.1 2.9 >>> l = pd.wide_to_long(df, stubnames='ht', i=['famid', 'birth'], j='age', ... sep='_', suffix=r'\w+') >>> l ... ht famid birth age 1 1 one 2.8 two 3.4 2 one 2.9 two 3.8 3 one 2.2 two 2.9 2 1 one 2.0 two 3.2 2 one 1.8 two 2.8 3 one 1.9 two 2.4 3 1 one 2.2 two 3.3 2 one 2.3 two 3.4 3 one 2.1 two 2.9
pandas.reference.api.pandas.wide_to_long
Plotting The following functions are contained in the pandas.plotting module. andrews_curves(frame, class_column[, ax, ...]) Generate a matplotlib plot of Andrews curves, for visualising clusters of multivariate data. autocorrelation_plot(series[, ax]) Autocorrelation plot for time series. bootstrap_plot(series[, fig, size, samples]) Bootstrap plot on mean, median and mid-range statistics. boxplot(data[, column, by, ax, fontsize, ...]) Make a box plot from DataFrame columns. deregister_matplotlib_converters() Remove pandas formatters and converters. lag_plot(series[, lag, ax]) Lag plot for time series. parallel_coordinates(frame, class_column[, ...]) Parallel coordinates plotting. plot_params Stores pandas plotting options. radviz(frame, class_column[, ax, color, ...]) Plot a multidimensional dataset in 2D. register_matplotlib_converters() Register pandas formatters and converters with matplotlib. scatter_matrix(frame[, alpha, figsize, ax, ...]) Draw a matrix of scatter plots. table(ax, data[, rowLabels, colLabels]) Helper function to convert DataFrame and Series to matplotlib.table.
pandas.reference.plotting
Resampling Resampler objects are returned by resample calls: pandas.DataFrame.resample(), pandas.Series.resample(). Indexing, iteration Resampler.__iter__() Groupby iterator. Resampler.groups Dict {group name -> group labels}. Resampler.indices Dict {group name -> group indices}. Resampler.get_group(name[, obj]) Construct DataFrame from group with provided name. Function application Resampler.apply([func]) Aggregate using one or more operations over the specified axis. Resampler.aggregate([func]) Aggregate using one or more operations over the specified axis. Resampler.transform(arg, *args, **kwargs) Call function producing a like-indexed Series on each group and return a Series with the transformed values. Resampler.pipe(func, *args, **kwargs) Apply a function func with arguments to this Resampler object and return the function's result. Upsampling Resampler.ffill([limit]) Forward fill the values. Resampler.backfill([limit]) Backward fill the new missing values in the resampled data. Resampler.bfill([limit]) Backward fill the new missing values in the resampled data. Resampler.pad([limit]) Forward fill the values. Resampler.nearest([limit]) Resample by using the nearest value. Resampler.fillna(method[, limit]) Fill missing values introduced by upsampling. Resampler.asfreq([fill_value]) Return the values at the new freq, essentially a reindex. Resampler.interpolate([method, axis, limit, ...]) Interpolate values according to different methods. Computations / descriptive stats Resampler.count() Compute count of group, excluding missing values. Resampler.nunique([_method]) Return number of unique elements in the group. Resampler.first([_method, min_count]) Compute first of group values. Resampler.last([_method, min_count]) Compute last of group values. Resampler.max([_method, min_count]) Compute max of group values. Resampler.mean([_method]) Compute mean of groups, excluding missing values. Resampler.median([_method]) Compute median of groups, excluding missing values. Resampler.min([_method, min_count]) Compute min of group values. Resampler.ohlc([_method]) Compute open, high, low and close values of a group, excluding missing values. Resampler.prod([_method, min_count]) Compute prod of group values. Resampler.size() Compute group sizes. Resampler.sem([_method]) Compute standard error of the mean of groups, excluding missing values. Resampler.std([ddof]) Compute standard deviation of groups, excluding missing values. Resampler.sum([_method, min_count]) Compute sum of group values. Resampler.var([ddof]) Compute variance of groups, excluding missing values. Resampler.quantile([q]) Return value at the given quantile.
pandas.reference.resampling
Series Constructor Series([data, index, dtype, name, copy, ...]) One-dimensional ndarray with axis labels (including time series). Attributes Axes Series.index The index (axis labels) of the Series. Series.array The ExtensionArray of the data backing this Series or Index. Series.values Return Series as ndarray or ndarray-like depending on the dtype. Series.dtype Return the dtype object of the underlying data. Series.shape Return a tuple of the shape of the underlying data. Series.nbytes Return the number of bytes in the underlying data. Series.ndim Number of dimensions of the underlying data, by definition 1. Series.size Return the number of elements in the underlying data. Series.T Return the transpose, which is by definition self. Series.memory_usage([index, deep]) Return the memory usage of the Series. Series.hasnans Return True if there are any NaNs. Series.empty Indicator whether Series/DataFrame is empty. Series.dtypes Return the dtype object of the underlying data. Series.name Return the name of the Series. Series.flags Get the properties associated with this pandas object. Series.set_flags(*[, copy, ...]) Return a new object with updated flags. Conversion Series.astype(dtype[, copy, errors]) Cast a pandas object to a specified dtype dtype. Series.convert_dtypes([infer_objects, ...]) Convert columns to best possible dtypes using dtypes supporting pd.NA. Series.infer_objects() Attempt to infer better dtypes for object columns. Series.copy([deep]) Make a copy of this object's indices and data. Series.bool() Return the bool of a single element Series or DataFrame. Series.to_numpy([dtype, copy, na_value]) A NumPy ndarray representing the values in this Series or Index. Series.to_period([freq, copy]) Convert Series from DatetimeIndex to PeriodIndex. Series.to_timestamp([freq, how, copy]) Cast to DatetimeIndex of Timestamps, at beginning of period. Series.to_list() Return a list of the values. Series.__array__([dtype]) Return the values as a NumPy array. Indexing, iteration Series.get(key[, default]) Get item from object for given key (ex: DataFrame column). Series.at Access a single value for a row/column label pair. Series.iat Access a single value for a row/column pair by integer position. Series.loc Access a group of rows and columns by label(s) or a boolean array. Series.iloc Purely integer-location based indexing for selection by position. Series.__iter__() Return an iterator of the values. Series.items() Lazily iterate over (index, value) tuples. Series.iteritems() Lazily iterate over (index, value) tuples. Series.keys() Return alias for index. Series.pop(item) Return item and drops from series. Series.item() Return the first element of the underlying data as a Python scalar. Series.xs(key[, axis, level, drop_level]) Return cross-section from the Series/DataFrame. For more information on .at, .iat, .loc, and .iloc, see the indexing documentation. Binary operator functions Series.add(other[, level, fill_value, axis]) Return Addition of series and other, element-wise (binary operator add). Series.sub(other[, level, fill_value, axis]) Return Subtraction of series and other, element-wise (binary operator sub). Series.mul(other[, level, fill_value, axis]) Return Multiplication of series and other, element-wise (binary operator mul). Series.div(other[, level, fill_value, axis]) Return Floating division of series and other, element-wise (binary operator truediv). Series.truediv(other[, level, fill_value, axis]) Return Floating division of series and other, element-wise (binary operator truediv). Series.floordiv(other[, level, fill_value, axis]) Return Integer division of series and other, element-wise (binary operator floordiv). Series.mod(other[, level, fill_value, axis]) Return Modulo of series and other, element-wise (binary operator mod). Series.pow(other[, level, fill_value, axis]) Return Exponential power of series and other, element-wise (binary operator pow). Series.radd(other[, level, fill_value, axis]) Return Addition of series and other, element-wise (binary operator radd). Series.rsub(other[, level, fill_value, axis]) Return Subtraction of series and other, element-wise (binary operator rsub). Series.rmul(other[, level, fill_value, axis]) Return Multiplication of series and other, element-wise (binary operator rmul). Series.rdiv(other[, level, fill_value, axis]) Return Floating division of series and other, element-wise (binary operator rtruediv). Series.rtruediv(other[, level, fill_value, axis]) Return Floating division of series and other, element-wise (binary operator rtruediv). Series.rfloordiv(other[, level, fill_value, ...]) Return Integer division of series and other, element-wise (binary operator rfloordiv). Series.rmod(other[, level, fill_value, axis]) Return Modulo of series and other, element-wise (binary operator rmod). Series.rpow(other[, level, fill_value, axis]) Return Exponential power of series and other, element-wise (binary operator rpow). Series.combine(other, func[, fill_value]) Combine the Series with a Series or scalar according to func. Series.combine_first(other) Update null elements with value in the same location in 'other'. Series.round([decimals]) Round each value in a Series to the given number of decimals. Series.lt(other[, level, fill_value, axis]) Return Less than of series and other, element-wise (binary operator lt). Series.gt(other[, level, fill_value, axis]) Return Greater than of series and other, element-wise (binary operator gt). Series.le(other[, level, fill_value, axis]) Return Less than or equal to of series and other, element-wise (binary operator le). Series.ge(other[, level, fill_value, axis]) Return Greater than or equal to of series and other, element-wise (binary operator ge). Series.ne(other[, level, fill_value, axis]) Return Not equal to of series and other, element-wise (binary operator ne). Series.eq(other[, level, fill_value, axis]) Return Equal to of series and other, element-wise (binary operator eq). Series.product([axis, skipna, level, ...]) Return the product of the values over the requested axis. Series.dot(other) Compute the dot product between the Series and the columns of other. Function application, GroupBy & window Series.apply(func[, convert_dtype, args]) Invoke function on values of Series. Series.agg([func, axis]) Aggregate using one or more operations over the specified axis. Series.aggregate([func, axis]) Aggregate using one or more operations over the specified axis. Series.transform(func[, axis]) Call func on self producing a Series with the same axis shape as self. Series.map(arg[, na_action]) Map values of Series according to an input mapping or function. Series.groupby([by, axis, level, as_index, ...]) Group Series using a mapper or by a Series of columns. Series.rolling(window[, min_periods, ...]) Provide rolling window calculations. Series.expanding([min_periods, center, ...]) Provide expanding window calculations. Series.ewm([com, span, halflife, alpha, ...]) Provide exponentially weighted (EW) calculations. Series.pipe(func, *args, **kwargs) Apply chainable functions that expect Series or DataFrames. Computations / descriptive stats Series.abs() Return a Series/DataFrame with absolute numeric value of each element. Series.all([axis, bool_only, skipna, level]) Return whether all elements are True, potentially over an axis. Series.any([axis, bool_only, skipna, level]) Return whether any element is True, potentially over an axis. Series.autocorr([lag]) Compute the lag-N autocorrelation. Series.between(left, right[, inclusive]) Return boolean Series equivalent to left <= series <= right. Series.clip([lower, upper, axis, inplace]) Trim values at input threshold(s). Series.corr(other[, method, min_periods]) Compute correlation with other Series, excluding missing values. Series.count([level]) Return number of non-NA/null observations in the Series. Series.cov(other[, min_periods, ddof]) Compute covariance with Series, excluding missing values. Series.cummax([axis, skipna]) Return cumulative maximum over a DataFrame or Series axis. Series.cummin([axis, skipna]) Return cumulative minimum over a DataFrame or Series axis. Series.cumprod([axis, skipna]) Return cumulative product over a DataFrame or Series axis. Series.cumsum([axis, skipna]) Return cumulative sum over a DataFrame or Series axis. Series.describe([percentiles, include, ...]) Generate descriptive statistics. Series.diff([periods]) First discrete difference of element. Series.factorize([sort, na_sentinel]) Encode the object as an enumerated type or categorical variable. Series.kurt([axis, skipna, level, numeric_only]) Return unbiased kurtosis over requested axis. Series.mad([axis, skipna, level]) Return the mean absolute deviation of the values over the requested axis. Series.max([axis, skipna, level, numeric_only]) Return the maximum of the values over the requested axis. Series.mean([axis, skipna, level, numeric_only]) Return the mean of the values over the requested axis. Series.median([axis, skipna, level, ...]) Return the median of the values over the requested axis. Series.min([axis, skipna, level, numeric_only]) Return the minimum of the values over the requested axis. Series.mode([dropna]) Return the mode(s) of the Series. Series.nlargest([n, keep]) Return the largest n elements. Series.nsmallest([n, keep]) Return the smallest n elements. Series.pct_change([periods, fill_method, ...]) Percentage change between the current and a prior element. Series.prod([axis, skipna, level, ...]) Return the product of the values over the requested axis. Series.quantile([q, interpolation]) Return value at the given quantile. Series.rank([axis, method, numeric_only, ...]) Compute numerical data ranks (1 through n) along axis. Series.sem([axis, skipna, level, ddof, ...]) Return unbiased standard error of the mean over requested axis. Series.skew([axis, skipna, level, numeric_only]) Return unbiased skew over requested axis. Series.std([axis, skipna, level, ddof, ...]) Return sample standard deviation over requested axis. Series.sum([axis, skipna, level, ...]) Return the sum of the values over the requested axis. Series.var([axis, skipna, level, ddof, ...]) Return unbiased variance over requested axis. Series.kurtosis([axis, skipna, level, ...]) Return unbiased kurtosis over requested axis. Series.unique() Return unique values of Series object. Series.nunique([dropna]) Return number of unique elements in the object. Series.is_unique Return boolean if values in the object are unique. Series.is_monotonic Return boolean if values in the object are monotonic_increasing. Series.is_monotonic_increasing Alias for is_monotonic. Series.is_monotonic_decreasing Return boolean if values in the object are monotonic_decreasing. Series.value_counts([normalize, sort, ...]) Return a Series containing counts of unique values. Reindexing / selection / label manipulation Series.align(other[, join, axis, level, ...]) Align two objects on their axes with the specified join method. Series.drop([labels, axis, index, columns, ...]) Return Series with specified index labels removed. Series.droplevel(level[, axis]) Return Series/DataFrame with requested index / column level(s) removed. Series.drop_duplicates([keep, inplace]) Return Series with duplicate values removed. Series.duplicated([keep]) Indicate duplicate Series values. Series.equals(other) Test whether two objects contain the same elements. Series.first(offset) Select initial periods of time series data based on a date offset. Series.head([n]) Return the first n rows. Series.idxmax([axis, skipna]) Return the row label of the maximum value. Series.idxmin([axis, skipna]) Return the row label of the minimum value. Series.isin(values) Whether elements in Series are contained in values. Series.last(offset) Select final periods of time series data based on a date offset. Series.reindex(*args, **kwargs) Conform Series to new index with optional filling logic. Series.reindex_like(other[, method, copy, ...]) Return an object with matching indices as other object. Series.rename([index, axis, copy, inplace, ...]) Alter Series index labels or name. Series.rename_axis([mapper, index, columns, ...]) Set the name of the axis for the index or columns. Series.reset_index([level, drop, name, inplace]) Generate a new DataFrame or Series with the index reset. Series.sample([n, frac, replace, weights, ...]) Return a random sample of items from an axis of object. Series.set_axis(labels[, axis, inplace]) Assign desired index to given axis. Series.take(indices[, axis, is_copy]) Return the elements in the given positional indices along an axis. Series.tail([n]) Return the last n rows. Series.truncate([before, after, axis, copy]) Truncate a Series or DataFrame before and after some index value. Series.where(cond[, other, inplace, axis, ...]) Replace values where the condition is False. Series.mask(cond[, other, inplace, axis, ...]) Replace values where the condition is True. Series.add_prefix(prefix) Prefix labels with string prefix. Series.add_suffix(suffix) Suffix labels with string suffix. Series.filter([items, like, regex, axis]) Subset the dataframe rows or columns according to the specified index labels. Missing data handling Series.backfill([axis, inplace, limit, downcast]) Synonym for DataFrame.fillna() with method='bfill'. Series.bfill([axis, inplace, limit, downcast]) Synonym for DataFrame.fillna() with method='bfill'. Series.dropna([axis, inplace, how]) Return a new Series with missing values removed. Series.ffill([axis, inplace, limit, downcast]) Synonym for DataFrame.fillna() with method='ffill'. Series.fillna([value, method, axis, ...]) Fill NA/NaN values using the specified method. Series.interpolate([method, axis, limit, ...]) Fill NaN values using an interpolation method. Series.isna() Detect missing values. Series.isnull() Series.isnull is an alias for Series.isna. Series.notna() Detect existing (non-missing) values. Series.notnull() Series.notnull is an alias for Series.notna. Series.pad([axis, inplace, limit, downcast]) Synonym for DataFrame.fillna() with method='ffill'. Series.replace([to_replace, value, inplace, ...]) Replace values given in to_replace with value. Reshaping, sorting Series.argsort([axis, kind, order]) Return the integer indices that would sort the Series values. Series.argmin([axis, skipna]) Return int position of the smallest value in the Series. Series.argmax([axis, skipna]) Return int position of the largest value in the Series. Series.reorder_levels(order) Rearrange index levels using input order. Series.sort_values([axis, ascending, ...]) Sort by the values. Series.sort_index([axis, level, ascending, ...]) Sort Series by index labels. Series.swaplevel([i, j, copy]) Swap levels i and j in a MultiIndex. Series.unstack([level, fill_value]) Unstack, also known as pivot, Series with MultiIndex to produce DataFrame. Series.explode([ignore_index]) Transform each element of a list-like to a row. Series.searchsorted(value[, side, sorter]) Find indices where elements should be inserted to maintain order. Series.ravel([order]) Return the flattened underlying data as an ndarray. Series.repeat(repeats[, axis]) Repeat elements of a Series. Series.squeeze([axis]) Squeeze 1 dimensional axis objects into scalars. Series.view([dtype]) Create a new view of the Series. Combining / comparing / joining / merging Series.append(to_append[, ignore_index, ...]) Concatenate two or more Series. Series.compare(other[, align_axis, ...]) Compare to another Series and show the differences. Series.update(other) Modify Series in place using values from passed Series. Time Series-related Series.asfreq(freq[, method, how, ...]) Convert time series to specified frequency. Series.asof(where[, subset]) Return the last row(s) without any NaNs before where. Series.shift([periods, freq, axis, fill_value]) Shift index by desired number of periods with an optional time freq. Series.first_valid_index() Return index for first non-NA value or None, if no NA value is found. Series.last_valid_index() Return index for last non-NA value or None, if no NA value is found. Series.resample(rule[, axis, closed, label, ...]) Resample time-series data. Series.tz_convert(tz[, axis, level, copy]) Convert tz-aware axis to target time zone. Series.tz_localize(tz[, axis, level, copy, ...]) Localize tz-naive index of a Series or DataFrame to target time zone. Series.at_time(time[, asof, axis]) Select values at particular time of day (e.g., 9:30AM). Series.between_time(start_time, end_time[, ...]) Select values between particular times of the day (e.g., 9:00-9:30 AM). Series.tshift([periods, freq, axis]) (DEPRECATED) Shift the time index, using the index's frequency if available. Series.slice_shift([periods, axis]) (DEPRECATED) Equivalent to shift without copying data. Accessors pandas provides dtype-specific methods under various accessors. These are separate namespaces within Series that only apply to specific data types. Data Type Accessor Datetime, Timedelta, Period dt String str Categorical cat Sparse sparse Datetimelike properties Series.dt can be used to access the values of the series as datetimelike and return several properties. These can be accessed like Series.dt.<property>. Datetime properties Series.dt.date Returns numpy array of python datetime.date objects. Series.dt.time Returns numpy array of datetime.time objects. Series.dt.timetz Returns numpy array of datetime.time objects with timezone information. Series.dt.year The year of the datetime. Series.dt.month The month as January=1, December=12. Series.dt.day The day of the datetime. Series.dt.hour The hours of the datetime. Series.dt.minute The minutes of the datetime. Series.dt.second The seconds of the datetime. Series.dt.microsecond The microseconds of the datetime. Series.dt.nanosecond The nanoseconds of the datetime. Series.dt.week (DEPRECATED) The week ordinal of the year. Series.dt.weekofyear (DEPRECATED) The week ordinal of the year. Series.dt.dayofweek The day of the week with Monday=0, Sunday=6. Series.dt.day_of_week The day of the week with Monday=0, Sunday=6. Series.dt.weekday The day of the week with Monday=0, Sunday=6. Series.dt.dayofyear The ordinal day of the year. Series.dt.day_of_year The ordinal day of the year. Series.dt.quarter The quarter of the date. Series.dt.is_month_start Indicates whether the date is the first day of the month. Series.dt.is_month_end Indicates whether the date is the last day of the month. Series.dt.is_quarter_start Indicator for whether the date is the first day of a quarter. Series.dt.is_quarter_end Indicator for whether the date is the last day of a quarter. Series.dt.is_year_start Indicate whether the date is the first day of a year. Series.dt.is_year_end Indicate whether the date is the last day of the year. Series.dt.is_leap_year Boolean indicator if the date belongs to a leap year. Series.dt.daysinmonth The number of days in the month. Series.dt.days_in_month The number of days in the month. Series.dt.tz Return the timezone. Series.dt.freq Return the frequency object for this PeriodArray. Datetime methods Series.dt.to_period(*args, **kwargs) Cast to PeriodArray/Index at a particular frequency. Series.dt.to_pydatetime() Return the data as an array of datetime.datetime objects. Series.dt.tz_localize(*args, **kwargs) Localize tz-naive Datetime Array/Index to tz-aware Datetime Array/Index. Series.dt.tz_convert(*args, **kwargs) Convert tz-aware Datetime Array/Index from one time zone to another. Series.dt.normalize(*args, **kwargs) Convert times to midnight. Series.dt.strftime(*args, **kwargs) Convert to Index using specified date_format. Series.dt.round(*args, **kwargs) Perform round operation on the data to the specified freq. Series.dt.floor(*args, **kwargs) Perform floor operation on the data to the specified freq. Series.dt.ceil(*args, **kwargs) Perform ceil operation on the data to the specified freq. Series.dt.month_name(*args, **kwargs) Return the month names of the DateTimeIndex with specified locale. Series.dt.day_name(*args, **kwargs) Return the day names of the DateTimeIndex with specified locale. Period properties Series.dt.qyear Series.dt.start_time Series.dt.end_time Timedelta properties Series.dt.days Number of days for each element. Series.dt.seconds Number of seconds (>= 0 and less than 1 day) for each element. Series.dt.microseconds Number of microseconds (>= 0 and less than 1 second) for each element. Series.dt.nanoseconds Number of nanoseconds (>= 0 and less than 1 microsecond) for each element. Series.dt.components Return a Dataframe of the components of the Timedeltas. Timedelta methods Series.dt.to_pytimedelta() Return an array of native datetime.timedelta objects. Series.dt.total_seconds(*args, **kwargs) Return total duration of each element expressed in seconds. String handling Series.str can be used to access the values of the series as strings and apply several methods to it. These can be accessed like Series.str.<function/property>. Series.str.capitalize() Convert strings in the Series/Index to be capitalized. Series.str.casefold() Convert strings in the Series/Index to be casefolded. Series.str.cat([others, sep, na_rep, join]) Concatenate strings in the Series/Index with given separator. Series.str.center(width[, fillchar]) Pad left and right side of strings in the Series/Index. Series.str.contains(pat[, case, flags, na, ...]) Test if pattern or regex is contained within a string of a Series or Index. Series.str.count(pat[, flags]) Count occurrences of pattern in each string of the Series/Index. Series.str.decode(encoding[, errors]) Decode character string in the Series/Index using indicated encoding. Series.str.encode(encoding[, errors]) Encode character string in the Series/Index using indicated encoding. Series.str.endswith(pat[, na]) Test if the end of each string element matches a pattern. Series.str.extract(pat[, flags, expand]) Extract capture groups in the regex pat as columns in a DataFrame. Series.str.extractall(pat[, flags]) Extract capture groups in the regex pat as columns in DataFrame. Series.str.find(sub[, start, end]) Return lowest indexes in each strings in the Series/Index. Series.str.findall(pat[, flags]) Find all occurrences of pattern or regular expression in the Series/Index. Series.str.fullmatch(pat[, case, flags, na]) Determine if each string entirely matches a regular expression. Series.str.get(i) Extract element from each component at specified position. Series.str.index(sub[, start, end]) Return lowest indexes in each string in Series/Index. Series.str.join(sep) Join lists contained as elements in the Series/Index with passed delimiter. Series.str.len() Compute the length of each element in the Series/Index. Series.str.ljust(width[, fillchar]) Pad right side of strings in the Series/Index. Series.str.lower() Convert strings in the Series/Index to lowercase. Series.str.lstrip([to_strip]) Remove leading characters. Series.str.match(pat[, case, flags, na]) Determine if each string starts with a match of a regular expression. Series.str.normalize(form) Return the Unicode normal form for the strings in the Series/Index. Series.str.pad(width[, side, fillchar]) Pad strings in the Series/Index up to width. Series.str.partition([sep, expand]) Split the string at the first occurrence of sep. Series.str.removeprefix(prefix) Remove a prefix from an object series. Series.str.removesuffix(suffix) Remove a suffix from an object series. Series.str.repeat(repeats) Duplicate each string in the Series or Index. Series.str.replace(pat, repl[, n, case, ...]) Replace each occurrence of pattern/regex in the Series/Index. Series.str.rfind(sub[, start, end]) Return highest indexes in each strings in the Series/Index. Series.str.rindex(sub[, start, end]) Return highest indexes in each string in Series/Index. Series.str.rjust(width[, fillchar]) Pad left side of strings in the Series/Index. Series.str.rpartition([sep, expand]) Split the string at the last occurrence of sep. Series.str.rstrip([to_strip]) Remove trailing characters. Series.str.slice([start, stop, step]) Slice substrings from each element in the Series or Index. Series.str.slice_replace([start, stop, repl]) Replace a positional slice of a string with another value. Series.str.split([pat, n, expand, regex]) Split strings around given separator/delimiter. Series.str.rsplit([pat, n, expand]) Split strings around given separator/delimiter. Series.str.startswith(pat[, na]) Test if the start of each string element matches a pattern. Series.str.strip([to_strip]) Remove leading and trailing characters. Series.str.swapcase() Convert strings in the Series/Index to be swapcased. Series.str.title() Convert strings in the Series/Index to titlecase. Series.str.translate(table) Map all characters in the string through the given mapping table. Series.str.upper() Convert strings in the Series/Index to uppercase. Series.str.wrap(width, **kwargs) Wrap strings in Series/Index at specified line width. Series.str.zfill(width) Pad strings in the Series/Index by prepending '0' characters. Series.str.isalnum() Check whether all characters in each string are alphanumeric. Series.str.isalpha() Check whether all characters in each string are alphabetic. Series.str.isdigit() Check whether all characters in each string are digits. Series.str.isspace() Check whether all characters in each string are whitespace. Series.str.islower() Check whether all characters in each string are lowercase. Series.str.isupper() Check whether all characters in each string are uppercase. Series.str.istitle() Check whether all characters in each string are titlecase. Series.str.isnumeric() Check whether all characters in each string are numeric. Series.str.isdecimal() Check whether all characters in each string are decimal. Series.str.get_dummies([sep]) Return DataFrame of dummy/indicator variables for Series. Categorical accessor Categorical-dtype specific methods and attributes are available under the Series.cat accessor. Series.cat.categories The categories of this categorical. Series.cat.ordered Whether the categories have an ordered relationship. Series.cat.codes Return Series of codes as well as the index. Series.cat.rename_categories(*args, **kwargs) Rename categories. Series.cat.reorder_categories(*args, **kwargs) Reorder categories as specified in new_categories. Series.cat.add_categories(*args, **kwargs) Add new categories. Series.cat.remove_categories(*args, **kwargs) Remove the specified categories. Series.cat.remove_unused_categories(*args, ...) Remove categories which are not used. Series.cat.set_categories(*args, **kwargs) Set the categories to the specified new_categories. Series.cat.as_ordered(*args, **kwargs) Set the Categorical to be ordered. Series.cat.as_unordered(*args, **kwargs) Set the Categorical to be unordered. Sparse accessor Sparse-dtype specific methods and attributes are provided under the Series.sparse accessor. Series.sparse.npoints The number of non- fill_value points. Series.sparse.density The percent of non- fill_value points, as decimal. Series.sparse.fill_value Elements in data that are fill_value are not stored. Series.sparse.sp_values An ndarray containing the non- fill_value values. Series.sparse.from_coo(A[, dense_index]) Create a Series with sparse values from a scipy.sparse.coo_matrix. Series.sparse.to_coo([row_levels, ...]) Create a scipy.sparse.coo_matrix from a Series with MultiIndex. Flags Flags refer to attributes of the pandas object. Properties of the dataset (like the date is was recorded, the URL it was accessed from, etc.) should be stored in Series.attrs. Flags(obj, *, allows_duplicate_labels) Flags that apply to pandas objects. Metadata Series.attrs is a dictionary for storing global metadata for this Series. Warning Series.attrs is considered experimental and may change without warning. Series.attrs Dictionary of global attributes of this dataset. Plotting Series.plot is both a callable method and a namespace attribute for specific plotting methods of the form Series.plot.<kind>. Series.plot([kind, ax, figsize, ....]) Series plotting accessor and method Series.plot.area([x, y]) Draw a stacked area plot. Series.plot.bar([x, y]) Vertical bar plot. Series.plot.barh([x, y]) Make a horizontal bar plot. Series.plot.box([by]) Make a box plot of the DataFrame columns. Series.plot.density([bw_method, ind]) Generate Kernel Density Estimate plot using Gaussian kernels. Series.plot.hist([by, bins]) Draw one histogram of the DataFrame's columns. Series.plot.kde([bw_method, ind]) Generate Kernel Density Estimate plot using Gaussian kernels. Series.plot.line([x, y]) Plot Series or DataFrame as lines. Series.plot.pie(**kwargs) Generate a pie plot. Series.hist([by, ax, grid, xlabelsize, ...]) Draw histogram of the input series using matplotlib. Serialization / IO / conversion Series.to_pickle(path[, compression, ...]) Pickle (serialize) object to file. Series.to_csv([path_or_buf, sep, na_rep, ...]) Write object to a comma-separated values (csv) file. Series.to_dict([into]) Convert Series to {label -> value} dict or dict-like object. Series.to_excel(excel_writer[, sheet_name, ...]) Write object to an Excel sheet. Series.to_frame([name]) Convert Series to DataFrame. Series.to_xarray() Return an xarray object from the pandas object. Series.to_hdf(path_or_buf, key[, mode, ...]) Write the contained data to an HDF5 file using HDFStore. Series.to_sql(name, con[, schema, ...]) Write records stored in a DataFrame to a SQL database. Series.to_json([path_or_buf, orient, ...]) Convert the object to a JSON string. Series.to_string([buf, na_rep, ...]) Render a string representation of the Series. Series.to_clipboard([excel, sep]) Copy object to the system clipboard. Series.to_latex([buf, columns, col_space, ...]) Render object to a LaTeX tabular, longtable, or nested table. Series.to_markdown([buf, mode, index, ...]) Print Series in Markdown-friendly format.
pandas.reference.series
Style Styler objects are returned by pandas.DataFrame.style. Styler constructor Styler(data[, precision, table_styles, ...]) Helps style a DataFrame or Series according to the data with HTML and CSS. Styler.from_custom_template(searchpath[, ...]) Factory function for creating a subclass of Styler. Styler properties Styler.env Styler.template_html Styler.template_html_style Styler.template_html_table Styler.template_latex Styler.loader Style application Styler.apply(func[, axis, subset]) Apply a CSS-styling function column-wise, row-wise, or table-wise. Styler.applymap(func[, subset]) Apply a CSS-styling function elementwise. Styler.apply_index(func[, axis, level]) Apply a CSS-styling function to the index or column headers, level-wise. Styler.applymap_index(func[, axis, level]) Apply a CSS-styling function to the index or column headers, elementwise. Styler.format([formatter, subset, na_rep, ...]) Format the text display value of cells. Styler.format_index([formatter, axis, ...]) Format the text display value of index labels or column headers. Styler.hide([subset, axis, level, names]) Hide the entire index / column headers, or specific rows / columns from display. Styler.set_td_classes(classes) Set the DataFrame of strings added to the class attribute of <td> HTML elements. Styler.set_table_styles([table_styles, ...]) Set the table styles included within the <style> HTML element. Styler.set_table_attributes(attributes) Set the table attributes added to the <table> HTML element. Styler.set_tooltips(ttips[, props, css_class]) Set the DataFrame of strings on Styler generating :hover tooltips. Styler.set_caption(caption) Set the text added to a <caption> HTML element. Styler.set_sticky([axis, pixel_size, levels]) Add CSS to permanently display the index or column headers in a scrolling frame. Styler.set_properties([subset]) Set defined CSS-properties to each <td> HTML element within the given subset. Styler.set_uuid(uuid) Set the uuid applied to id attributes of HTML elements. Styler.clear() Reset the Styler, removing any previously applied styles. Styler.pipe(func, *args, **kwargs) Apply func(self, *args, **kwargs), and return the result. Builtin styles Styler.highlight_null([null_color, subset, ...]) Highlight missing values with a style. Styler.highlight_max([subset, color, axis, ...]) Highlight the maximum with a style. Styler.highlight_min([subset, color, axis, ...]) Highlight the minimum with a style. Styler.highlight_between([subset, color, ...]) Highlight a defined range with a style. Styler.highlight_quantile([subset, color, ...]) Highlight values defined by a quantile with a style. Styler.background_gradient([cmap, low, ...]) Color the background in a gradient style. Styler.text_gradient([cmap, low, high, ...]) Color the text in a gradient style. Styler.bar([subset, axis, color, cmap, ...]) Draw bar chart in the cell backgrounds. Style export and import Styler.to_html([buf, table_uuid, ...]) Write Styler to a file, buffer or string in HTML-CSS format. Styler.to_latex([buf, column_format, ...]) Write Styler to a file, buffer or string in LaTeX format. Styler.to_excel(excel_writer[, sheet_name, ...]) Write Styler to an Excel sheet. Styler.export() Export the styles applied to the current Styler. Styler.use(styles) Set the styles on the current Styler.
pandas.reference.style
Window Rolling objects are returned by .rolling calls: pandas.DataFrame.rolling(), pandas.Series.rolling(), etc. Expanding objects are returned by .expanding calls: pandas.DataFrame.expanding(), pandas.Series.expanding(), etc. ExponentialMovingWindow objects are returned by .ewm calls: pandas.DataFrame.ewm(), pandas.Series.ewm(), etc. Rolling window functions Rolling.count() Calculate the rolling count of non NaN observations. Rolling.sum(*args[, engine, engine_kwargs]) Calculate the rolling sum. Rolling.mean(*args[, engine, engine_kwargs]) Calculate the rolling mean. Rolling.median([engine, engine_kwargs]) Calculate the rolling median. Rolling.var([ddof, engine, engine_kwargs]) Calculate the rolling variance. Rolling.std([ddof, engine, engine_kwargs]) Calculate the rolling standard deviation. Rolling.min(*args[, engine, engine_kwargs]) Calculate the rolling minimum. Rolling.max(*args[, engine, engine_kwargs]) Calculate the rolling maximum. Rolling.corr([other, pairwise, ddof]) Calculate the rolling correlation. Rolling.cov([other, pairwise, ddof]) Calculate the rolling sample covariance. Rolling.skew(**kwargs) Calculate the rolling unbiased skewness. Rolling.kurt(**kwargs) Calculate the rolling Fisher's definition of kurtosis without bias. Rolling.apply(func[, raw, engine, ...]) Calculate the rolling custom aggregation function. Rolling.aggregate(func, *args, **kwargs) Aggregate using one or more operations over the specified axis. Rolling.quantile(quantile[, interpolation]) Calculate the rolling quantile. Rolling.sem([ddof]) Calculate the rolling standard error of mean. Rolling.rank([method, ascending, pct]) Calculate the rolling rank. Weighted window functions Window.mean(*args, **kwargs) Calculate the rolling weighted window mean. Window.sum(*args, **kwargs) Calculate the rolling weighted window sum. Window.var([ddof]) Calculate the rolling weighted window variance. Window.std([ddof]) Calculate the rolling weighted window standard deviation. Expanding window functions Expanding.count() Calculate the expanding count of non NaN observations. Expanding.sum(*args[, engine, engine_kwargs]) Calculate the expanding sum. Expanding.mean(*args[, engine, engine_kwargs]) Calculate the expanding mean. Expanding.median([engine, engine_kwargs]) Calculate the expanding median. Expanding.var([ddof, engine, engine_kwargs]) Calculate the expanding variance. Expanding.std([ddof, engine, engine_kwargs]) Calculate the expanding standard deviation. Expanding.min(*args[, engine, engine_kwargs]) Calculate the expanding minimum. Expanding.max(*args[, engine, engine_kwargs]) Calculate the expanding maximum. Expanding.corr([other, pairwise, ddof]) Calculate the expanding correlation. Expanding.cov([other, pairwise, ddof]) Calculate the expanding sample covariance. Expanding.skew(**kwargs) Calculate the expanding unbiased skewness. Expanding.kurt(**kwargs) Calculate the expanding Fisher's definition of kurtosis without bias. Expanding.apply(func[, raw, engine, ...]) Calculate the expanding custom aggregation function. Expanding.aggregate(func, *args, **kwargs) Aggregate using one or more operations over the specified axis. Expanding.quantile(quantile[, interpolation]) Calculate the expanding quantile. Expanding.sem([ddof]) Calculate the expanding standard error of mean. Expanding.rank([method, ascending, pct]) Calculate the expanding rank. Exponentially-weighted window functions ExponentialMovingWindow.mean(*args[, ...]) Calculate the ewm (exponential weighted moment) mean. ExponentialMovingWindow.sum(*args[, engine, ...]) Calculate the ewm (exponential weighted moment) sum. ExponentialMovingWindow.std([bias]) Calculate the ewm (exponential weighted moment) standard deviation. ExponentialMovingWindow.var([bias]) Calculate the ewm (exponential weighted moment) variance. ExponentialMovingWindow.corr([other, pairwise]) Calculate the ewm (exponential weighted moment) sample correlation. ExponentialMovingWindow.cov([other, ...]) Calculate the ewm (exponential weighted moment) sample covariance. Window indexer Base class for defining custom window boundaries. api.indexers.BaseIndexer([index_array, ...]) Base class for window bounds calculations. api.indexers.FixedForwardWindowIndexer([...]) Creates window boundaries for fixed-length windows that include the current row. api.indexers.VariableOffsetWindowIndexer([...]) Calculate window boundaries based on a non-fixed offset such as a BusinessDay.
pandas.reference.window
Module: color skimage.color.combine_stains(stains, conv_matrix) Stain to RGB color space conversion. skimage.color.convert_colorspace(arr, …) Convert an image array to a new color space. skimage.color.deltaE_cie76(lab1, lab2) Euclidean distance between two points in Lab color space skimage.color.deltaE_ciede2000(lab1, lab2[, …]) Color difference as given by the CIEDE 2000 standard. skimage.color.deltaE_ciede94(lab1, lab2[, …]) Color difference according to CIEDE 94 standard skimage.color.deltaE_cmc(lab1, lab2[, kL, kC]) Color difference from the CMC l:c standard. skimage.color.gray2rgb(image[, alpha]) Create an RGB representation of a gray-level image. skimage.color.gray2rgba(image[, alpha]) Create a RGBA representation of a gray-level image. skimage.color.grey2rgb(image[, alpha]) Create an RGB representation of a gray-level image. skimage.color.hed2rgb(hed) Haematoxylin-Eosin-DAB (HED) to RGB color space conversion. skimage.color.hsv2rgb(hsv) HSV to RGB color space conversion. skimage.color.lab2lch(lab) CIE-LAB to CIE-LCH color space conversion. skimage.color.lab2rgb(lab[, illuminant, …]) Lab to RGB color space conversion. skimage.color.lab2xyz(lab[, illuminant, …]) CIE-LAB to XYZcolor space conversion. skimage.color.label2rgb(label[, image, …]) Return an RGB image where color-coded labels are painted over the image. skimage.color.lch2lab(lch) CIE-LCH to CIE-LAB color space conversion. skimage.color.rgb2gray(rgb) Compute luminance of an RGB image. skimage.color.rgb2grey(rgb) Compute luminance of an RGB image. skimage.color.rgb2hed(rgb) RGB to Haematoxylin-Eosin-DAB (HED) color space conversion. skimage.color.rgb2hsv(rgb) RGB to HSV color space conversion. skimage.color.rgb2lab(rgb[, illuminant, …]) Conversion from the sRGB color space (IEC 61966-2-1:1999) to the CIE Lab colorspace under the given illuminant and observer. skimage.color.rgb2rgbcie(rgb) RGB to RGB CIE color space conversion. skimage.color.rgb2xyz(rgb) RGB to XYZ color space conversion. skimage.color.rgb2ycbcr(rgb) RGB to YCbCr color space conversion. skimage.color.rgb2ydbdr(rgb) RGB to YDbDr color space conversion. skimage.color.rgb2yiq(rgb) RGB to YIQ color space conversion. skimage.color.rgb2ypbpr(rgb) RGB to YPbPr color space conversion. skimage.color.rgb2yuv(rgb) RGB to YUV color space conversion. skimage.color.rgba2rgb(rgba[, background]) RGBA to RGB conversion using alpha blending [1]. skimage.color.rgbcie2rgb(rgbcie) RGB CIE to RGB color space conversion. skimage.color.separate_stains(rgb, conv_matrix) RGB to stain color space conversion. skimage.color.xyz2lab(xyz[, illuminant, …]) XYZ to CIE-LAB color space conversion. skimage.color.xyz2rgb(xyz) XYZ to RGB color space conversion. skimage.color.ycbcr2rgb(ycbcr) YCbCr to RGB color space conversion. skimage.color.ydbdr2rgb(ydbdr) YDbDr to RGB color space conversion. skimage.color.yiq2rgb(yiq) YIQ to RGB color space conversion. skimage.color.ypbpr2rgb(ypbpr) YPbPr to RGB color space conversion. skimage.color.yuv2rgb(yuv) YUV to RGB color space conversion. combine_stains skimage.color.combine_stains(stains, conv_matrix) [source] Stain to RGB color space conversion. Parameters stains(…, 3) array_like The image in stain color space. Final dimension denotes channels. conv_matrix: ndarray The stain separation matrix as described by G. Landini [1]. Returns out(…, 3) ndarray The image in RGB format. Same dimensions as input. Raises ValueError If stains is not at least 2-D with shape (…, 3). Notes Stain combination matrices available in the color module and their respective colorspace: rgb_from_hed: Hematoxylin + Eosin + DAB rgb_from_hdx: Hematoxylin + DAB rgb_from_fgx: Feulgen + Light Green rgb_from_bex: Giemsa stain : Methyl Blue + Eosin rgb_from_rbd: FastRed + FastBlue + DAB rgb_from_gdx: Methyl Green + DAB rgb_from_hax: Hematoxylin + AEC rgb_from_bro: Blue matrix Anilline Blue + Red matrix Azocarmine + Orange matrix Orange-G rgb_from_bpx: Methyl Blue + Ponceau Fuchsin rgb_from_ahx: Alcian Blue + Hematoxylin rgb_from_hpx: Hematoxylin + PAS References 1 https://web.archive.org/web/20160624145052/http://www.mecourse.com/landinig/software/cdeconv/cdeconv.html 2 A. C. Ruifrok and D. A. Johnston, “Quantification of histochemical staining by color deconvolution,” Anal. Quant. Cytol. Histol., vol. 23, no. 4, pp. 291–299, Aug. 2001. Examples >>> from skimage import data >>> from skimage.color import (separate_stains, combine_stains, ... hdx_from_rgb, rgb_from_hdx) >>> ihc = data.immunohistochemistry() >>> ihc_hdx = separate_stains(ihc, hdx_from_rgb) >>> ihc_rgb = combine_stains(ihc_hdx, rgb_from_hdx) convert_colorspace skimage.color.convert_colorspace(arr, fromspace, tospace) [source] Convert an image array to a new color space. Valid color spaces are: ‘RGB’, ‘HSV’, ‘RGB CIE’, ‘XYZ’, ‘YUV’, ‘YIQ’, ‘YPbPr’, ‘YCbCr’, ‘YDbDr’ Parameters arr(…, 3) array_like The image to convert. Final dimension denotes channels. fromspacestr The color space to convert from. Can be specified in lower case. tospacestr The color space to convert to. Can be specified in lower case. Returns out(…, 3) ndarray The converted image. Same dimensions as input. Raises ValueError If fromspace is not a valid color space ValueError If tospace is not a valid color space Notes Conversion is performed through the “central” RGB color space, i.e. conversion from XYZ to HSV is implemented as XYZ -> RGB -> HSV instead of directly. Examples >>> from skimage import data >>> img = data.astronaut() >>> img_hsv = convert_colorspace(img, 'RGB', 'HSV') deltaE_cie76 skimage.color.deltaE_cie76(lab1, lab2) [source] Euclidean distance between two points in Lab color space Parameters lab1array_like reference color (Lab colorspace) lab2array_like comparison color (Lab colorspace) Returns dEarray_like distance between colors lab1 and lab2 References 1 https://en.wikipedia.org/wiki/Color_difference 2 A. R. Robertson, “The CIE 1976 color-difference formulae,” Color Res. Appl. 2, 7-11 (1977). deltaE_ciede2000 skimage.color.deltaE_ciede2000(lab1, lab2, kL=1, kC=1, kH=1) [source] Color difference as given by the CIEDE 2000 standard. CIEDE 2000 is a major revision of CIDE94. The perceptual calibration is largely based on experience with automotive paint on smooth surfaces. Parameters lab1array_like reference color (Lab colorspace) lab2array_like comparison color (Lab colorspace) kLfloat (range), optional lightness scale factor, 1 for “acceptably close”; 2 for “imperceptible” see deltaE_cmc kCfloat (range), optional chroma scale factor, usually 1 kHfloat (range), optional hue scale factor, usually 1 Returns deltaEarray_like The distance between lab1 and lab2 Notes CIEDE 2000 assumes parametric weighting factors for the lightness, chroma, and hue (kL, kC, kH respectively). These default to 1. References 1 https://en.wikipedia.org/wiki/Color_difference 2 http://www.ece.rochester.edu/~gsharma/ciede2000/ciede2000noteCRNA.pdf DOI:10.1364/AO.33.008069 3 M. Melgosa, J. Quesada, and E. Hita, “Uniformity of some recent color metrics tested with an accurate color-difference tolerance dataset,” Appl. Opt. 33, 8069-8077 (1994). deltaE_ciede94 skimage.color.deltaE_ciede94(lab1, lab2, kH=1, kC=1, kL=1, k1=0.045, k2=0.015) [source] Color difference according to CIEDE 94 standard Accommodates perceptual non-uniformities through the use of application specific scale factors (kH, kC, kL, k1, and k2). Parameters lab1array_like reference color (Lab colorspace) lab2array_like comparison color (Lab colorspace) kHfloat, optional Hue scale kCfloat, optional Chroma scale kLfloat, optional Lightness scale k1float, optional first scale parameter k2float, optional second scale parameter Returns dEarray_like color difference between lab1 and lab2 Notes deltaE_ciede94 is not symmetric with respect to lab1 and lab2. CIEDE94 defines the scales for the lightness, hue, and chroma in terms of the first color. Consequently, the first color should be regarded as the “reference” color. kL, k1, k2 depend on the application and default to the values suggested for graphic arts Parameter Graphic Arts Textiles kL 1.000 2.000 k1 0.045 0.048 k2 0.015 0.014 References 1 https://en.wikipedia.org/wiki/Color_difference 2 http://www.brucelindbloom.com/index.html?Eqn_DeltaE_CIE94.html deltaE_cmc skimage.color.deltaE_cmc(lab1, lab2, kL=1, kC=1) [source] Color difference from the CMC l:c standard. This color difference was developed by the Colour Measurement Committee (CMC) of the Society of Dyers and Colourists (United Kingdom). It is intended for use in the textile industry. The scale factors kL, kC set the weight given to differences in lightness and chroma relative to differences in hue. The usual values are kL=2, kC=1 for “acceptability” and kL=1, kC=1 for “imperceptibility”. Colors with dE > 1 are “different” for the given scale factors. Parameters lab1array_like reference color (Lab colorspace) lab2array_like comparison color (Lab colorspace) Returns dEarray_like distance between colors lab1 and lab2 Notes deltaE_cmc the defines the scales for the lightness, hue, and chroma in terms of the first color. Consequently deltaE_cmc(lab1, lab2) != deltaE_cmc(lab2, lab1) References 1 https://en.wikipedia.org/wiki/Color_difference 2 http://www.brucelindbloom.com/index.html?Eqn_DeltaE_CIE94.html 3 F. J. J. Clarke, R. McDonald, and B. Rigg, “Modification to the JPC79 colour-difference formula,” J. Soc. Dyers Colour. 100, 128-132 (1984). gray2rgb skimage.color.gray2rgb(image, alpha=None) [source] Create an RGB representation of a gray-level image. Parameters imagearray_like Input image. alphabool, optional Ensure that the output image has an alpha layer. If None, alpha layers are passed through but not created. Returns rgb(…, 3) ndarray RGB image. A new dimension of length 3 is added to input image. Notes If the input is a 1-dimensional image of shape (M, ), the output will be shape (M, 3). Examples using skimage.color.gray2rgb Tinting gray-scale images gray2rgba skimage.color.gray2rgba(image, alpha=None) [source] Create a RGBA representation of a gray-level image. Parameters imagearray_like Input image. alphaarray_like, optional Alpha channel of the output image. It may be a scalar or an array that can be broadcast to image. If not specified it is set to the maximum limit corresponding to the image dtype. Returns rgbandarray RGBA image. A new dimension of length 4 is added to input image shape. grey2rgb skimage.color.grey2rgb(image, alpha=None) [source] Create an RGB representation of a gray-level image. Parameters imagearray_like Input image. alphabool, optional Ensure that the output image has an alpha layer. If None, alpha layers are passed through but not created. Returns rgb(…, 3) ndarray RGB image. A new dimension of length 3 is added to input image. Notes If the input is a 1-dimensional image of shape (M, ), the output will be shape (M, 3). hed2rgb skimage.color.hed2rgb(hed) [source] Haematoxylin-Eosin-DAB (HED) to RGB color space conversion. Parameters hed(…, 3) array_like The image in the HED color space. Final dimension denotes channels. Returns out(…, 3) ndarray The image in RGB. Same dimensions as input. Raises ValueError If hed is not at least 2-D with shape (…, 3). References 1 A. C. Ruifrok and D. A. Johnston, “Quantification of histochemical staining by color deconvolution.,” Analytical and quantitative cytology and histology / the International Academy of Cytology [and] American Society of Cytology, vol. 23, no. 4, pp. 291-9, Aug. 2001. Examples >>> from skimage import data >>> from skimage.color import rgb2hed, hed2rgb >>> ihc = data.immunohistochemistry() >>> ihc_hed = rgb2hed(ihc) >>> ihc_rgb = hed2rgb(ihc_hed) hsv2rgb skimage.color.hsv2rgb(hsv) [source] HSV to RGB color space conversion. Parameters hsv(…, 3) array_like The image in HSV format. Final dimension denotes channels. Returns out(…, 3) ndarray The image in RGB format. Same dimensions as input. Raises ValueError If hsv is not at least 2-D with shape (…, 3). Notes Conversion between RGB and HSV color spaces results in some loss of precision, due to integer arithmetic and rounding [1]. References 1 https://en.wikipedia.org/wiki/HSL_and_HSV Examples >>> from skimage import data >>> img = data.astronaut() >>> img_hsv = rgb2hsv(img) >>> img_rgb = hsv2rgb(img_hsv) Examples using skimage.color.hsv2rgb Tinting gray-scale images Flood Fill lab2lch skimage.color.lab2lch(lab) [source] CIE-LAB to CIE-LCH color space conversion. LCH is the cylindrical representation of the LAB (Cartesian) colorspace Parameters lab(…, 3) array_like The N-D image in CIE-LAB format. The last (N+1-th) dimension must have at least 3 elements, corresponding to the L, a, and b color channels. Subsequent elements are copied. Returns out(…, 3) ndarray The image in LCH format, in a N-D array with same shape as input lab. Raises ValueError If lch does not have at least 3 color channels (i.e. l, a, b). Notes The Hue is expressed as an angle between (0, 2*pi) Examples >>> from skimage import data >>> from skimage.color import rgb2lab, lab2lch >>> img = data.astronaut() >>> img_lab = rgb2lab(img) >>> img_lch = lab2lch(img_lab) lab2rgb skimage.color.lab2rgb(lab, illuminant='D65', observer='2') [source] Lab to RGB color space conversion. Parameters lab(…, 3) array_like The image in Lab format. Final dimension denotes channels. illuminant{“A”, “D50”, “D55”, “D65”, “D75”, “E”}, optional The name of the illuminant (the function is NOT case sensitive). observer{“2”, “10”}, optional The aperture angle of the observer. Returns out(…, 3) ndarray The image in RGB format. Same dimensions as input. Raises ValueError If lab is not at least 2-D with shape (…, 3). Notes This function uses lab2xyz and xyz2rgb. By default Observer= 2A, Illuminant= D65. CIE XYZ tristimulus values x_ref=95.047, y_ref=100., z_ref=108.883. See function get_xyz_coords for a list of supported illuminants. References 1 https://en.wikipedia.org/wiki/Standard_illuminant lab2xyz skimage.color.lab2xyz(lab, illuminant='D65', observer='2') [source] CIE-LAB to XYZcolor space conversion. Parameters lab(…, 3) array_like The image in Lab format. Final dimension denotes channels. illuminant{“A”, “D50”, “D55”, “D65”, “D75”, “E”}, optional The name of the illuminant (the function is NOT case sensitive). observer{“2”, “10”}, optional The aperture angle of the observer. Returns out(…, 3) ndarray The image in XYZ format. Same dimensions as input. Raises ValueError If lab is not at least 2-D with shape (…, 3). ValueError If either the illuminant or the observer angle are not supported or unknown. UserWarning If any of the pixels are invalid (Z < 0). Notes By default Observer= 2A, Illuminant= D65. CIE XYZ tristimulus values x_ref = 95.047, y_ref = 100., z_ref = 108.883. See function ‘get_xyz_coords’ for a list of supported illuminants. References 1 http://www.easyrgb.com/index.php?X=MATH&H=07 2 https://en.wikipedia.org/wiki/Lab_color_space label2rgb skimage.color.label2rgb(label, image=None, colors=None, alpha=0.3, bg_label=-1, bg_color=(0, 0, 0), image_alpha=1, kind='overlay') [source] Return an RGB image where color-coded labels are painted over the image. Parameters labelarray, shape (M, N) Integer array of labels with the same shape as image. imagearray, shape (M, N, 3), optional Image used as underlay for labels. If the input is an RGB image, it’s converted to grayscale before coloring. colorslist, optional List of colors. If the number of labels exceeds the number of colors, then the colors are cycled. alphafloat [0, 1], optional Opacity of colorized labels. Ignored if image is None. bg_labelint, optional Label that’s treated as the background. If bg_label is specified, bg_color is None, and kind is overlay, background is not painted by any colors. bg_colorstr or array, optional Background color. Must be a name in color_dict or RGB float values between [0, 1]. image_alphafloat [0, 1], optional Opacity of the image. kindstring, one of {‘overlay’, ‘avg’} The kind of color image desired. ‘overlay’ cycles over defined colors and overlays the colored labels over the original image. ‘avg’ replaces each labeled segment with its average color, for a stained-class or pastel painting appearance. Returns resultarray of float, shape (M, N, 3) The result of blending a cycling colormap (colors) for each distinct value in label with the image, at a certain alpha value. Examples using skimage.color.label2rgb Segment human cells (in mitosis) lch2lab skimage.color.lch2lab(lch) [source] CIE-LCH to CIE-LAB color space conversion. LCH is the cylindrical representation of the LAB (Cartesian) colorspace Parameters lch(…, 3) array_like The N-D image in CIE-LCH format. The last (N+1-th) dimension must have at least 3 elements, corresponding to the L, a, and b color channels. Subsequent elements are copied. Returns out(…, 3) ndarray The image in LAB format, with same shape as input lch. Raises ValueError If lch does not have at least 3 color channels (i.e. l, c, h). Examples >>> from skimage import data >>> from skimage.color import rgb2lab, lch2lab >>> img = data.astronaut() >>> img_lab = rgb2lab(img) >>> img_lch = lab2lch(img_lab) >>> img_lab2 = lch2lab(img_lch) rgb2gray skimage.color.rgb2gray(rgb) [source] Compute luminance of an RGB image. Parameters rgb(…, 3) array_like The image in RGB format. Final dimension denotes channels. Returns outndarray The luminance image - an array which is the same size as the input array, but with the channel dimension removed. Raises ValueError If rgb is not at least 2-D with shape (…, 3). Notes The weights used in this conversion are calibrated for contemporary CRT phosphors: Y = 0.2125 R + 0.7154 G + 0.0721 B If there is an alpha channel present, it is ignored. References 1 http://poynton.ca/PDFs/ColorFAQ.pdf Examples >>> from skimage.color import rgb2gray >>> from skimage import data >>> img = data.astronaut() >>> img_gray = rgb2gray(img) Examples using skimage.color.rgb2gray Registration using optical flow Phase Unwrapping rgb2grey skimage.color.rgb2grey(rgb) [source] Compute luminance of an RGB image. Parameters rgb(…, 3) array_like The image in RGB format. Final dimension denotes channels. Returns outndarray The luminance image - an array which is the same size as the input array, but with the channel dimension removed. Raises ValueError If rgb is not at least 2-D with shape (…, 3). Notes The weights used in this conversion are calibrated for contemporary CRT phosphors: Y = 0.2125 R + 0.7154 G + 0.0721 B If there is an alpha channel present, it is ignored. References 1 http://poynton.ca/PDFs/ColorFAQ.pdf Examples >>> from skimage.color import rgb2gray >>> from skimage import data >>> img = data.astronaut() >>> img_gray = rgb2gray(img) rgb2hed skimage.color.rgb2hed(rgb) [source] RGB to Haematoxylin-Eosin-DAB (HED) color space conversion. Parameters rgb(…, 3) array_like The image in RGB format. Final dimension denotes channels. Returns out(…, 3) ndarray The image in HED format. Same dimensions as input. Raises ValueError If rgb is not at least 2-D with shape (…, 3). References 1 A. C. Ruifrok and D. A. Johnston, “Quantification of histochemical staining by color deconvolution.,” Analytical and quantitative cytology and histology / the International Academy of Cytology [and] American Society of Cytology, vol. 23, no. 4, pp. 291-9, Aug. 2001. Examples >>> from skimage import data >>> from skimage.color import rgb2hed >>> ihc = data.immunohistochemistry() >>> ihc_hed = rgb2hed(ihc) rgb2hsv skimage.color.rgb2hsv(rgb) [source] RGB to HSV color space conversion. Parameters rgb(…, 3) array_like The image in RGB format. Final dimension denotes channels. Returns out(…, 3) ndarray The image in HSV format. Same dimensions as input. Raises ValueError If rgb is not at least 2-D with shape (…, 3). Notes Conversion between RGB and HSV color spaces results in some loss of precision, due to integer arithmetic and rounding [1]. References 1 https://en.wikipedia.org/wiki/HSL_and_HSV Examples >>> from skimage import color >>> from skimage import data >>> img = data.astronaut() >>> img_hsv = color.rgb2hsv(img) Examples using skimage.color.rgb2hsv Tinting gray-scale images Flood Fill rgb2lab skimage.color.rgb2lab(rgb, illuminant='D65', observer='2') [source] Conversion from the sRGB color space (IEC 61966-2-1:1999) to the CIE Lab colorspace under the given illuminant and observer. Parameters rgb(…, 3) array_like The image in RGB format. Final dimension denotes channels. illuminant{“A”, “D50”, “D55”, “D65”, “D75”, “E”}, optional The name of the illuminant (the function is NOT case sensitive). observer{“2”, “10”}, optional The aperture angle of the observer. Returns out(…, 3) ndarray The image in Lab format. Same dimensions as input. Raises ValueError If rgb is not at least 2-D with shape (…, 3). Notes RGB is a device-dependent color space so, if you use this function, be sure that the image you are analyzing has been mapped to the sRGB color space. This function uses rgb2xyz and xyz2lab. By default Observer= 2A, Illuminant= D65. CIE XYZ tristimulus values x_ref=95.047, y_ref=100., z_ref=108.883. See function get_xyz_coords for a list of supported illuminants. References 1 https://en.wikipedia.org/wiki/Standard_illuminant rgb2rgbcie skimage.color.rgb2rgbcie(rgb) [source] RGB to RGB CIE color space conversion. Parameters rgb(…, 3) array_like The image in RGB format. Final dimension denotes channels. Returns out(…, 3) ndarray The image in RGB CIE format. Same dimensions as input. Raises ValueError If rgb is not at least 2-D with shape (…, 3). References 1 https://en.wikipedia.org/wiki/CIE_1931_color_space Examples >>> from skimage import data >>> from skimage.color import rgb2rgbcie >>> img = data.astronaut() >>> img_rgbcie = rgb2rgbcie(img) rgb2xyz skimage.color.rgb2xyz(rgb) [source] RGB to XYZ color space conversion. Parameters rgb(…, 3) array_like The image in RGB format. Final dimension denotes channels. Returns out(…, 3) ndarray The image in XYZ format. Same dimensions as input. Raises ValueError If rgb is not at least 2-D with shape (…, 3). Notes The CIE XYZ color space is derived from the CIE RGB color space. Note however that this function converts from sRGB. References 1 https://en.wikipedia.org/wiki/CIE_1931_color_space Examples >>> from skimage import data >>> img = data.astronaut() >>> img_xyz = rgb2xyz(img) rgb2ycbcr skimage.color.rgb2ycbcr(rgb) [source] RGB to YCbCr color space conversion. Parameters rgb(…, 3) array_like The image in RGB format. Final dimension denotes channels. Returns out(…, 3) ndarray The image in YCbCr format. Same dimensions as input. Raises ValueError If rgb is not at least 2-D with shape (…, 3). Notes Y is between 16 and 235. This is the color space commonly used by video codecs; it is sometimes incorrectly called “YUV”. References 1 https://en.wikipedia.org/wiki/YCbCr rgb2ydbdr skimage.color.rgb2ydbdr(rgb) [source] RGB to YDbDr color space conversion. Parameters rgb(…, 3) array_like The image in RGB format. Final dimension denotes channels. Returns out(…, 3) ndarray The image in YDbDr format. Same dimensions as input. Raises ValueError If rgb is not at least 2-D with shape (…, 3). Notes This is the color space commonly used by video codecs. It is also the reversible color transform in JPEG2000. References 1 https://en.wikipedia.org/wiki/YDbDr rgb2yiq skimage.color.rgb2yiq(rgb) [source] RGB to YIQ color space conversion. Parameters rgb(…, 3) array_like The image in RGB format. Final dimension denotes channels. Returns out(…, 3) ndarray The image in YIQ format. Same dimensions as input. Raises ValueError If rgb is not at least 2-D with shape (…, 3). rgb2ypbpr skimage.color.rgb2ypbpr(rgb) [source] RGB to YPbPr color space conversion. Parameters rgb(…, 3) array_like The image in RGB format. Final dimension denotes channels. Returns out(…, 3) ndarray The image in YPbPr format. Same dimensions as input. Raises ValueError If rgb is not at least 2-D with shape (…, 3). References 1 https://en.wikipedia.org/wiki/YPbPr rgb2yuv skimage.color.rgb2yuv(rgb) [source] RGB to YUV color space conversion. Parameters rgb(…, 3) array_like The image in RGB format. Final dimension denotes channels. Returns out(…, 3) ndarray The image in YUV format. Same dimensions as input. Raises ValueError If rgb is not at least 2-D with shape (…, 3). Notes Y is between 0 and 1. Use YCbCr instead of YUV for the color space commonly used by video codecs, where Y ranges from 16 to 235. References 1 https://en.wikipedia.org/wiki/YUV rgba2rgb skimage.color.rgba2rgb(rgba, background=(1, 1, 1)) [source] RGBA to RGB conversion using alpha blending [1]. Parameters rgba(…, 4) array_like The image in RGBA format. Final dimension denotes channels. backgroundarray_like The color of the background to blend the image with (3 floats between 0 to 1 - the RGB value of the background). Returns out(…, 3) ndarray The image in RGB format. Same dimensions as input. Raises ValueError If rgba is not at least 2-D with shape (…, 4). References 1(1,2) https://en.wikipedia.org/wiki/Alpha_compositing#Alpha_blending Examples >>> from skimage import color >>> from skimage import data >>> img_rgba = data.logo() >>> img_rgb = color.rgba2rgb(img_rgba) rgbcie2rgb skimage.color.rgbcie2rgb(rgbcie) [source] RGB CIE to RGB color space conversion. Parameters rgbcie(…, 3) array_like The image in RGB CIE format. Final dimension denotes channels. Returns out(…, 3) ndarray The image in RGB format. Same dimensions as input. Raises ValueError If rgbcie is not at least 2-D with shape (…, 3). References 1 https://en.wikipedia.org/wiki/CIE_1931_color_space Examples >>> from skimage import data >>> from skimage.color import rgb2rgbcie, rgbcie2rgb >>> img = data.astronaut() >>> img_rgbcie = rgb2rgbcie(img) >>> img_rgb = rgbcie2rgb(img_rgbcie) separate_stains skimage.color.separate_stains(rgb, conv_matrix) [source] RGB to stain color space conversion. Parameters rgb(…, 3) array_like The image in RGB format. Final dimension denotes channels. conv_matrix: ndarray The stain separation matrix as described by G. Landini [1]. Returns out(…, 3) ndarray The image in stain color space. Same dimensions as input. Raises ValueError If rgb is not at least 2-D with shape (…, 3). Notes Stain separation matrices available in the color module and their respective colorspace: hed_from_rgb: Hematoxylin + Eosin + DAB hdx_from_rgb: Hematoxylin + DAB fgx_from_rgb: Feulgen + Light Green bex_from_rgb: Giemsa stain : Methyl Blue + Eosin rbd_from_rgb: FastRed + FastBlue + DAB gdx_from_rgb: Methyl Green + DAB hax_from_rgb: Hematoxylin + AEC bro_from_rgb: Blue matrix Anilline Blue + Red matrix Azocarmine + Orange matrix Orange-G bpx_from_rgb: Methyl Blue + Ponceau Fuchsin ahx_from_rgb: Alcian Blue + Hematoxylin hpx_from_rgb: Hematoxylin + PAS This implementation borrows some ideas from DIPlib [2], e.g. the compensation using a small value to avoid log artifacts when calculating the Beer-Lambert law. References 1 https://web.archive.org/web/20160624145052/http://www.mecourse.com/landinig/software/cdeconv/cdeconv.html 2 https://github.com/DIPlib/diplib/ 3 A. C. Ruifrok and D. A. Johnston, “Quantification of histochemical staining by color deconvolution,” Anal. Quant. Cytol. Histol., vol. 23, no. 4, pp. 291–299, Aug. 2001. Examples >>> from skimage import data >>> from skimage.color import separate_stains, hdx_from_rgb >>> ihc = data.immunohistochemistry() >>> ihc_hdx = separate_stains(ihc, hdx_from_rgb) xyz2lab skimage.color.xyz2lab(xyz, illuminant='D65', observer='2') [source] XYZ to CIE-LAB color space conversion. Parameters xyz(…, 3) array_like The image in XYZ format. Final dimension denotes channels. illuminant{“A”, “D50”, “D55”, “D65”, “D75”, “E”}, optional The name of the illuminant (the function is NOT case sensitive). observer{“2”, “10”}, optional The aperture angle of the observer. Returns out(…, 3) ndarray The image in CIE-LAB format. Same dimensions as input. Raises ValueError If xyz is not at least 2-D with shape (…, 3). ValueError If either the illuminant or the observer angle is unsupported or unknown. Notes By default Observer= 2A, Illuminant= D65. CIE XYZ tristimulus values x_ref=95.047, y_ref=100., z_ref=108.883. See function get_xyz_coords for a list of supported illuminants. References 1 http://www.easyrgb.com/index.php?X=MATH&H=07 2 https://en.wikipedia.org/wiki/Lab_color_space Examples >>> from skimage import data >>> from skimage.color import rgb2xyz, xyz2lab >>> img = data.astronaut() >>> img_xyz = rgb2xyz(img) >>> img_lab = xyz2lab(img_xyz) xyz2rgb skimage.color.xyz2rgb(xyz) [source] XYZ to RGB color space conversion. Parameters xyz(…, 3) array_like The image in XYZ format. Final dimension denotes channels. Returns out(…, 3) ndarray The image in RGB format. Same dimensions as input. Raises ValueError If xyz is not at least 2-D with shape (…, 3). Notes The CIE XYZ color space is derived from the CIE RGB color space. Note however that this function converts to sRGB. References 1 https://en.wikipedia.org/wiki/CIE_1931_color_space Examples >>> from skimage import data >>> from skimage.color import rgb2xyz, xyz2rgb >>> img = data.astronaut() >>> img_xyz = rgb2xyz(img) >>> img_rgb = xyz2rgb(img_xyz) ycbcr2rgb skimage.color.ycbcr2rgb(ycbcr) [source] YCbCr to RGB color space conversion. Parameters ycbcr(…, 3) array_like The image in YCbCr format. Final dimension denotes channels. Returns out(…, 3) ndarray The image in RGB format. Same dimensions as input. Raises ValueError If ycbcr is not at least 2-D with shape (…, 3). Notes Y is between 16 and 235. This is the color space commonly used by video codecs; it is sometimes incorrectly called “YUV”. References 1 https://en.wikipedia.org/wiki/YCbCr ydbdr2rgb skimage.color.ydbdr2rgb(ydbdr) [source] YDbDr to RGB color space conversion. Parameters ydbdr(…, 3) array_like The image in YDbDr format. Final dimension denotes channels. Returns out(…, 3) ndarray The image in RGB format. Same dimensions as input. Raises ValueError If ydbdr is not at least 2-D with shape (…, 3). Notes This is the color space commonly used by video codecs, also called the reversible color transform in JPEG2000. References 1 https://en.wikipedia.org/wiki/YDbDr yiq2rgb skimage.color.yiq2rgb(yiq) [source] YIQ to RGB color space conversion. Parameters yiq(…, 3) array_like The image in YIQ format. Final dimension denotes channels. Returns out(…, 3) ndarray The image in RGB format. Same dimensions as input. Raises ValueError If yiq is not at least 2-D with shape (…, 3). ypbpr2rgb skimage.color.ypbpr2rgb(ypbpr) [source] YPbPr to RGB color space conversion. Parameters ypbpr(…, 3) array_like The image in YPbPr format. Final dimension denotes channels. Returns out(…, 3) ndarray The image in RGB format. Same dimensions as input. Raises ValueError If ypbpr is not at least 2-D with shape (…, 3). References 1 https://en.wikipedia.org/wiki/YPbPr yuv2rgb skimage.color.yuv2rgb(yuv) [source] YUV to RGB color space conversion. Parameters yuv(…, 3) array_like The image in YUV format. Final dimension denotes channels. Returns out(…, 3) ndarray The image in RGB format. Same dimensions as input. Raises ValueError If yuv is not at least 2-D with shape (…, 3). References 1 https://en.wikipedia.org/wiki/YUV
skimage.api.skimage.color
skimage.color.combine_stains(stains, conv_matrix) [source] Stain to RGB color space conversion. Parameters stains(…, 3) array_like The image in stain color space. Final dimension denotes channels. conv_matrix: ndarray The stain separation matrix as described by G. Landini [1]. Returns out(…, 3) ndarray The image in RGB format. Same dimensions as input. Raises ValueError If stains is not at least 2-D with shape (…, 3). Notes Stain combination matrices available in the color module and their respective colorspace: rgb_from_hed: Hematoxylin + Eosin + DAB rgb_from_hdx: Hematoxylin + DAB rgb_from_fgx: Feulgen + Light Green rgb_from_bex: Giemsa stain : Methyl Blue + Eosin rgb_from_rbd: FastRed + FastBlue + DAB rgb_from_gdx: Methyl Green + DAB rgb_from_hax: Hematoxylin + AEC rgb_from_bro: Blue matrix Anilline Blue + Red matrix Azocarmine + Orange matrix Orange-G rgb_from_bpx: Methyl Blue + Ponceau Fuchsin rgb_from_ahx: Alcian Blue + Hematoxylin rgb_from_hpx: Hematoxylin + PAS References 1 https://web.archive.org/web/20160624145052/http://www.mecourse.com/landinig/software/cdeconv/cdeconv.html 2 A. C. Ruifrok and D. A. Johnston, “Quantification of histochemical staining by color deconvolution,” Anal. Quant. Cytol. Histol., vol. 23, no. 4, pp. 291–299, Aug. 2001. Examples >>> from skimage import data >>> from skimage.color import (separate_stains, combine_stains, ... hdx_from_rgb, rgb_from_hdx) >>> ihc = data.immunohistochemistry() >>> ihc_hdx = separate_stains(ihc, hdx_from_rgb) >>> ihc_rgb = combine_stains(ihc_hdx, rgb_from_hdx)
skimage.api.skimage.color#skimage.color.combine_stains
skimage.color.convert_colorspace(arr, fromspace, tospace) [source] Convert an image array to a new color space. Valid color spaces are: ‘RGB’, ‘HSV’, ‘RGB CIE’, ‘XYZ’, ‘YUV’, ‘YIQ’, ‘YPbPr’, ‘YCbCr’, ‘YDbDr’ Parameters arr(…, 3) array_like The image to convert. Final dimension denotes channels. fromspacestr The color space to convert from. Can be specified in lower case. tospacestr The color space to convert to. Can be specified in lower case. Returns out(…, 3) ndarray The converted image. Same dimensions as input. Raises ValueError If fromspace is not a valid color space ValueError If tospace is not a valid color space Notes Conversion is performed through the “central” RGB color space, i.e. conversion from XYZ to HSV is implemented as XYZ -> RGB -> HSV instead of directly. Examples >>> from skimage import data >>> img = data.astronaut() >>> img_hsv = convert_colorspace(img, 'RGB', 'HSV')
skimage.api.skimage.color#skimage.color.convert_colorspace
skimage.color.deltaE_cie76(lab1, lab2) [source] Euclidean distance between two points in Lab color space Parameters lab1array_like reference color (Lab colorspace) lab2array_like comparison color (Lab colorspace) Returns dEarray_like distance between colors lab1 and lab2 References 1 https://en.wikipedia.org/wiki/Color_difference 2 A. R. Robertson, “The CIE 1976 color-difference formulae,” Color Res. Appl. 2, 7-11 (1977).
skimage.api.skimage.color#skimage.color.deltaE_cie76
skimage.color.deltaE_ciede2000(lab1, lab2, kL=1, kC=1, kH=1) [source] Color difference as given by the CIEDE 2000 standard. CIEDE 2000 is a major revision of CIDE94. The perceptual calibration is largely based on experience with automotive paint on smooth surfaces. Parameters lab1array_like reference color (Lab colorspace) lab2array_like comparison color (Lab colorspace) kLfloat (range), optional lightness scale factor, 1 for “acceptably close”; 2 for “imperceptible” see deltaE_cmc kCfloat (range), optional chroma scale factor, usually 1 kHfloat (range), optional hue scale factor, usually 1 Returns deltaEarray_like The distance between lab1 and lab2 Notes CIEDE 2000 assumes parametric weighting factors for the lightness, chroma, and hue (kL, kC, kH respectively). These default to 1. References 1 https://en.wikipedia.org/wiki/Color_difference 2 http://www.ece.rochester.edu/~gsharma/ciede2000/ciede2000noteCRNA.pdf DOI:10.1364/AO.33.008069 3 M. Melgosa, J. Quesada, and E. Hita, “Uniformity of some recent color metrics tested with an accurate color-difference tolerance dataset,” Appl. Opt. 33, 8069-8077 (1994).
skimage.api.skimage.color#skimage.color.deltaE_ciede2000
skimage.color.deltaE_ciede94(lab1, lab2, kH=1, kC=1, kL=1, k1=0.045, k2=0.015) [source] Color difference according to CIEDE 94 standard Accommodates perceptual non-uniformities through the use of application specific scale factors (kH, kC, kL, k1, and k2). Parameters lab1array_like reference color (Lab colorspace) lab2array_like comparison color (Lab colorspace) kHfloat, optional Hue scale kCfloat, optional Chroma scale kLfloat, optional Lightness scale k1float, optional first scale parameter k2float, optional second scale parameter Returns dEarray_like color difference between lab1 and lab2 Notes deltaE_ciede94 is not symmetric with respect to lab1 and lab2. CIEDE94 defines the scales for the lightness, hue, and chroma in terms of the first color. Consequently, the first color should be regarded as the “reference” color. kL, k1, k2 depend on the application and default to the values suggested for graphic arts Parameter Graphic Arts Textiles kL 1.000 2.000 k1 0.045 0.048 k2 0.015 0.014 References 1 https://en.wikipedia.org/wiki/Color_difference 2 http://www.brucelindbloom.com/index.html?Eqn_DeltaE_CIE94.html
skimage.api.skimage.color#skimage.color.deltaE_ciede94
skimage.color.deltaE_cmc(lab1, lab2, kL=1, kC=1) [source] Color difference from the CMC l:c standard. This color difference was developed by the Colour Measurement Committee (CMC) of the Society of Dyers and Colourists (United Kingdom). It is intended for use in the textile industry. The scale factors kL, kC set the weight given to differences in lightness and chroma relative to differences in hue. The usual values are kL=2, kC=1 for “acceptability” and kL=1, kC=1 for “imperceptibility”. Colors with dE > 1 are “different” for the given scale factors. Parameters lab1array_like reference color (Lab colorspace) lab2array_like comparison color (Lab colorspace) Returns dEarray_like distance between colors lab1 and lab2 Notes deltaE_cmc the defines the scales for the lightness, hue, and chroma in terms of the first color. Consequently deltaE_cmc(lab1, lab2) != deltaE_cmc(lab2, lab1) References 1 https://en.wikipedia.org/wiki/Color_difference 2 http://www.brucelindbloom.com/index.html?Eqn_DeltaE_CIE94.html 3 F. J. J. Clarke, R. McDonald, and B. Rigg, “Modification to the JPC79 colour-difference formula,” J. Soc. Dyers Colour. 100, 128-132 (1984).
skimage.api.skimage.color#skimage.color.deltaE_cmc
skimage.color.gray2rgb(image, alpha=None) [source] Create an RGB representation of a gray-level image. Parameters imagearray_like Input image. alphabool, optional Ensure that the output image has an alpha layer. If None, alpha layers are passed through but not created. Returns rgb(…, 3) ndarray RGB image. A new dimension of length 3 is added to input image. Notes If the input is a 1-dimensional image of shape (M, ), the output will be shape (M, 3).
skimage.api.skimage.color#skimage.color.gray2rgb
skimage.color.gray2rgba(image, alpha=None) [source] Create a RGBA representation of a gray-level image. Parameters imagearray_like Input image. alphaarray_like, optional Alpha channel of the output image. It may be a scalar or an array that can be broadcast to image. If not specified it is set to the maximum limit corresponding to the image dtype. Returns rgbandarray RGBA image. A new dimension of length 4 is added to input image shape.
skimage.api.skimage.color#skimage.color.gray2rgba
skimage.color.grey2rgb(image, alpha=None) [source] Create an RGB representation of a gray-level image. Parameters imagearray_like Input image. alphabool, optional Ensure that the output image has an alpha layer. If None, alpha layers are passed through but not created. Returns rgb(…, 3) ndarray RGB image. A new dimension of length 3 is added to input image. Notes If the input is a 1-dimensional image of shape (M, ), the output will be shape (M, 3).
skimage.api.skimage.color#skimage.color.grey2rgb
skimage.color.hed2rgb(hed) [source] Haematoxylin-Eosin-DAB (HED) to RGB color space conversion. Parameters hed(…, 3) array_like The image in the HED color space. Final dimension denotes channels. Returns out(…, 3) ndarray The image in RGB. Same dimensions as input. Raises ValueError If hed is not at least 2-D with shape (…, 3). References 1 A. C. Ruifrok and D. A. Johnston, “Quantification of histochemical staining by color deconvolution.,” Analytical and quantitative cytology and histology / the International Academy of Cytology [and] American Society of Cytology, vol. 23, no. 4, pp. 291-9, Aug. 2001. Examples >>> from skimage import data >>> from skimage.color import rgb2hed, hed2rgb >>> ihc = data.immunohistochemistry() >>> ihc_hed = rgb2hed(ihc) >>> ihc_rgb = hed2rgb(ihc_hed)
skimage.api.skimage.color#skimage.color.hed2rgb
skimage.color.hsv2rgb(hsv) [source] HSV to RGB color space conversion. Parameters hsv(…, 3) array_like The image in HSV format. Final dimension denotes channels. Returns out(…, 3) ndarray The image in RGB format. Same dimensions as input. Raises ValueError If hsv is not at least 2-D with shape (…, 3). Notes Conversion between RGB and HSV color spaces results in some loss of precision, due to integer arithmetic and rounding [1]. References 1 https://en.wikipedia.org/wiki/HSL_and_HSV Examples >>> from skimage import data >>> img = data.astronaut() >>> img_hsv = rgb2hsv(img) >>> img_rgb = hsv2rgb(img_hsv)
skimage.api.skimage.color#skimage.color.hsv2rgb
skimage.color.lab2lch(lab) [source] CIE-LAB to CIE-LCH color space conversion. LCH is the cylindrical representation of the LAB (Cartesian) colorspace Parameters lab(…, 3) array_like The N-D image in CIE-LAB format. The last (N+1-th) dimension must have at least 3 elements, corresponding to the L, a, and b color channels. Subsequent elements are copied. Returns out(…, 3) ndarray The image in LCH format, in a N-D array with same shape as input lab. Raises ValueError If lch does not have at least 3 color channels (i.e. l, a, b). Notes The Hue is expressed as an angle between (0, 2*pi) Examples >>> from skimage import data >>> from skimage.color import rgb2lab, lab2lch >>> img = data.astronaut() >>> img_lab = rgb2lab(img) >>> img_lch = lab2lch(img_lab)
skimage.api.skimage.color#skimage.color.lab2lch
skimage.color.lab2rgb(lab, illuminant='D65', observer='2') [source] Lab to RGB color space conversion. Parameters lab(…, 3) array_like The image in Lab format. Final dimension denotes channels. illuminant{“A”, “D50”, “D55”, “D65”, “D75”, “E”}, optional The name of the illuminant (the function is NOT case sensitive). observer{“2”, “10”}, optional The aperture angle of the observer. Returns out(…, 3) ndarray The image in RGB format. Same dimensions as input. Raises ValueError If lab is not at least 2-D with shape (…, 3). Notes This function uses lab2xyz and xyz2rgb. By default Observer= 2A, Illuminant= D65. CIE XYZ tristimulus values x_ref=95.047, y_ref=100., z_ref=108.883. See function get_xyz_coords for a list of supported illuminants. References 1 https://en.wikipedia.org/wiki/Standard_illuminant
skimage.api.skimage.color#skimage.color.lab2rgb
skimage.color.lab2xyz(lab, illuminant='D65', observer='2') [source] CIE-LAB to XYZcolor space conversion. Parameters lab(…, 3) array_like The image in Lab format. Final dimension denotes channels. illuminant{“A”, “D50”, “D55”, “D65”, “D75”, “E”}, optional The name of the illuminant (the function is NOT case sensitive). observer{“2”, “10”}, optional The aperture angle of the observer. Returns out(…, 3) ndarray The image in XYZ format. Same dimensions as input. Raises ValueError If lab is not at least 2-D with shape (…, 3). ValueError If either the illuminant or the observer angle are not supported or unknown. UserWarning If any of the pixels are invalid (Z < 0). Notes By default Observer= 2A, Illuminant= D65. CIE XYZ tristimulus values x_ref = 95.047, y_ref = 100., z_ref = 108.883. See function ‘get_xyz_coords’ for a list of supported illuminants. References 1 http://www.easyrgb.com/index.php?X=MATH&H=07 2 https://en.wikipedia.org/wiki/Lab_color_space
skimage.api.skimage.color#skimage.color.lab2xyz
skimage.color.label2rgb(label, image=None, colors=None, alpha=0.3, bg_label=-1, bg_color=(0, 0, 0), image_alpha=1, kind='overlay') [source] Return an RGB image where color-coded labels are painted over the image. Parameters labelarray, shape (M, N) Integer array of labels with the same shape as image. imagearray, shape (M, N, 3), optional Image used as underlay for labels. If the input is an RGB image, it’s converted to grayscale before coloring. colorslist, optional List of colors. If the number of labels exceeds the number of colors, then the colors are cycled. alphafloat [0, 1], optional Opacity of colorized labels. Ignored if image is None. bg_labelint, optional Label that’s treated as the background. If bg_label is specified, bg_color is None, and kind is overlay, background is not painted by any colors. bg_colorstr or array, optional Background color. Must be a name in color_dict or RGB float values between [0, 1]. image_alphafloat [0, 1], optional Opacity of the image. kindstring, one of {‘overlay’, ‘avg’} The kind of color image desired. ‘overlay’ cycles over defined colors and overlays the colored labels over the original image. ‘avg’ replaces each labeled segment with its average color, for a stained-class or pastel painting appearance. Returns resultarray of float, shape (M, N, 3) The result of blending a cycling colormap (colors) for each distinct value in label with the image, at a certain alpha value.
skimage.api.skimage.color#skimage.color.label2rgb
skimage.color.lch2lab(lch) [source] CIE-LCH to CIE-LAB color space conversion. LCH is the cylindrical representation of the LAB (Cartesian) colorspace Parameters lch(…, 3) array_like The N-D image in CIE-LCH format. The last (N+1-th) dimension must have at least 3 elements, corresponding to the L, a, and b color channels. Subsequent elements are copied. Returns out(…, 3) ndarray The image in LAB format, with same shape as input lch. Raises ValueError If lch does not have at least 3 color channels (i.e. l, c, h). Examples >>> from skimage import data >>> from skimage.color import rgb2lab, lch2lab >>> img = data.astronaut() >>> img_lab = rgb2lab(img) >>> img_lch = lab2lch(img_lab) >>> img_lab2 = lch2lab(img_lch)
skimage.api.skimage.color#skimage.color.lch2lab
skimage.color.rgb2gray(rgb) [source] Compute luminance of an RGB image. Parameters rgb(…, 3) array_like The image in RGB format. Final dimension denotes channels. Returns outndarray The luminance image - an array which is the same size as the input array, but with the channel dimension removed. Raises ValueError If rgb is not at least 2-D with shape (…, 3). Notes The weights used in this conversion are calibrated for contemporary CRT phosphors: Y = 0.2125 R + 0.7154 G + 0.0721 B If there is an alpha channel present, it is ignored. References 1 http://poynton.ca/PDFs/ColorFAQ.pdf Examples >>> from skimage.color import rgb2gray >>> from skimage import data >>> img = data.astronaut() >>> img_gray = rgb2gray(img)
skimage.api.skimage.color#skimage.color.rgb2gray
skimage.color.rgb2grey(rgb) [source] Compute luminance of an RGB image. Parameters rgb(…, 3) array_like The image in RGB format. Final dimension denotes channels. Returns outndarray The luminance image - an array which is the same size as the input array, but with the channel dimension removed. Raises ValueError If rgb is not at least 2-D with shape (…, 3). Notes The weights used in this conversion are calibrated for contemporary CRT phosphors: Y = 0.2125 R + 0.7154 G + 0.0721 B If there is an alpha channel present, it is ignored. References 1 http://poynton.ca/PDFs/ColorFAQ.pdf Examples >>> from skimage.color import rgb2gray >>> from skimage import data >>> img = data.astronaut() >>> img_gray = rgb2gray(img)
skimage.api.skimage.color#skimage.color.rgb2grey
skimage.color.rgb2hed(rgb) [source] RGB to Haematoxylin-Eosin-DAB (HED) color space conversion. Parameters rgb(…, 3) array_like The image in RGB format. Final dimension denotes channels. Returns out(…, 3) ndarray The image in HED format. Same dimensions as input. Raises ValueError If rgb is not at least 2-D with shape (…, 3). References 1 A. C. Ruifrok and D. A. Johnston, “Quantification of histochemical staining by color deconvolution.,” Analytical and quantitative cytology and histology / the International Academy of Cytology [and] American Society of Cytology, vol. 23, no. 4, pp. 291-9, Aug. 2001. Examples >>> from skimage import data >>> from skimage.color import rgb2hed >>> ihc = data.immunohistochemistry() >>> ihc_hed = rgb2hed(ihc)
skimage.api.skimage.color#skimage.color.rgb2hed
skimage.color.rgb2hsv(rgb) [source] RGB to HSV color space conversion. Parameters rgb(…, 3) array_like The image in RGB format. Final dimension denotes channels. Returns out(…, 3) ndarray The image in HSV format. Same dimensions as input. Raises ValueError If rgb is not at least 2-D with shape (…, 3). Notes Conversion between RGB and HSV color spaces results in some loss of precision, due to integer arithmetic and rounding [1]. References 1 https://en.wikipedia.org/wiki/HSL_and_HSV Examples >>> from skimage import color >>> from skimage import data >>> img = data.astronaut() >>> img_hsv = color.rgb2hsv(img)
skimage.api.skimage.color#skimage.color.rgb2hsv
skimage.color.rgb2lab(rgb, illuminant='D65', observer='2') [source] Conversion from the sRGB color space (IEC 61966-2-1:1999) to the CIE Lab colorspace under the given illuminant and observer. Parameters rgb(…, 3) array_like The image in RGB format. Final dimension denotes channels. illuminant{“A”, “D50”, “D55”, “D65”, “D75”, “E”}, optional The name of the illuminant (the function is NOT case sensitive). observer{“2”, “10”}, optional The aperture angle of the observer. Returns out(…, 3) ndarray The image in Lab format. Same dimensions as input. Raises ValueError If rgb is not at least 2-D with shape (…, 3). Notes RGB is a device-dependent color space so, if you use this function, be sure that the image you are analyzing has been mapped to the sRGB color space. This function uses rgb2xyz and xyz2lab. By default Observer= 2A, Illuminant= D65. CIE XYZ tristimulus values x_ref=95.047, y_ref=100., z_ref=108.883. See function get_xyz_coords for a list of supported illuminants. References 1 https://en.wikipedia.org/wiki/Standard_illuminant
skimage.api.skimage.color#skimage.color.rgb2lab
skimage.color.rgb2rgbcie(rgb) [source] RGB to RGB CIE color space conversion. Parameters rgb(…, 3) array_like The image in RGB format. Final dimension denotes channels. Returns out(…, 3) ndarray The image in RGB CIE format. Same dimensions as input. Raises ValueError If rgb is not at least 2-D with shape (…, 3). References 1 https://en.wikipedia.org/wiki/CIE_1931_color_space Examples >>> from skimage import data >>> from skimage.color import rgb2rgbcie >>> img = data.astronaut() >>> img_rgbcie = rgb2rgbcie(img)
skimage.api.skimage.color#skimage.color.rgb2rgbcie
skimage.color.rgb2xyz(rgb) [source] RGB to XYZ color space conversion. Parameters rgb(…, 3) array_like The image in RGB format. Final dimension denotes channels. Returns out(…, 3) ndarray The image in XYZ format. Same dimensions as input. Raises ValueError If rgb is not at least 2-D with shape (…, 3). Notes The CIE XYZ color space is derived from the CIE RGB color space. Note however that this function converts from sRGB. References 1 https://en.wikipedia.org/wiki/CIE_1931_color_space Examples >>> from skimage import data >>> img = data.astronaut() >>> img_xyz = rgb2xyz(img)
skimage.api.skimage.color#skimage.color.rgb2xyz
skimage.color.rgb2ycbcr(rgb) [source] RGB to YCbCr color space conversion. Parameters rgb(…, 3) array_like The image in RGB format. Final dimension denotes channels. Returns out(…, 3) ndarray The image in YCbCr format. Same dimensions as input. Raises ValueError If rgb is not at least 2-D with shape (…, 3). Notes Y is between 16 and 235. This is the color space commonly used by video codecs; it is sometimes incorrectly called “YUV”. References 1 https://en.wikipedia.org/wiki/YCbCr
skimage.api.skimage.color#skimage.color.rgb2ycbcr
skimage.color.rgb2ydbdr(rgb) [source] RGB to YDbDr color space conversion. Parameters rgb(…, 3) array_like The image in RGB format. Final dimension denotes channels. Returns out(…, 3) ndarray The image in YDbDr format. Same dimensions as input. Raises ValueError If rgb is not at least 2-D with shape (…, 3). Notes This is the color space commonly used by video codecs. It is also the reversible color transform in JPEG2000. References 1 https://en.wikipedia.org/wiki/YDbDr
skimage.api.skimage.color#skimage.color.rgb2ydbdr
skimage.color.rgb2yiq(rgb) [source] RGB to YIQ color space conversion. Parameters rgb(…, 3) array_like The image in RGB format. Final dimension denotes channels. Returns out(…, 3) ndarray The image in YIQ format. Same dimensions as input. Raises ValueError If rgb is not at least 2-D with shape (…, 3).
skimage.api.skimage.color#skimage.color.rgb2yiq
skimage.color.rgb2ypbpr(rgb) [source] RGB to YPbPr color space conversion. Parameters rgb(…, 3) array_like The image in RGB format. Final dimension denotes channels. Returns out(…, 3) ndarray The image in YPbPr format. Same dimensions as input. Raises ValueError If rgb is not at least 2-D with shape (…, 3). References 1 https://en.wikipedia.org/wiki/YPbPr
skimage.api.skimage.color#skimage.color.rgb2ypbpr
skimage.color.rgb2yuv(rgb) [source] RGB to YUV color space conversion. Parameters rgb(…, 3) array_like The image in RGB format. Final dimension denotes channels. Returns out(…, 3) ndarray The image in YUV format. Same dimensions as input. Raises ValueError If rgb is not at least 2-D with shape (…, 3). Notes Y is between 0 and 1. Use YCbCr instead of YUV for the color space commonly used by video codecs, where Y ranges from 16 to 235. References 1 https://en.wikipedia.org/wiki/YUV
skimage.api.skimage.color#skimage.color.rgb2yuv