jeudi 29 avril 2021

How to get index of an outcome of if statement?

I have two dataframes 'ds' and 'df'

ds-outcome of Selenium Parser Which Constantly loops and have dynamic dataset with columns(Date, Price, id) id is static But Price and Date are Dynamic

df-SQL Database To where Values From 'ds' should be written to

  1. I need To Write Values From 'ds' to 'df'
  2. Also need update values in 'df' if those values changed in 'ds'
  3. If new values are in 'ds' append those values to 'df'

Extra

If any one knows how to perform this operation using psycopg2 or sqlalchemy

Example:

import pandas as pd
ds = pd.read_csv("Info(Parser).csv")
df = pd.read_csv("Info(SQL).csv")
for idx, val in enumerate(df['id']):
        if val in ds['id']:
            (How To Update True Values?)
        else:
            (How to append only False Values?)

Aucun commentaire:

Enregistrer un commentaire