'Trying to Generate an NFT Using .CSV Metadata and Pandas
I have been scratching my head at generating my actual NFT's from a .csv file for a long time and looking for resources has been challenging at the very least for my Hardcoding Method (Following a Guide) If Anyone could Look through what I have and Offer some Help Figuring out what's going on I would be FOREVER Endebted to you!
def generateOneRandRow(ADATvID):
FILENAME = "ADA Tv" + str(ADATvID)
NO = ADATvID
BACKGROUND = randBackground()
ACCESSORIES = randAccessories()
HEAD = randHead()
HAT = randHat()
BODY = randBody()
CHEST = randChest()
ARMS = randArms()
FACE = randFace()
singleRow = [FILENAME,NO,BACKGROUND,ACCESSORIES,HEAD,HAT,BODY,CHEST,ARMS,FACE]
testThisRow =["ADA Tv2925","2925","cnft","couchbear","bnw","mullet","damagedorange","bluesuit","greenlightsaber","inlove"]
def checkIfExists(checkRow):
aData = pd.read_csv('adalist.csv')
index_list = aData[(aData['Background'] == checkRow[2])] & (aData['Accessories'] == checkRow[3]) & (aData['Head'] == checkRow[4]) & (aData['Hat'] == checkRow[5]) & (aData['Body'] == checkRow[6]) &(aData['Chest'] ==checkRow[7]) & (aData['Arms'] ==checkRow[7]) & (aData['Face'] == checkRow[8]).index.tolist()
print(index_list)
if index_list == []:
return False
else:
return True
checkIfExists(testThisRow)
Solution 1:[1]
Change:
index_list = aData[(aData['Background'] == checkRow[2])] & (aData['Accessories'] == checkRow[3]) & (aData['Head'] == checkRow[4]) & (aData['Hat'] == checkRow[5]) & (aData['Body'] == checkRow[6]) &(aData['Chest'] ==checkRow[7]) & (aData['Arms'] ==checkRow[7]) & (aData['Face'] == checkRow[8]).index.tolist()
to:
index_list = aData[(aData['Background'] == checkRow[2])
& (aData['Accessories'] == checkRow[3]) &
(aData['Head'] == checkRow[4]) &
(aData['Hat'] == checkRow[5]) &
(aData['Body'] == checkRow[6]) &
(aData['Chest'] ==checkRow[7]) &
(aData['Arms'] ==checkRow[7]) &
(aData['Face'] == checkRow[8])].index.tolist()
Because you did not provide data, i reproduced your error as follows:
df = pd.DataFrame({'a':[1,'2'], 'b':[5,6]})
df[(df['a']=='2')]&(df['b']==6).index.tolist()
With error:
TypeError: unsupported operand type(s) for &: 'str' and 'int'
Editing the brackets:
df = pd.DataFrame({'a':[1,'2'], 'b':[5,6]})
df[(df['a']=='2')&(df['b']==6)].index.tolist()
With no error.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
