question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AttributeError: 'numpy.ndarray' object has no attribute 'style'

See original GitHub issue

Thanks for your work

  • Python 3.7.3
  • StyleFrame 2.0.5
  • pandas 0.25.3
  • openpyxl 3.0.2

I want to read an xlsx file as described in this SO answer, but I get the following error

Code

sf = StyleFrame.read_excel(file_path, 
                           sheet_name=1,
                           index_col=0, 
                           read_style=True
                          )

Error

lib/python3.7/site-packages/StyleFrame/style_frame.py in _read_style()
    208                         style_object = Styler.from_openpyxl_style(current_cell, theme_colors,
    209                                                                   read_comments and current_cell.comment)
--> 210                     sf.at[sf_index, col_name].style = style_object
    211                     sf._rows_height[row_index] = sheet.row_dimensions[row_index].height
    212 

AttributeError: 'numpy.ndarray' object has no attribute 'style'

Do you I make a mistake somewhere or is there a bug ?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
MattMacscommented, Apr 16, 2020

Hi, got it resolved, used df.set_index before.

After removing it, everything works smoothly.

0reactions
DeepSpace2commented, Apr 16, 2020

@MattMacs Please provide a full code that reproduces this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AttributeError: 'numpy.ndarray' object has no attribute 'xaxis'
When trying to create a plot with multiple figures, I get this error AttributeError: 'numpy.ndarray' object has no attribute 'xaxis'.
Read more >
AttributeError: 'numpy.ndarray' object has no attribute ' ...
The problem is that train_test_split(X, y, ...) returns numpy arrays and not pandas dataframes. Numpy arrays have no attribute named columns.
Read more >
How to Fix: 'numpy.ndarray' object has no attribute 'index'
One error you may encounter when using NumPy is: AttributeError: 'numpy.ndarray' object has no attribute 'index'.
Read more >
'numpy.ndarray' object has no attribute 'append' Solution
ndarray' object has no attribute 'append' error indicates you are using the regular Python append() method to add an item to a NumPy...
Read more >
numpy.ravel — NumPy v1.24 Manual
As of NumPy 1.10, the returned array will have the same type as the input array. ... 'C' means to index the elements...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found