Reputation: 163
I'm trying to catch an empty list going into a pandas data frame but the above error occurs:
ValueError: Shape of passed values is (1, 5), indices imply (5, 5)
I currently have a simple set up here:
if not daily_info:
daily_info= ["No data found today","No data found today","No data found today","No data found today","No data found today"]
df = pd.DataFrame(data=daily_info, columns=['Send/Collect', 'Hospital', 'Courier', 'Kit', 'Manufacturer'])
df = df.assign(Status="Not Started")
This may seem similar to this where it is asking about appending an existing DF however the answers don't really help me with a different context.
Can anyone help me as to where i've gone wrong?
Upvotes: 2
Views: 3168
Reputation: 863541
I think need pass nested list
to DataFrame
constructor - [daily_info]
:
daily_info= ["No data found today","No data found today","No data found today","No data found today","No data found today"]
df = pd.DataFrame(data=[daily_info], columns=['Send/Collect', 'Hospital', 'Courier', 'Kit', 'Manufacturer'])
df = df.assign(Status="Not Started")
print (df)
Send/Collect Hospital Courier \
0 No data found today No data found today No data found today
Kit Manufacturer Status
0 No data found today No data found today Not Started
Upvotes: 1