@@ -417,22 +417,30 @@ def _upsert_batch(self,
417
417
418
418
def upsert_dataframe (self ,
419
419
df ,
420
- namespase : str = None ,
420
+ namespace : str = None ,
421
421
batch_size : int = 500 ,
422
+ use_async_requests : bool = True ,
422
423
show_progress : bool = True ) -> None :
423
424
"""Upserts a dataframe into the index.
424
425
425
426
Args:
426
427
df: A pandas dataframe with the following columns: id, vector, and metadata.
427
428
namespace: The namespace to upsert into.
428
429
batch_size: The number of rows to upsert in a single batch.
430
+ use_async_requests: Whether to upsert multiple requests at the same time using asynchronous request mechanism.
431
+ Set to `False`
429
432
show_progress: Whether to show a progress bar.
430
433
"""
431
- if find_spec ("pandas" ) is None :
432
- raise ImportError ("pandas not found. Please install pandas to use this method." )
434
+ try :
435
+ import pandas as pd
436
+ except ImportError :
437
+ raise RuntimeError ("The `pandas` package is not installed. Please install pandas to use `upsert_from_dataframe()`" )
438
+
439
+ if not isinstance (df , pd .DataFrame ):
440
+ raise ValueError (f"Only pandas dataframes are supported. Found: { type (df )} " )
433
441
434
442
async_results = [
435
- self .upsert (vectors = chunk , namespace = namespase , async_req = True )
443
+ self .upsert (vectors = chunk , namespace = namespace , async_req = True )
436
444
for chunk in tqdm (self ._iter_dataframe (df , batch_size = batch_size ),
437
445
total = len (df ) // batch_size , disable = not show_progress )
438
446
]
0 commit comments