ValueError: arrays must all be same length in python using pandas DataFrame

Viewed 35048

I'm a newbie in python and using Dataframe from pandas package (python3.6).

I set it up like below code,

df = DataFrame({'list1': list1, 'list2': list2, 'list3': list3, 'list4': list4, 'list5': list5, 'list6': list6})

and it gives an error like ValueError: arrays must all be same length

So I checked all the length of arrays, and list1 & list2 have 1 more data than other lists. If I want to add 1 data to those other 4 lists(list3, list4, list5, list6) by using pd.resample, then how should I write code...?

Also, those lists are time series list with 1 minute.

Does anybody have an idea or help me out here?

Thanks in advance.

EDIT So I changed as what EdChum said. and added time list at the front. it is like below.

2017-04-01 0:00 895.87  730 12.8    4   19.1    380
2017-04-01 0:01 894.4   730 12.8    4   19.1    380
2017-04-01 0:02 893.08  730 12.8    4   19.3    380
2017-04-01 0:03 890.41  730 12.8    4   19.7    380
2017-04-01 0:04 889.28  730 12.8    4   19.93   380

and I typed code like

df.resample('1min', how='mean', fill_method='pad')

And it gives me this error: TypeError: Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'RangeIndex'

2 Answers
Related