I'm reading data from Google Sheets and was able to successfully get it in:
header = result.get('values', [])[0] #First line is column names
values = result.get('values', [])[1:] #Everything else is data
Then after that I'm doing this:
if not values:
print('No data found.')
else:
df = pd.DataFrame(data=values, columns=header)
print(df.head(10))
but I'm getting an error:
AssertionError: 26 columns passed, passed data had 14 columns
If I print header or values I'm getting the data in List successfully.
len(values)is5297andlen(header)is26. I might not want to hard code it as the data will be added to it every now and then.headerdoes not align with the amount of columns invalues. Hence the 26 vs 14. Try this firstlen(pd.DataFrame(data=values).columns).14. SO on google sheet14columns has data to them and columns from 15 to 26 does not have any data yet. But the column names are there, so pandas should just add blank to its values right?df = pd.DataFrame(data=values, columns=header[:14])