I have a dataset like below:
Which needs to be checked against the below master
dataset:
Here, the condition is to check the associated value for the Group
and its value from the dataset with the master dataset and pick the S2SFlag
column value from the master dataset and create an S2SFlag
column in the dataset. The original dataset is returned by querying the database using AWS Lambda
.
Also, if post-checking if there is a 'No
' value for any of the Group
attributes then the Flag for that particular group would be 'No
'. The expected output
is as below:
As it can be seen that for the first record in the expected output, S2SFlag for each of the group attributes is Yes
so the S2SFlag for the first record is 'Yes
' and in the second case it is No
because one of the values of Age
has No
as its S2SFlag.
Attempt so far:
df1 = pd.read_csv('/home/siddhesh/Documents/data.csv')
df2 = pd.read_csv('/home/siddhesh/Documents/data1.csv') # Assuming it as query results
age = df2['Age']
Channel = df2['Channel']
Status = df2['Status']
df3 = df1[(df1['Attributes'] = str(age))]
if (age == df3.iloc[0]):
getS2s = df1['S2SFlag']
if (getS2s == 'No'):
df1['S2SFlag'] = 'No'
It gives me the below error:
Traceback (most recent call last):
File "/home/siddhesh/Downloads/pyspark/src/sample/test.py", line 16, in <module>
if (age == df3.iloc[0]):
File "/home/siddhesh/.local/lib/python3.8/site-packages/pandas/core/indexing.py", line 931, in __getitem__
return self._getitem_axis(maybe_callable, axis=axis)
File "/home/siddhesh/.local/lib/python3.8/site-packages/pandas/core/indexing.py", line 1566, in _getitem_axis
self._validate_integer(key, axis)
File "/home/siddhesh/.local/lib/python3.8/site-packages/pandas/core/indexing.py", line 1500, in _validate_integer
raise IndexError("single positional indexer is out-of-bounds")
IndexError: single positional indexer is out-of-bounds