Reputation: 139
My code-
for i, row in df.iterrows():
thisdict = {
row['house']: "Holding_number"}
print(thisdict)
Result- {'House 193/A': 'Holding_number'}
Expected output - {'House 193/A': 0,10 'Holding_number'}
I want to add start and end indices.
Dataframe-
Upvotes: 0
Views: 72
Reputation: 71610
Do you mean by?
lod = []
for i, row in df.iterrows():
lod.append({row['house']: f"(0, {len(row['house']) - 1}) {row['label1']}"})
print(lod)
Upvotes: 2
Reputation: 261880
Use a dictionary comprehension:
thisdict = {
row['house']: (0, len(row['house']-1, row['label1'])
i, row in df.iterrows()
}
Upvotes: 1