Skip to content

Commit b81a6e6

Browse files
committed
avoid bpd.NA
1 parent f884610 commit b81a6e6

File tree

8 files changed

+37
-38
lines changed

8 files changed

+37
-38
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@
463463

464464
* Address `read_csv` with both `index_col` and `use_cols` behavior inconsistency with pandas ([#1785](https://github.com/googleapis/python-bigquery-dataframes/issues/1785)) ([ba7c313](https://github.com/googleapis/python-bigquery-dataframes/commit/ba7c313c8d308e3ff3f736b60978cb7a51715209))
465465
* Allow KMeans model init parameter as k-means++ alias ([#1790](https://github.com/googleapis/python-bigquery-dataframes/issues/1790)) ([0b59cf1](https://github.com/googleapis/python-bigquery-dataframes/commit/0b59cf1008613770fa1433c6da395e755c86fe22))
466-
* Replace function now can handle bpd.NA value. ([#1786](https://github.com/googleapis/python-bigquery-dataframes/issues/1786)) ([7269512](https://github.com/googleapis/python-bigquery-dataframes/commit/7269512a28eb42029447d5380c764353278a74e1))
466+
* Replace function now can handle pd.NA value. ([#1786](https://github.com/googleapis/python-bigquery-dataframes/issues/1786)) ([7269512](https://github.com/googleapis/python-bigquery-dataframes/commit/7269512a28eb42029447d5380c764353278a74e1))
467467

468468

469469
### Documentation

bigframes/operations/strings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ def reverse(self) -> series.Series:
6868
**Examples:**
6969
7070
71-
>>> s = bpd.Series(["apple", "banana", "", bpd.NA])
71+
>>> s = bpd.Series(["apple", "banana", "", pd.NA])
7272
>>> s.str.reverse()
7373
0 elppa
7474
1 ananab

tests/system/small/operations/test_strings.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ def test_strip(scalars_dfs):
288288
],
289289
)
290290
def test_strip_w_to_strip(to_strip):
291-
s = bpd.Series(["1. Ant. ", "2. Bee!\n", "3. Cat?\t", bpd.NA])
291+
s = bpd.Series(["1. Ant. ", "2. Bee!\n", "3. Cat?\t", pd.NA])
292292
pd_s = s.to_pandas()
293293

294294
bf_result = s.str.strip(to_strip=to_strip).to_pandas()
@@ -434,7 +434,7 @@ def test_rstrip(scalars_dfs):
434434
],
435435
)
436436
def test_rstrip_w_to_strip(to_strip):
437-
s = bpd.Series(["1. Ant. ", "2. Bee!\n", "3. Cat?\t", bpd.NA])
437+
s = bpd.Series(["1. Ant. ", "2. Bee!\n", "3. Cat?\t", pd.NA])
438438
pd_s = s.to_pandas()
439439

440440
bf_result = s.str.rstrip(to_strip=to_strip).to_pandas()
@@ -469,7 +469,7 @@ def test_lstrip(scalars_dfs):
469469
],
470470
)
471471
def test_lstrip_w_to_strip(to_strip):
472-
s = bpd.Series(["1. Ant. ", "2. Bee!\n", "3. Cat?\t", bpd.NA])
472+
s = bpd.Series(["1. Ant. ", "2. Bee!\n", "3. Cat?\t", pd.NA])
473473
pd_s = s.to_pandas()
474474

475475
bf_result = s.str.lstrip(to_strip=to_strip).to_pandas()

tests/unit/test_pandas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def test_cut_raises_with_invalid_bins(bins: int, error_message: str):
174174

175175

176176
def test_pandas_attribute():
177-
assert bpd.NA is pd.NA
177+
assert pd.NA is pd.NA
178178
assert bpd.BooleanDtype is pd.BooleanDtype
179179
assert bpd.Float64Dtype is pd.Float64Dtype
180180
assert bpd.Int64Dtype is pd.Int64Dtype

third_party/bigframes_vendored/pandas/core/frame.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1749,7 +1749,7 @@ def dropna(
17491749
17501750
>>> df = bpd.DataFrame({"name": ['Alfred', 'Batman', 'Catwoman'],
17511751
... "toy": [np.nan, 'Batmobile', 'Bullwhip'],
1752-
... "born": [bpd.NA, "1940-04-25", bpd.NA]})
1752+
... "born": [pd.NA, "1940-04-25", pd.NA]})
17531753
>>> df
17541754
name toy born
17551755
0 Alfred <NA> <NA>
@@ -2217,7 +2217,7 @@ def sort_values(
22172217
22182218
22192219
>>> df = bpd.DataFrame({
2220-
... 'col1': ['A', 'A', 'B', bpd.NA, 'D', 'C'],
2220+
... 'col1': ['A', 'A', 'B', pd.NA, 'D', 'C'],
22212221
... 'col2': [2, 1, 9, 8, 7, 4],
22222222
... 'col3': [0, 1, 9, 4, 2, 3],
22232223
... 'col4': ['a', 'B', 'c', 'D', 'e', 'F']
@@ -4361,13 +4361,12 @@ def map(self, func, na_action: Optional[str] = None) -> DataFrame:
43614361
43624362
**Examples:**
43634363
4364-
43654364
Let's use ``reuse=False`` flag to make sure a new ``remote_function``
43664365
is created every time we run the following code, but you can skip it
43674366
to potentially reuse a previously deployed ``remote_function`` from
43684367
the same user defined function.
43694368
4370-
>>> @bpd.remote_function(reuse=False, cloud_function_service_account="default")
4369+
>>> @bpd.remote_function(reuse=False, cloud_function_service_account="default") # doctest: +SKIP
43714370
... def minutes_to_hours(x: int) -> float:
43724371
... return x/60
43734372
@@ -4384,8 +4383,8 @@ def map(self, func, na_action: Optional[str] = None) -> DataFrame:
43844383
<BLANKLINE>
43854384
[5 rows x 2 columns]
43864385
4387-
>>> df_hours = df_minutes.map(minutes_to_hours)
4388-
>>> df_hours
4386+
>>> df_hours = df_minutes.map(minutes_to_hours) # doctest: +SKIP
4387+
>>> df_hours # doctest: +SKIP
43894388
system_minutes user_minutes
43904389
0 0.0 0.0
43914390
1 0.5 0.25
@@ -4401,11 +4400,11 @@ def map(self, func, na_action: Optional[str] = None) -> DataFrame:
44014400
44024401
>>> df_minutes = bpd.DataFrame(
44034402
... {
4404-
... "system_minutes" : [0, 30, 60, None, 90, 120, bpd.NA],
4405-
... "user_minutes" : [0, 15, 75, 90, 6, None, bpd.NA]
4403+
... "system_minutes" : [0, 30, 60, None, 90, 120, pd.NA],
4404+
... "user_minutes" : [0, 15, 75, 90, 6, None, pd.NA]
44064405
... }, dtype="Int64")
4407-
>>> df_hours = df_minutes.map(minutes_to_hours, na_action='ignore')
4408-
>>> df_hours
4406+
>>> df_hours = df_minutes.map(minutes_to_hours, na_action='ignore') # doctest: +SKIP
4407+
>>> df_hours # doctest: +SKIP
44094408
system_minutes user_minutes
44104409
0 0.0 0.0
44114410
1 0.5 0.25
@@ -6521,7 +6520,7 @@ def value_counts(
65216520
65226521
65236522
>>> df = bpd.DataFrame({'num_legs': [2, 4, 4, 6, 7],
6524-
... 'num_wings': [2, 0, 0, 0, bpd.NA]},
6523+
... 'num_wings': [2, 0, 0, 0, pd.NA]},
65256524
... index=['falcon', 'dog', 'cat', 'ant', 'octopus'],
65266525
... dtype='Int64')
65276526
>>> df

third_party/bigframes_vendored/pandas/core/generic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ def isna(self) -> NDFrame:
809809
810810
>>> df = bpd.DataFrame(dict(
811811
... age=[5, 6, np.nan],
812-
... born=[bpd.NA, "1940-04-25", "1940-04-25"],
812+
... born=[pd.NA, "1940-04-25", "1940-04-25"],
813813
... name=['Alfred', 'Batman', ''],
814814
... toy=[None, 'Batmobile', 'Joker'],
815815
... ))
@@ -841,7 +841,7 @@ def isna(self) -> NDFrame:
841841
842842
Show which entries in a Series are NA:
843843
844-
>>> ser = bpd.Series([5, None, 6, np.nan, bpd.NA])
844+
>>> ser = bpd.Series([5, None, 6, np.nan, pd.NA])
845845
>>> ser
846846
0 5
847847
1 <NA>

third_party/bigframes_vendored/pandas/core/series.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ def shape(self):
160160
>>> s = bpd.Series([1, 4, 9, 16])
161161
>>> s.shape
162162
(4,)
163-
>>> s = bpd.Series(['Alice', 'Bob', bpd.NA])
163+
>>> s = bpd.Series(['Alice', 'Bob', pd.NA])
164164
>>> s.shape
165165
(3,)
166166
"""
@@ -866,7 +866,7 @@ def count(self):
866866
**Examples:**
867867
868868
869-
>>> s = bpd.Series([0.0, 1.0, bpd.NA])
869+
>>> s = bpd.Series([0.0, 1.0, pd.NA])
870870
>>> s
871871
0 0.0
872872
1 1.0
@@ -2517,7 +2517,7 @@ def dropna(self, *, axis=0, inplace: bool = False, how=None) -> Series:
25172517
25182518
Empty strings are not considered NA values. ``None`` is considered an NA value.
25192519
2520-
>>> ser = bpd.Series(['2', bpd.NA, '', None, 'I stay'], dtype='object')
2520+
>>> ser = bpd.Series(['2', pd.NA, '', None, 'I stay'], dtype='object')
25212521
>>> ser
25222522
0 2
25232523
1 <NA>
@@ -3089,7 +3089,7 @@ def add(self, other) -> Series:
30893089
**Examples:**
30903090
30913091
3092-
>>> a = bpd.Series([1, 2, 3, bpd.NA])
3092+
>>> a = bpd.Series([1, 2, 3, pd.NA])
30933093
>>> a
30943094
0 1
30953095
1 2
@@ -4391,7 +4391,7 @@ def max(
43914391
43924392
Calculating the max of a Series containing ``NA`` values:
43934393
4394-
>>> s = bpd.Series([1, 3, bpd.NA])
4394+
>>> s = bpd.Series([1, 3, pd.NA])
43954395
>>> s
43964396
0 1
43974397
1 3
@@ -4431,7 +4431,7 @@ def min(
44314431
44324432
Calculating the min of a Series containing ``NA`` values:
44334433
4434-
>>> s = bpd.Series([1, 3, bpd.NA])
4434+
>>> s = bpd.Series([1, 3, pd.NA])
44354435
>>> s
44364436
0 1
44374437
1 3
@@ -4516,7 +4516,7 @@ def sum(self):
45164516
45174517
Calculating the sum of a Series containing ``NA`` values:
45184518
4519-
>>> s = bpd.Series([1, 3, bpd.NA])
4519+
>>> s = bpd.Series([1, 3, pd.NA])
45204520
>>> s
45214521
0 1
45224522
1 3
@@ -4550,7 +4550,7 @@ def mean(self):
45504550
45514551
Calculating the mean of a Series containing ``NA`` values:
45524552
4553-
>>> s = bpd.Series([1, 3, bpd.NA])
4553+
>>> s = bpd.Series([1, 3, pd.NA])
45544554
>>> s
45554555
0 1
45564556
1 3
@@ -5215,7 +5215,7 @@ def value_counts(
52155215
**Examples:**
52165216
52175217
5218-
>>> s = bpd.Series([3, 1, 2, 3, 4, bpd.NA], dtype="Int64")
5218+
>>> s = bpd.Series([3, 1, 2, 3, 4, pd.NA], dtype="Int64")
52195219
52205220
>>> s
52215221
0 3
@@ -5470,7 +5470,7 @@ def map(
54705470
**Examples:**
54715471
54725472
5473-
>>> s = bpd.Series(['cat', 'dog', bpd.NA, 'rabbit'])
5473+
>>> s = bpd.Series(['cat', 'dog', pd.NA, 'rabbit'])
54745474
>>> s
54755475
0 cat
54765476
1 dog

third_party/bigframes_vendored/pandas/core/strings/accessor.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ def len(self):
146146
147147
Returns the length (number of characters) in a string.
148148
149-
>>> s = bpd.Series(['dog', '', bpd.NA])
149+
>>> s = bpd.Series(['dog', '', pd.NA])
150150
>>> s.str.len()
151151
0 3
152152
1 0
@@ -249,7 +249,7 @@ def strip(self, to_strip: typing.Optional[str] = None):
249249
... '1. Ant.',
250250
... ' 2. Bee? ',
251251
... '\\t3. Cat!\\n',
252-
... bpd.NA,
252+
... pd.NA,
253253
... ])
254254
>>> s.str.strip()
255255
0 1. Ant.
@@ -535,7 +535,7 @@ def rstrip(self, to_strip: typing.Optional[str] = None):
535535
536536
>>> import bigframes.pandas as bpd
537537
538-
>>> s = bpd.Series(['Ant', ' Bee ', '\tCat\n', bpd.NA])
538+
>>> s = bpd.Series(['Ant', ' Bee ', '\tCat\n', pd.NA])
539539
>>> s.str.rstrip()
540540
0 Ant
541541
1 Bee
@@ -567,7 +567,7 @@ def lstrip(self, to_strip: typing.Optional[str] = None):
567567
568568
>>> import bigframes.pandas as bpd
569569
570-
>>> s = bpd.Series(['Ant', ' Bee ', '\tCat\n', bpd.NA])
570+
>>> s = bpd.Series(['Ant', ' Bee ', '\tCat\n', pd.NA])
571571
>>> s.str.lstrip()
572572
0 Ant
573573
1 Bee
@@ -817,7 +817,7 @@ def replace(
817817
as a regex. When *repl* is a string, it replaces matching regex patterns
818818
as with `re.sub()`. NaN value(s) in the Series are left as is:
819819
820-
>>> s = bpd.Series(['foo', 'fuz', bpd.NA])
820+
>>> s = bpd.Series(['foo', 'fuz', pd.NA])
821821
>>> s.str.replace('f.', 'ba', regex=True)
822822
0 bao
823823
1 baz
@@ -827,7 +827,7 @@ def replace(
827827
When *pat* is a string and *regex* is False, every *pat* is replaced
828828
with *repl* as with `str.replace()`:
829829
830-
>>> s = bpd.Series(['f.o', 'fuz', bpd.NA])
830+
>>> s = bpd.Series(['f.o', 'fuz', pd.NA])
831831
>>> s.str.replace('f.', 'ba', regex=False)
832832
0 bao
833833
1 fuz
@@ -874,7 +874,7 @@ def startswith(
874874
875875
>>> import bigframes.pandas as bpd
876876
877-
>>> s = bpd.Series(['bat', 'Bear', 'caT', bpd.NA])
877+
>>> s = bpd.Series(['bat', 'Bear', 'caT', pd.NA])
878878
>>> s
879879
0 bat
880880
1 Bear
@@ -918,7 +918,7 @@ def endswith(
918918
919919
>>> import bigframes.pandas as bpd
920920
921-
>>> s = bpd.Series(['bat', 'bear', 'caT', bpd.NA])
921+
>>> s = bpd.Series(['bat', 'bear', 'caT', pd.NA])
922922
>>> s
923923
0 bat
924924
1 bear
@@ -1206,7 +1206,7 @@ def zfill(
12061206
12071207
>>> import bigframes.pandas as bpd
12081208
1209-
>>> s = bpd.Series(['-1', '1', '1000', bpd.NA])
1209+
>>> s = bpd.Series(['-1', '1', '1000', pd.NA])
12101210
>>> s
12111211
0 -1
12121212
1 1

0 commit comments

Comments
 (0)