jeudi 3 décembre 2020

how do i get new output dataframe in Pandas based on an if else statement numeric condition [duplicate]

Hi i have a pandas DataFrame , i need to get Date and Field_Worker by the amount Individuls_Confirmed(int) those equal or greater than 10 to be specific, i need to do it using if else statement or just a condition that would make it easy and reuse, thank you

i am gettning (ValueError: The truth value of a Series is ambiguous. Use a.empty, a.bool(), a.item(), a.any() or a.all().)

In SQL i would do

SELECT Field_Worker, Date FROM table WHERE Individuls_Confirmed <= 10

Here is my Code fairly new to python esp pandas

import mysql.connector

from tabulate import tabulate
import numpy as np
import pandas as pd
from matplotlib import pyplot

data = pd.read_csv(r'C:\Users\Selamola\Documents\R\MyrThings\Confirmations4748.csv')

pd.set_option('display.max_rows', None)
pd.set_option('display.max_columns', None)
pd.set_option('display.width', None)
pd.set_option('display.max_colwidth', None)

csvData = pd.DataFrame(data)

if csvData['Individuls_Confirmed'] <= 10:
     print(csvData['Field_Worker'], csvData['Date'])


# print(csvData)

Sample of how DataFrame looks Table

Aucun commentaire:

Enregistrer un commentaire