- 2.17.0 (latest)
- 2.16.0
- 2.15.0
- 2.14.0
- 2.13.0
- 2.12.0
- 2.11.0
- 2.10.0
- 2.9.0
- 2.8.0
- 2.7.0
- 2.6.0
- 2.5.0
- 2.4.0
- 2.3.0
- 2.2.0
- 2.0.0-dev0
- 1.36.0
- 1.35.0
- 1.34.0
- 1.33.0
- 1.32.0
- 1.31.0
- 1.30.0
- 1.29.0
- 1.28.0
- 1.27.0
- 1.26.0
- 1.25.0
- 1.24.0
- 1.22.0
- 1.21.0
- 1.20.0
- 1.19.0
- 1.18.0
- 1.17.0
- 1.16.0
- 1.15.0
- 1.14.0
- 1.13.0
- 1.12.0
- 1.11.1
- 1.10.0
- 1.9.0
- 1.8.0
- 1.7.0
- 1.6.0
- 1.5.0
- 1.4.0
- 1.3.0
- 1.2.0
- 1.1.0
- 1.0.0
- 0.26.0
- 0.25.0
- 0.24.0
- 0.23.0
- 0.22.0
- 0.21.0
- 0.20.1
- 0.19.2
- 0.18.0
- 0.17.0
- 0.16.0
- 0.15.0
- 0.14.1
- 0.13.0
- 0.12.0
- 0.11.0
- 0.10.0
- 0.9.0
- 0.8.0
- 0.7.0
- 0.6.0
- 0.5.0
- 0.4.0
- 0.3.0
- 0.2.0
Index
(
data
=
None
,
dtype
=
None
,
*
,
name
=
None
,
session
=
None
)
Immutable sequence used for indexing and alignment.
The basic object storing axis labels for all objects.
Parameters
data
pandas.Series pandas.Index bigframes.series.Series
bigframes.core.indexes.base.Index
Labels (1-dimensional).
session
Optional[ bigframes.session.Session
]
BigQuery DataFrames session where queries are run. If not set, a default session is used.
Properties
T
Return the transpose, which is by definition self.
Examples:
>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None
>>> s = bpd.Series(['Ant', 'Bear', 'Cow'])
>>> s
0 Ant
1 Bear
2 Cow
dtype: string
>>> s.T
0 Ant
1 Bear
2 Cow
dtype: string
For Index:
>>> idx = bpd.Index([1, 2, 3])
>>> idx.T
Index([1, 2, 3], dtype='Int64')
dtype
Return the dtype object of the underlying data.
Examples:
>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None
>>> idx = bpd.Index([1, 2, 3])
>>> idx
Index([1, 2, 3], dtype='Int64')
>>> idx.dtype
Int64Dtype()
dtypes
Return the dtypes as a Series for the underlying MultiIndex.
Pandas.Series
empty
Returns True if the Index is empty, otherwise returns False.
has_duplicates
Check if the Index has duplicate values.
Examples:
>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None
>>> idx = bpd.Index([1, 5, 7, 7])
>>> bool(idx.has_duplicates)
True
>>> idx = bpd.Index([1, 5, 7])
>>> bool(idx.has_duplicates)
False
bool
is_monotonic_decreasing
Return a boolean if the values are equal or decreasing.
Examples:
>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None
>>> bool(bpd.Index([3, 2, 1]).is_monotonic_decreasing)
True
>>> bool(bpd.Index([3, 2, 2]).is_monotonic_decreasing)
True
>>> bool(bpd.Index([3, 1, 2]).is_monotonic_decreasing)
False
bool
is_monotonic_increasing
Return a boolean if the values are equal or increasing.
Examples:
>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None
>>> bool(bpd.Index([1, 2, 3]).is_monotonic_increasing)
True
>>> bool(bpd.Index([1, 2, 2]).is_monotonic_increasing)
True
>>> bool(bpd.Index([1, 3, 2]).is_monotonic_increasing)
False
bool
is_unique
Return if the index has unique values.
Examples:
>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None
>>> idx = bpd.Index([1, 5, 7, 7])
>>> idx.is_unique
False
>>> idx = bpd.Index([1, 5, 7])
>>> idx.is_unique
True
bool
name
Returns Index name.
Examples:
>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None
>>> idx = bpd.Index([1, 2, 3], name='x')
>>> idx
Index([1, 2, 3], dtype='Int64', name='x')
>>> idx.name
'x'
blocks.Label
names
Returns the names of the Index.
Sequence[blocks.Label]
ndim
Number of dimensions of the underlying data, by definition 1.
Examples:
>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None
>>> s = bpd.Series(['Ant', 'Bear', 'Cow'])
>>> s
0 Ant
1 Bear
2 Cow
dtype: string
>>> s.ndim
1
For Index:
>>> idx = bpd.Index([1, 2, 3])
>>> idx
Index([1, 2, 3], dtype='Int64')
>>> idx.ndim
1
int
nlevels
Integer number of levels in this MultiIndex
Examples:
>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None
>>> mi = bpd.MultiIndex.from_arrays([['a'], ['b'], ['c']])
>>> mi
MultiIndex([('a', 'b', 'c')],
)
>>> mi.nlevels
3
int
query_job
BigQuery job metadata for the most recent query.
shape
Return a tuple of the shape of the underlying data.
Examples:
>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None
>>> idx = bpd.Index([1, 2, 3])
>>> idx
Index([1, 2, 3], dtype='Int64')
>>> idx.shape
(3,)
Tuple[int]
size
Return the number of elements in the underlying data.
Examples:
>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None
For Series:
>>> s = bpd.Series(['Ant', 'Bear', 'Cow'])
>>> s
0 Ant
1 Bear
2 Cow
dtype: string
For Index:
>>> idx = bpd.Index([1, 2, 3])
>>> idx
Index([1, 2, 3], dtype='Int64')
int
values
Return an array representing the data in the Index.
Examples:
>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None
>>> idx = bpd.Index([1, 2, 3])
>>> idx
Index([1, 2, 3], dtype='Int64')
>>> idx.values
array([1, 2, 3])
array
Methods
__setitem__
__setitem__
(
key
,
value
)
-
> None
Index objects are immutable. Use Index constructor to create modified Index.
all
all
()
-
> bool
Return whether all elements are Truthy.
Examples:
>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None
True, because nonzero integers are considered True.
>>> bool(bpd.Index([1, 2, 3]).all())
True
False, because 0 is considered False.
>>> bool(bpd.Index([0, 1, 2]).all())
False
TypeError
all
.bool
any
any
()
-
> bool
Return whether any element is Truthy.
Examples:
>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None
>>> index = bpd.Index([0, 1, 2])
>>> bool(index.any())
True
>>> index = bpd.Index([0, 0, 0])
>>> bool(index.any())
False
TypeError
any
.bool
argmax
argmax
()
-
> int
Return int position of the largest value in the Series.
If the maximum is achieved in multiple locations, the first row position is returned.
Examples:
Consider dataset containing cereal calories
>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None
>>> s = bpd.Series({'Corn Flakes': 100.0, 'Almond Delight': 110.0,
... 'Cinnamon Toast Crunch': 120.0, 'Cocoa Puff': 110.0})
>>> s
Corn Flakes 100.0
Almond Delight 110.0
Cinnamon Toast Crunch 120.0
Cocoa Puff 110.0
dtype: Float64
>>> int(s.argmax())
2
>>> int(s.argmin())
0
The maximum cereal calories is the third element and the minimum cereal calories is the first element, since series is zero-indexed.
int
argmin
argmin
()
-
> int
Return int position of the smallest value in the series.
If the minimum is achieved in multiple locations, the first row position is returned.
Examples:
>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None
Consider dataset containing cereal calories
>>> s = bpd.Series({'Corn Flakes': 100.0, 'Almond Delight': 110.0,
... 'Cinnamon Toast Crunch': 120.0, 'Cocoa Puff': 110.0})
>>> s
Corn Flakes 100.0
Almond Delight 110.0
Cinnamon Toast Crunch 120.0
Cocoa Puff 110.0
dtype: Float64
>>> int(s.argmax())
2
>>> int(s.argmin())
0
The maximum cereal calories is the third element and the minimum cereal calories is the first element, since series is zero-indexed.
int
astype
astype
(
dtype
,
*
,
errors
:
typing
.
Literal
[
"raise"
,
"null"
]
=
"raise"
)
-
> bigframes
.
core
.
indexes
.
base
.
Index
Create an Index with values cast to dtypes.
The class of a new Index is determined by dtype. When conversion is impossible, a TypeError exception is raised.
Examples:
>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None
>>> idx = bpd.Index([1, 2, 3])
>>> idx
Index([1, 2, 3], dtype='Int64')
dtype
str, data type, or pandas.ExtensionDtype
A dtype supported by BigQuery DataFrame include 'boolean'
, 'Float64'
, 'Int64'
, 'int64[pyarrow]'
, 'string'
, 'string[pyarrow]'
, 'timestamp[us, tz=UTC][pyarrow]'
, 'timestamp[us][pyarrow]'
, 'date32[day][pyarrow]'
, 'time64[us][pyarrow]'
. A pandas.ExtensionDtype include pandas.BooleanDtype()
, pandas.Float64Dtype()
, pandas.Int64Dtype()
, pandas.StringDtype(storage="pyarrow")
, pd.ArrowDtype(pa.date32())
, pd.ArrowDtype(pa.time64("us"))
, pd.ArrowDtype(pa.timestamp("us"))
, pd.ArrowDtype(pa.timestamp("us", tz="UTC"))
.
errors
{'raise', 'null'}, default 'raise'
Control raising of exceptions on invalid data for provided dtype. If 'raise', allow exceptions to be raised if any value fails cast If 'null', will assign null value if value fails cast
ValueError
errors
is not one of raise
.TypeError
astype
.copy
copy
(
name
:
typing
.
Optional
[
typing
.
Hashable
]
=
None
)
Make a copy of this object.
Name is set on the new object.
Examples:
>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None
>>> idx = bpd.Index(['a', 'b', 'c'])
>>> new_idx = idx.copy()
>>> idx is new_idx
False
name
Label, optional
Set name for new object.
drop
drop
(
labels
:
typing
.
Any
)
-
> bigframes
.
core
.
indexes
.
base
.
Index
Make new Index with passed list of labels deleted.
Examples:
>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None
>>> idx = bpd.Index(['a', 'b', 'c'])
>>> idx.drop(['a'])
Index(['b', 'c'], dtype='string')
drop_duplicates
drop_duplicates
(
*
,
keep
:
str
=
"first"
)
-
> bigframes
.
core
.
indexes
.
base
.
Index
Return Index with duplicate values removed.
Examples:
>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None
Generate an pandas.Index with duplicate values.
>>> idx = bpd.Index(['lama', 'cow', 'lama', 'beetle', 'lama', 'hippo'])
The keep parameter controls which duplicate values are removed.
The value first
keeps the first occurrence for each set of
duplicated entries. The default value of keep is first
.
>>> idx.drop_duplicates(keep='first')
Index(['lama', 'cow', 'beetle', 'hippo'], dtype='string')
The value last
keeps the last occurrence for each set of
duplicated entries.
>>> idx.drop_duplicates(keep='last')
Index(['cow', 'beetle', 'lama', 'hippo'], dtype='string')
The value False
discards all sets of duplicated entries.
>>> idx.drop_duplicates(keep=False)
Index(['cow', 'beetle', 'hippo'], dtype='string')
keep
{'first', 'last', False
}, default 'first'
One of: 'first' : Drop duplicates except for the first occurrence. 'last' : Drop duplicates except for the last occurrence. False
: Drop all duplicates.
dropna
dropna
(
how
:
typing
.
Literal
[
"all"
,
"any"
]
=
"any"
,
)
-
> bigframes
.
core
.
indexes
.
base
.
Index
Return Index without NA/NaN values.
Examples:
>>> import bigframes.pandas as bpd
>>> import numpy as np
>>> bpd.options.display.progress_bar = None
>>> idx = bpd.Index([1, np.nan, 3])
>>> idx.dropna()
Index([1.0, 3.0], dtype='Float64')
how
{'any', 'all'}, default 'any'
If the Index is a MultiIndex, drop the value when any or all levels are NaN.
ValueError
how
is not any
or all
fillna
fillna
(
value
=
None
)
-
> bigframes
.
core
.
indexes
.
base
.
Index
Fill NA/NaN values with the specified value.
Examples:
>>> import bigframes.pandas as bpd
>>> import numpy as np
>>> bpd.options.display.progress_bar = None
>>> idx = bpd.Index([np.nan, np.nan, 3])
>>> idx.fillna(0)
Index([0.0, 0.0, 3.0], dtype='Float64')
value
scalar
Scalar value to use to fill holes (e.g. 0). This value cannot be a list-likes.
TypeError
fillna
.from_frame
from_frame
(
frame
:
typing
.
Union
[
bigframes
.
series
.
Series
,
bigframes
.
dataframe
.
DataFrame
],
)
-
> bigframes
.
core
.
indexes
.
base
.
Index
Make a MultiIndex from a DataFrame.
Examples:
>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None
>>> df = bpd.DataFrame([['HI', 'Temp'], ['HI', 'Precip'],
... ['NJ', 'Temp'], ['NJ', 'Precip']],
... columns=['a', 'b'])
>>> df
a b
0 HI Temp
1 HI Precip
2 NJ Temp
3 NJ Precip
<BLANKLINE>
[4 rows x 2 columns]
>>> bpd.MultiIndex.from_frame(df)
Index([0, 1, 2, 3], dtype='Int64')
frame
Union[ bigframes.pandas.Series
, bigframes.pandas.DataFrame
]
bigframes.pandas.Series or bigframes.pandas.DataFrame to convert to bigframes.pandas.Index .
get_level_values
get_level_values
(
level
)
-
> bigframes
.
core
.
indexes
.
base
.
Index
Return an Index of values for requested level.
This is primarily useful to get an individual level of values from a MultiIndex, but is provided on Index as well for compatibility.
Examples:
>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None
>>> idx = bpd.Index(list('abc'))
>>> idx
Index(['a', 'b', 'c'], dtype='string')
Get level values by supplying level as integer:
>>> idx.get_level_values(0)
Index(['a', 'b', 'c'], dtype='string')
level
int or str
It is either the integer position or the name of the level.
get_loc
get_loc
(
key
)
-
> typing
.
Union
[
int
,
slice
,
bigframes
.
series
.
Series
]
Get integer location, slice or boolean mask for requested label.
NotImplementedError
KeyError
isin
isin
(
values
)
-
> bigframes
.
core
.
indexes
.
base
.
Index
Return a boolean array where the index values are in values
.
Compute boolean array to check whether each index value is found in the passed set of values. The length of the returned boolean array matches the length of the index.
Examples:
>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None
>>> idx = bpd.Index([1,2,3])
>>> idx
Index([1, 2, 3], dtype='Int64')
Check whether each index value in a list of values.
>>> idx.isin([1, 4])
Index([True, False, False], dtype='boolean')
>>> midx = bpd.MultiIndex.from_arrays([[1,2,3],
... ['red', 'blue', 'green']],
... names=('number', 'color'))
>>> midx
MultiIndex([(1, 'red'),
(2, 'blue'),
(3, 'green')],
names=['number', 'color'])
values
set or list-like
Sought values.
TypeError
isin()
is not a list-likeitem
item
()
Return the first element of the underlying data as a Python scalar.
Examples:
>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None
>>> s = bpd.Series([1], index=['a'])
>>> s.index.item()
'a'
ValueError
scalar
max
max
()
-
> typing
.
Any
Return the maximum value of the Index.
Examples:
>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None
>>> idx = bpd.Index([3, 2, 1])
>>> int(idx.max())
3
>>> idx = bpd.Index(['c', 'b', 'a'])
>>> idx.max()
'c'
scalar
min
min
()
-
> typing
.
Any
Return the minimum value of the Index.
Examples:
>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None
>>> idx = bpd.Index([3, 2, 1])
>>> int(idx.min())
1
>>> idx = bpd.Index(['c', 'b', 'a'])
>>> idx.min()
'a'
scalar
nunique
nunique
()
-
> int
Return number of unique elements in the object.
Excludes NA values by default.
Examples:
>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None
>>> s = bpd.Series([1, 3, 5, 7, 7])
>>> s
0 1
1 3
2 5
3 7
4 7
dtype: Int64
>>> int(s.nunique())
4
int
rename
Alter Index or MultiIndex name.
Able to set new names without level. Defaults to returning new index. Length of names must match number of levels in MultiIndex.
Examples:
>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None
>>> idx = bpd.Index(['A', 'C', 'A', 'B'], name='score')
>>> idx.rename('grade')
Index(['A', 'C', 'A', 'B'], dtype='string', name='grade')
name
label or list of labels
Name(s) to set.
inplace
bool
Default False. Modifies the object directly, instead of creating a new Index or MultiIndex.
ValueError
name
is not the same length as levels.inplace=True
.sort_values
sort_values
(
*
,
inplace
:
bool
=
False
,
ascending
:
bool
=
True
,
na_position
:
str
=
"last"
)
-
> bigframes
.
core
.
indexes
.
base
.
Index
Return a sorted copy of the index.
Return a sorted copy of the index, and optionally return the indices that sorted the index itself.
Examples:
>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None
>>> idx = bpd.Index([10, 100, 1, 1000])
>>> idx
Index([10, 100, 1, 1000], dtype='Int64')
Sort values in ascending order (default behavior).
>>> idx.sort_values()
Index([1, 10, 100, 1000], dtype='Int64')
ascending
bool, default True
Should the index values be sorted in an ascending order.
na_position
{'first' or 'last'}, default 'last'
Argument 'first' puts NaNs at the beginning, 'last' puts NaNs at the end.
ValueError
no_position
is not one of first
or last
.pandas.Index
to_numpy
to_numpy
(
dtype
=
None
,
*
,
allow_large_results
=
None
,
**
kwargs
)
-
> numpy
.
ndarray
A NumPy ndarray representing the values in this Series or Index.
allow_large_results
bool, default None
If not None, overrides the global setting to allow or disallow large query results over the default size limit of 10 GB.
to_pandas
Gets the Index as a pandas Index.
allow_large_results
bool, default None
If not None, overrides the global setting to allow or disallow large query results over the default size limit of 10 GB.
dry_run
bool, default False
If this argument is true, this method will not process the data. Instead, it returns a Pandas series containing dtype and the amount of bytes to be processed.
pandas.Index pandas.Series
to_series
to_series
(
index
:
typing
.
Optional
[
bigframes
.
core
.
indexes
.
base
.
Index
]
=
None
,
name
:
typing
.
Optional
[
typing
.
Hashable
]
=
None
,
)
-
> bigframes
.
series
.
Series
Create a Series with both index and values equal to the index keys.
Useful with map for returning an indexer based on an index.
Examples:
>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None
>>> idx = bpd.Index(['Ant', 'Bear', 'Cow'], name='animal')
By default, the original index and original name is reused.
>>> idx.to_series()
animal
Ant Ant
Bear Bear
Cow Cow
Name: animal, dtype: string
To enforce a new index, specify new labels to index:
>>> idx.to_series(index=[0, 1, 2])
0 Ant
1 Bear
2 Cow
Name: animal, dtype: string
To override the name of the resulting column, specify name:
>>> idx.to_series(name='zoo')
animal
Ant Ant
Bear Bear
Cow Cow
Name: zoo, dtype: string
index
Index, optional
Index of resulting Series. If None, defaults to original index.
name
str, optional
Name of resulting Series. If None, defaults to name of original index.
transpose
transpose
()
-
> bigframes
.
core
.
indexes
.
base
.
Index
Return the transpose, which is by definition self.
unique
unique
(
level
:
typing
.
Optional
[
typing
.
Union
[
typing
.
Hashable
,
int
]]
=
None
,
)
-
> bigframes
.
core
.
indexes
.
base
.
Index
Returns unique values in the index.
Examples:
>>> import bigframes.pandas as bpd
>>> bpd.options.display.progress_bar = None
>>> idx = bpd.Index([1, 1, 2, 3, 3])
>>> idx.unique()
Index([1, 2, 3], dtype='Int64')
level
int or hashable, optional
Only return values from specified level (for MultiIndex). If int, gets the level by integer position, else by level name.
value_counts
value_counts
(
normalize
:
bool
=
False
,
sort
:
bool
=
True
,
ascending
:
bool
=
False
,
*
,
dropna
:
bool
=
True
)
Return a Series containing counts of unique values.
The resulting object will be in descending order so that the first element is the most frequently-occurring element. Excludes NA values by default.
Examples:
>>> import bigframes.pandas as bpd
>>> import numpy as np
>>> bpd.options.display.progress_bar = None
>>> index = bpd.Index([3, 1, 2, 3, 4, np.nan])
>>> index.value_counts()
3.0 2
1.0 1
2.0 1
4.0 1
Name: count, dtype: Int64
With normalize set to True, returns the relative frequency by dividing all values by the sum of values.
>>> s = bpd.Series([3, 1, 2, 3, 4, np.nan])
>>> s.value_counts(normalize=True)
3.0 0.4
1.0 0.2
2.0 0.2
4.0 0.2
Name: proportion, dtype: Float64
dropna
With dropna set to False we can also see NaN index values.
>>> s.value_counts(dropna=False)
3.0 2
1.0 1
2.0 1
4.0 1
<NA> 1
Name: count, dtype: Int64
normalize
bool, default False
If True, then the object returned will contain the relative frequencies of the unique values.
sort
bool, default True
Sort by frequencies.
ascending
bool, default False
Sort in ascending order.
dropna
bool, default True
Don't include counts of NaN.