Skip to content

A value is trying to be set on a copy of a slice from a DataFrame #133

@lgabs

Description

@lgabs

When reunning dialog service, a pandas warning appears warning about changing a copy of a slice dataframe. To avoid this, we can explicitly declare df_filtered a copy.

➜  dialog git:(luan/adopt-lcel-pt1) ✗ docker compose up dialog
[+] Building 0.0s (0/0)                                                                                  docker:desktop-linux
[+] Running 2/2
 ✔ Container dialog-db-1      Running                                                                                    0.0s
 ✔ Container dialog-dialog-1  Created                                                                                    0.1s
Attaching to dialog-dialog-1
dialog-dialog-1  | INFO  [alembic.runtime.migration] Context impl PostgresqlImpl.
dialog-dialog-1  | INFO  [alembic.runtime.migration] Will assume transactional DDL.
dialog-dialog-1  | /app/src/load_csv.py:4: DeprecationWarning:
dialog-dialog-1  | Pyarrow will become a required dependency of pandas in the next major release of pandas (pandas 3.0),
dialog-dialog-1  | (to allow more performant data types, such as the Arrow string type, and better interoperability with other libraries)
dialog-dialog-1  | but was not found to be installed on your system.
dialog-dialog-1  | If this would cause problems for you,
dialog-dialog-1  | please provide us feedback at https://github.com/pandas-dev/pandas/issues/54466
dialog-dialog-1  |
dialog-dialog-1  |   import pandas as pd
dialog-dialog-1  | Generating embeddings for new questions...
dialog-dialog-1  | New questions: 0
dialog-dialog-1  | /app/src/load_csv.py:52: SettingWithCopyWarning:
dialog-dialog-1  | A value is trying to be set on a copy of a slice from a DataFrame
dialog-dialog-1  |
dialog-dialog-1  | See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
dialog-dialog-1  |   df_filtered.drop(columns=["primary_key"], inplace=True)
dialog-dialog-1  | INFO:     Will watch for changes in these directories: ['/app/src']
dialog-dialog-1  | INFO:     Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)
dialog-dialog-1  | INFO:     Started reloader process [44] using WatchFiles
dialog-dialog-1  | INFO:     Started server process [46]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions