@@ -24,6 +24,37 @@ class Index:
24
24
a default session is used.
25
25
"""
26
26
27
+ @property
28
+ def name (self ):
29
+ """Returns Index name.
30
+
31
+ **Examples:**
32
+
33
+ >>> import bigframes.pandas as bpd
34
+ >>> bpd.options.display.progress_bar = None
35
+
36
+ >>> idx = bpd.Index([1, 2, 3], name='x')
37
+ >>> idx
38
+ Index([1, 2, 3], dtype='Int64', name='x')
39
+ >>> idx.name
40
+ 'x'
41
+
42
+ Returns:
43
+ blocks.Label:
44
+ Index or MultiIndex name
45
+ """
46
+ raise NotImplementedError (constants .ABSTRACT_METHOD_ERROR_MESSAGE )
47
+
48
+ @property
49
+ def names (self ):
50
+ """Returns the names of the Index.
51
+
52
+ Returns:
53
+ Sequence[blocks.Label]:
54
+ A Sequence of Index or MultiIndex name
55
+ """
56
+ raise NotImplementedError (constants .ABSTRACT_METHOD_ERROR_MESSAGE )
57
+
27
58
@property
28
59
def values (self ):
29
60
"""Return an array representing the data in the Index.
@@ -46,6 +77,166 @@ def values(self):
46
77
"""
47
78
raise NotImplementedError (constants .ABSTRACT_METHOD_ERROR_MESSAGE )
48
79
80
+ @property
81
+ def ndim (self ):
82
+ """
83
+ Number of dimensions of the underlying data, by definition 1.
84
+
85
+ **Examples:**
86
+
87
+ >>> import bigframes.pandas as bpd
88
+ >>> bpd.options.display.progress_bar = None
89
+
90
+ >>> s = bpd.Series(['Ant', 'Bear', 'Cow'])
91
+ >>> s
92
+ 0 Ant
93
+ 1 Bear
94
+ 2 Cow
95
+ dtype: string
96
+
97
+ >>> s.ndim
98
+ 1
99
+
100
+ For Index:
101
+
102
+ >>> idx = bpd.Index([1, 2, 3])
103
+ >>> idx
104
+ Index([1, 2, 3], dtype='Int64')
105
+
106
+ >>> idx.ndim
107
+ 1
108
+
109
+ Returns:
110
+ int:
111
+ Number or dimensions.
112
+ """
113
+ raise NotImplementedError (constants .ABSTRACT_METHOD_ERROR_MESSAGE )
114
+
115
+ @property
116
+ def size (self ) -> int :
117
+ """
118
+ Return the number of elements in the underlying data.
119
+
120
+ **Examples:**
121
+
122
+ >>> import bigframes.pandas as bpd
123
+ >>> bpd.options.display.progress_bar = None
124
+
125
+ For Series:
126
+
127
+ >>> s = bpd.Series(['Ant', 'Bear', 'Cow'])
128
+ >>> s
129
+ 0 Ant
130
+ 1 Bear
131
+ 2 Cow
132
+ dtype: string
133
+
134
+ For Index:
135
+
136
+ >>> idx = bpd.Index([1, 2, 3])
137
+ >>> idx
138
+ Index([1, 2, 3], dtype='Int64')
139
+
140
+ Returns:
141
+ int:
142
+ Number of elements
143
+ """
144
+ raise NotImplementedError (constants .ABSTRACT_METHOD_ERROR_MESSAGE )
145
+
146
+ @property
147
+ def empty (self ) -> bool :
148
+ raise NotImplementedError (constants .ABSTRACT_METHOD_ERROR_MESSAGE )
149
+
150
+ @property
151
+ def is_monotonic_increasing (self ) -> bool :
152
+ """
153
+ Return a boolean if the values are equal or increasing.
154
+
155
+ **Examples:**
156
+
157
+ >>> import bigframes.pandas as bpd
158
+ >>> bpd.options.display.progress_bar = None
159
+
160
+ >>> bool(bpd.Index([1, 2, 3]).is_monotonic_increasing)
161
+ True
162
+
163
+ >>> bool(bpd.Index([1, 2, 2]).is_monotonic_increasing)
164
+ True
165
+
166
+ >>> bool(bpd.Index([1, 3, 2]).is_monotonic_increasing)
167
+ False
168
+
169
+ Returns:
170
+ bool:
171
+ True, if the values monotonically increasing, otherwise False.
172
+ """
173
+ raise NotImplementedError (constants .ABSTRACT_METHOD_ERROR_MESSAGE )
174
+
175
+ @property
176
+ def is_monotonic_decreasing (self ) -> bool :
177
+ """
178
+ Return a boolean if the values are equal or decreasing.
179
+
180
+ **Examples:**
181
+
182
+ >>> import bigframes.pandas as bpd
183
+ >>> bpd.options.display.progress_bar = None
184
+
185
+ >>> bool(bpd.Index([3, 2, 1]).is_monotonic_decreasing)
186
+ True
187
+
188
+ >>> bool(bpd.Index([3, 2, 2]).is_monotonic_decreasing)
189
+ True
190
+
191
+ >>> bool(bpd.Index([3, 1, 2]).is_monotonic_decreasing)
192
+ False
193
+
194
+ Returns:
195
+ bool:
196
+ True, if the values monotonically decreasing, otherwise False.
197
+ """
198
+ raise NotImplementedError (constants .ABSTRACT_METHOD_ERROR_MESSAGE )
199
+
200
+ @classmethod
201
+ def from_frame (cls , frame ) -> Index :
202
+ """
203
+ Make a MultiIndex from a DataFrame.
204
+
205
+ **Examples:**
206
+
207
+ >>> import bigframes.pandas as bpd
208
+ >>> bpd.options.display.progress_bar = None
209
+
210
+ >>> df = bpd.DataFrame([['HI', 'Temp'], ['HI', 'Precip'],
211
+ ... ['NJ', 'Temp'], ['NJ', 'Precip']],
212
+ ... columns=['a', 'b'])
213
+ >>> df
214
+ a b
215
+ 0 HI Temp
216
+ 1 HI Precip
217
+ 2 NJ Temp
218
+ 3 NJ Precip
219
+ <BLANKLINE>
220
+ [4 rows x 2 columns]
221
+
222
+ >>> bpd.MultiIndex.from_frame(df)
223
+ Index([0, 1, 2, 3], dtype='Int64')
224
+
225
+ Args:
226
+ frame (Union[bigframes.pandas.Series, bigframes.pandas.DataFrame]):
227
+ bigframes.pandas.Series or bigframes.pandas.DataFrame to convert
228
+ to bigframes.pandas.Index.
229
+
230
+ Returns:
231
+ bigframes.pandas.Index:
232
+ The Index representation of the given Series or DataFrame.
233
+
234
+ Raises:
235
+ bigframes.exceptions.NullIndexError:
236
+ If Index is Null.
237
+ """
238
+ raise NotImplementedError (constants .ABSTRACT_METHOD_ERROR_MESSAGE )
239
+
49
240
@property
50
241
def shape (self ):
51
242
"""
0 commit comments