cm3 / lafayettedb_thumbnail_getter

Based on csv data, get thumbnails for search engine construction (Will be hosted on Kyoto-Lafayette account.)
1 stars 0 forks source link

AttributeError: 'BlockManager' object has no attribute 'T' #3

Closed cm3 closed 7 years ago

cm3 commented 7 years ago

df.set_value(i, 'thumbnail', filename)

cause error in some rows:

Traceback (most recent call last):
  File "get_thumbnail.py", line 63, in main
    df.set_value(i, 'thumbnail', filename)
  File "/home/kameda/bin/miniconda3/lib/python3.5/site-packages/pandas/core/frame.py", line 1924, in set_value
    series = self._get_item_cache(col)
  File "/home/kameda/bin/miniconda3/lib/python3.5/site-packages/pandas/core/generic.py", line 1387, in _get_item_cache
    res = self._box_item_values(item, values)
  File "/home/kameda/bin/miniconda3/lib/python3.5/site-packages/pandas/core/frame.py", line 2396, in _box_item_values
    return self._constructor(values.T, columns=items, index=self.index)
AttributeError: 'BlockManager' object has no attribute 'T'
cm3 commented 7 years ago

use

df.loc[i, 'thumbnail'] = filename

instead

cm3 commented 7 years ago

Typical reason of this error is duplicate column names.

Csv output with unnamed index can have caused that. Now, csv is output without the index column.

df.to_csv(csv, encoding="utf-8", index=False)

Ref:

AlecMurphy commented 7 years ago

I think this also solved my 'Incompatible Indexer with Series' error. I'm not positive what it was but my issue was:

  1. Concat two data frames
  2. Take data from column of one frame and move it to column of the other
    • Did this using the df.iloc[n, 'Column Name'] = df.iloc[n, 'Other Column Name'] loop I wasn't able to get the above to work and for some reason one column would randomly be a series or a data frame type. Using set_value resulted in the BlockManager error.

I re imported the data making sure to specify encoding on each (used utf-8), made sure there where no duplicate column names in the data sets, and now everything behaves as normal! Guess that's what I get for assuming, implicit < explicit when it comes to pandas!!!! Specify your encoding, keep unique names, and remember identity vs equality !