Closed hanwsf closed 4 years ago
Hi @hanwsf
Can you please provide some more information on the files you are trying to concat? (num columns, dtypes, do they have missing values.., etc.) Did you create those hdf5 files with vaex or in some other way?
I can create nearly the same issue as yours if I mistakenly create an hdf5 file like this:
import vaex
df = vaex.from_arrays(x=[1, 2], y=['a', 'b'], z=[100, 200, 300])
hdf5 created by waex both can get head() correctly, but after concat, there is the issue.
The head of the hdf5:
-- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- | -- 0 | 1022 | 3 | 186.365 | 2016-04-17 17:00:00 | 10 | Education | 84346 | nan | 2 | 11.1 | 0 | -3.9 | 0 | 1023.4 | 50 | 8.8 1 | 1023 | 0 | 44.6978 | 2016-04-17 17:00:00 | 10 | Education | 87976 | nan | 2 | 11.1 | 0 | -3.9 | 0 | 1023.4 | 50 | 8.8 2 | 1024 | 0 | 3.73404 | 2016-04-17 17:00:00 | 10 | Education | 53855 | nan | 2 | 11.1 | 0 | -3.9 | 0 | 1023.4 | 50 | 8.8 3 | 1025 | 0 | 18.5386 | 2016-04-17 17:00:00 | 10 | Lodging/residential | 52034 | nan | 2 | 11.1 | 0 | -3.9 | 0 | 1023.4 | 50 | 8.8 4 | 1026 | 0 | 53.4908 | 2016-04-17 17:00:00 | 10 | Lodging/residential | 88480 | nan | 1 | 11.1 | 0 | -3.9 | 0 | 1023.4 | 50 | 8.8 5 | 1027 | 0 | 10.4783 | 2016-04-17 17:00:00 | 10 | Lodging/residential | 35465 | nan | 2 | 11.1 | 0 | -3.9 | 0 | 1023.4 | 50 | 8.8 6 | 1028 | 0 | 33.7065 | 2016-04-17 17:00:00 | 11 | Education | 81390 | nan | nan | 18.9 | nan | -1.5 | nan | 1029.1 | 260 | 2.6 7 | 1029 | 0 | 89.098 | 2016-04-17 17:00:00 | 11 | Education | 152559 | nan | nan | 18.9 | nan | -1.5 | nan | 1029.1 | 260 | 2.6 8 | 1029 | 3 | 31.9694 | 2016-04-17 17:00:00 | 11 | Education | 152559 | nan | nan | 18.9 | nan | -1.5 | nan | 1029.1 | 260 | 2.6 9 | 1030 | 0 | 24.0342 | 2016-04-17 17:00:00 | 11 | Education | 68030 | nan | nan | 18.9 | nan | -1.5 | nan | 1029.1 | 260 | 2.6
master_df = vaex.open_many(hdf5_list) master_df.export_hdf5('./data/train.hdf5', progress=True) This can concat all hdf5 in 1 big hdf5. Thanks.
Hi @hanwsf
Thanks for your data samples, it helped me to re-create the issue. You can track the progress here #531.
Also, not the issue only about the printing of the portion of a dataframe. If you simply do
df.head_and_tail
or if you use Jupyter just display df
it should work.
Yes indeed.. if you export a concatenated dataframe into a single hdf5 file, and work will that, you should have no problems. In fact that is the recommended workflow for now.
Thanks for making us aware on this issue tho.
Cheers, J.
Should be fixed by #531
df=vaex.open(DIR+'train_0.hdf5') df1=vaex.open(DIR+'train_1.hdf5') df3=vaex.concat([df,df1]) df3.head()
or: from glob import glob DIR ='./train/' files = glob(DIR+'train*.hdf5') df = vaex.open(DIR+'train*.hdf5')
These 2 cases can cause following issue from 2.1.0 to latest version (2.0.2 is trim issue):
ValueError Traceback (most recent call last) ~/.local/lib/python3.6/site-packages/IPython/core/formatters.py in call(self, obj, include, exclude) 968 969 if method is not None: --> 970 return method(include=include, exclude=exclude) 971 return None 972 else:
~/.local/lib/python3.6/site-packages/vaex/dataframe.py in _reprmimebundle(self, include, exclude, **kwargs) 3615 # TODO: optimize, since we use the same data in both versions 3616 # TODO: include latex version -> 3617 return {'text/html':self._head_and_tail_table(format='html'), 'text/plain': self._head_and_tail_table(format='plain')} 3618 3619 def _reprhtml(self):
~/.local/lib/python3.6/site-packages/vaex/dataframe.py in _head_and_tail_table(self, n, format) 3408 N = _len(self) 3409 if N <= n * 2: -> 3410 return self._as_table(0, N, format=format) 3411 else: 3412 return self._as_table(0, n, N - n, N, format=format)
~/.local/lib/python3.6/site-packages/vaex/dataframe.py in _as_table(self, i1, i2, j1, j2, format) 3540 # parts += [""] 3541 # return values_list -> 3542 parts = table_part(i1, i2, parts) 3543 if j1 is not None and j2 is not None: 3544 values_list[0][1].append('...')
~/.local/lib/python3.6/site-packages/vaex/dataframe.py in table_part(k1, k2, parts) 3518 # slicing will invoke .extract which will make the evaluation 3519 # much quicker -> 3520 df = self[k1:k2] 3521 for i, name in enumerate(column_names): 3522 try:
~/.local/lib/python3.6/site-packages/vaex/dataframe.py in getitem(self, item) 4552 assert stop != -1 4553 stop = stop+1 # +1 to make it inclusive -> 4554 df = self.trim() 4555 df.set_active_range(start, stop) 4556 return df.trim()
~/.local/lib/python3.6/site-packages/vaex/dataframe.py in trim(self, inplace) 3782 :rtype: DataFrame 3783 ''' -> 3784 df = self if inplace else self.copy() 3785 if self._index_start == 0 and self._index_end == self._length_original: 3786 return df
~/.local/lib/python3.6/site-packages/vaex/dataframe.py in copy(self, column_names, virtual) 4852 column = self.columns[name] 4853 if not isinstance(column, ColumnSparse): -> 4854 df.add_column(name, column, dtype=self._dtypes_override.get(name)) 4855 elif name in self.virtual_columns: 4856 if virtual: # TODO: check if the ast is cached
~/.local/lib/python3.6/site-packages/vaex/dataframe.py in add_column(self, name, data, dtype) 5819 # self._length_original = len(data) 5820 # self._index_end = self._length_unfiltered -> 5821 super(DataFrameArrays, self).add_column(name, data, dtype=dtype) 5822 self._length_unfiltered = int(round(self._length_original * self._active_fraction)) 5823 # self.set_active_fraction(self._active_fraction)
~/.local/lib/python3.6/site-packages/vaex/dataframe.py in add_column(self, name, f_or_array, dtype) 2929 if len(self) == len(ar): 2930 raise ValueError("Array is of length %s, while the length of the DataFrame is %s due to the filtering, the (unfiltered) length is %s." % (len(ar), len(self), self.length_unfiltered())) -> 2931 raise ValueError("array is of length %s, while the length of the DataFrame is %s" % (len(ar), self.length_original())) 2932 # assert self.length_unfiltered() == len(data), "columns should be of equal length, length should be %d, while it is %d" % ( self.length_unfiltered(), len(data)) 2933 valid_name = vaex.utils.find_valid_name(name)
ValueError: array is of length 11, while the length of the DataFrame is 10
Pls fix. Thanks!