The problem is your data object is a list of the DataFrames. You can either convert the DataFrames individually, e.g. df.to_csv(...) or merge them together and output as one file.

Try changing this part:

data = []

for df in path1:
    df = pd.read_excel(df)  
    data.append(df)

data.to_csv("H:\\test1.csv", index = False)

To this:

df = pd.concat(pd.read_excel(fl) for fl in path1)
df.to_csv("H:\\test1.csv", index = False)
Answer from r.ook on Stack Overflow
🌐
Python Forum
python-forum.io › thread-32955.html
'str' object has no attribute 'to_csv'
Hello guys, I'm trying to save some data that I collected from a website textform, on a csv file. And for that I'm using the following code, but I'm getting the error: 'str' object has no attribute 'to_csv' import zapimoveis_scraper as zap import ...
🌐
Reddit
reddit.com › r/codinghelp › matplotlib returning: attributeerror: 'property' object has no attribute '__name__'
r/CodingHelp on Reddit: Matplotlib returning: AttributeError: 'property' object has no attribute '__name__'
January 29, 2020 -

I've built a webscraper in python (Jupyter) to pull post content from a blog and I would like to use the csv file to create a wordcloud. This is the wordcloud code I am using:

%matplotlib notebook
from os import path
import matplotlib.pyplot as plt
import random

from wordcloud import WordCloud, STOPWORDS

# Open and read blog_stuff csv file
file = open("blog_stuff.csv",'r')
text = file.read()
file.close()

# Generate WordCloud 
# !!!make sure the path for the font is correct!!!
wordcloud = WordCloud(font_path='C:/Windows/Fonts/Calibri.ttf', relative_scaling = 0.25 ).generate(text)

# Save image
plt.savefig('wordcloud.png')

# Display Image
plt.show()

I keep running into an attribute error on all of the tutorials I follow. This is the error:


AttributeError Traceback (most recent call last) <ipython-input-34-20ba22870573> in <module> ----> 1 get_ipython().run_line_magic('matplotlib', 'notebook') 2 from os import path 3 import matplotlib.pyplot as plt 4 import random 5

~\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py in run_line_magic(self, magic_name, line, _stack_depth) 2305 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals 2306 with self.builtin_trap: -> 2307 result = fn(*args, **kwargs) 2308 return result 2309

<C:\Users\MyName\Anaconda3\lib\site-packages\decorator.py:decorator-gen-109> in matplotlib(self, line)

~\Anaconda3\lib\site-packages\IPython\core\magic.py in <lambda>(f, *a, **k) 185 # but it's overkill for just that one bit of state. 186 def magic_deco(arg): --> 187 call = lambda f, *a, **k: f(*a, **k) 188 189 if callable(arg):

~\Anaconda3\lib\site-packages\IPython\core\magics\pylab.py in matplotlib(self, line) 97 print("Available matplotlib backends: %s" % backends_list) 98 else: ---> 99 gui, backend = self.shell.enable_matplotlib(args.gui) 100 self._show_matplotlib_backend(args.gui, backend) 101

~\Anaconda3\lib\site-packages\IPython\core\interactiveshell.py in enable_matplotlib(self, gui) 3382 gui, backend = pt.find_gui_and_backend(self.pylab_gui_select) 3383 -> 3384 pt.activate_matplotlib(backend) 3385 pt.configure_inline_support(self, backend) 3386

~\Anaconda3\lib\site-packages\IPython\core\pylabtools.py in activate_matplotlib(backend) 311 matplotlib.rcParams['backend'] = backend 312 --> 313 import matplotlib.pyplot 314 matplotlib.pyplot.switch_backend(backend) 315

~\Anaconda3\lib\site-packages\matplotlib\pyplot.py in <module> 30 from cycler import cycler 31 import matplotlib ---> 32 import matplotlib.colorbar 33 import matplotlib.image 34 from matplotlib import rcsetup, style

~\Anaconda3\lib\site-packages\matplotlib\colorbar.py in <module> 25 26 import matplotlib as mpl ---> 27 import matplotlib.artist as martist 28 import matplotlib.cbook as cbook 29 import matplotlib.collections as collections

~\Anaconda3\lib\site-packages\matplotlib\artist.py in <module> 55 56 ---> 57 class Artist(object): 58 """ 59 Abstract base class for objects that render into a FigureCanvas.

~\Anaconda3\lib\site-packages\matplotlib\artist.py in Artist() 62 """ 63 @cbook.deprecated("3.1") ---> 64 @property 65 def aname(self): 66 return 'Artist'

~\Anaconda3\lib\site-packages\matplotlib\cbook\deprecation.py in deprecate(obj, message, name, alternative, pending, addendum) 180 pass 181 """ --> 182 183 def deprecate(obj, message=message, name=name, alternative=alternative, 184 pending=pending, obj_type=obj_type, addendum=addendum):

AttributeError: 'property' object has no attribute 'name'

Would any of you fine folks know how I can remedy this issue?

Edit: Removed my name from path

Discussions

python - Matplotlib returning: AttributeError: 'property' object has no attribute '__name__' - Stack Overflow
I've built a webscraper in python (Jupyter) to pull post content from a blog and I would like to use the csv file to create a wordcloud. This is the wordcloud code I am using: %matplotlib notebook... More on stackoverflow.com
🌐 stackoverflow.com
python - AttributeError: 'property' object has no attribute - Stack Overflow
Python (2.6) seems to be derping for no reason, can anyone see a problem with this code? class DB (): def doSomething (self, str): print str class A (): __db = DB() @staticme... More on stackoverflow.com
🌐 stackoverflow.com
django - Python "property object has no attribute" Exception - Stack Overflow
TypeError: 'property' object has only read-only attributes (assign to .short_description) ... The result of property() is an object where you can't add new fields or methods. It's immutable which is why you get the error. One way to achieve what you want is with using four arguments to property(): confirmation = property(_get_confirmation, _set_confirmation, None... More on stackoverflow.com
🌐 stackoverflow.com
June 5, 2020
python - AttributeError: 'str' object has no attribute 'csv' - Stack Overflow
I am trying to write a CSV file and I have code to create a document with a header file this code will take inputs to write to that same file. class CSVFile: def __init__(self, doctitle): ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
Stack Overflow
stackoverflow.com › questions › 59961401 › matplotlib-returning-attributeerror-property-object-has-no-attribute-name
python - Matplotlib returning: AttributeError: 'property' object has no attribute '__name__' - Stack Overflow
%matplotlib notebook from os import path import matplotlib.pyplot as plt import random from wordcloud import WordCloud, STOPWORDS # Open and read blog_stuff csv file file = open("blog_stuff.csv",'r') text = file.read() file.close() # Generate WordCloud # !!!make sure the path for the font is correct!!! wordcloud = WordCloud(font_path='C:/Windows/Fonts/Calibri.ttf', relative_scaling = 0.25 ).generate(text) # Save image plt.savefig('wordcloud.png') # Display Image plt.show() I keep running into an attribute error on all of the tutorials I follow.
Top answer
1 of 3
22

In addition to needing to inherit from object, properties only work on instances.

a = A()
a.db.doSomething("blah")

To make a property work on the class, you can define a metaclass. (A class is an instance of a metaclass, so properties defined on the metaclass work on the class, just as properties defined on a class work on an instance of that class.)

2 of 3
1

You aren't using classes correctly. A class is (normally) two things:

  1. A factory for creating a family of related objects
  2. A definition of the common behaviour of those objects

These related objects are the instances of the class. Normal methods are invoked on instances of the class, not on the class itself. If you want methods that can be invoked from the class, without an instance, you need to label the methods with @classmethod (or @staticmethod).

However I don't actually know whether properties work when retrieved from a class object. I can't check right now, but I don't think so. The error you are getting is that A.db is retrieving the property object which defines the property itself, it isn't "evaluating" the property to get A.__db. Property objects have no doSomething attribute. Properties are designed to be created in classes as descriptions of how the instances of those classes work.

If you did intend to be working with an instance of A, then you'll need to create one:

my_a = A()
my_a.db.doSomething("blah")

However, this will also fail. You have not correctly written getDB as any kind of method. Normal methods need an argument to represent the instance it was invoked on (traditionally called self):

def getDB(self):
    ...

Static methods don't, but need a decorator to label them as static:

@staticmethod
def getDB():
    ...

Class methods need both an argument to receive the class they were invoked on, and a decorator:

@classmethod
def getDB(cls):
    ...
🌐
Stack Overflow
stackoverflow.com › questions › 55274409 › attributeerror-str-object-has-no-attribute-csv
python - AttributeError: 'str' object has no attribute 'csv' - Stack Overflow
This is because you are not instantiating an object. Your call is CSVFile.appendrow("", "test", 2, 3, 4, 5). Essentially, it means that for the self parameter of appendrow you are passing an empty string argument "". Try something along lines ...
🌐
Reddit
reddit.com › r/learnpython › attributeerror: 'index' object has no attribute 'to_csv'
r/learnpython on Reddit: AttributeError: 'Index' object has no attribute 'to_csv'
July 9, 2023 -

How do I fix this error, please?

Code:

import pandas as pd

import numpy as np

import itertools

import csv

data = pd.ExcelFile(r"C:\Users\Josh-\OneDrive\Documents\Prem Tipster\YouTube Files\FPL Documents\FPL Tools.xlsx")

df = pd.read_excel(data, 'Defence')

#Drop columns and rows

df = df.drop(df.columns[[0, 1]], axis=1)

df = df.iloc[21:]

df = df.dropna(how= "all", axis=1)

#New headers for columns and rows

df.columns = df.iloc[0]

df = df.iloc[1:]

df.index = ['Row_1']

index = list(df.columns[[0]])

df = df.set_index(index)

#Remove spaces from column names

df.columns = df.columns.str.replace(' ', '')

DEF_IN_SQUAD = 2

DEF_IN_XI = 1

STARTING_GW = 1

ENDING_GW = 19

def validCombinations(GAMEWEEK):

TOTAL_COMB = list(itertools.combinations(df[GAMEWEEK], DEF_IN_SQUAD))

VALID_COMB = [(sum(sorted(x)[:DEF_IN_XI])) for x in TOTAL_COMB]

return(VALID_COMB)

TEAM_COMB = df.columns

for i in range(STARTING_GW, ENDING_GW, 1):

GW = "GW{}".format(i)

a = validCombinations(GW)

# print(len(a))

TEAM_COMB = TEAM_COMB.insert(i, a)

TEAM_COMB.to_csv(r"C:\Users\Josh-\OneDrive\Documents\Prem Tipster\Python\FPL Data Analysis\Defence Rotations Data.csv", sep='\t', index=False)

Find elsewhere
🌐
Stack Overflow
stackoverflow.com › questions › 47687049 › attributeerror-object-has-no-attribute-reader-online-when-csv-used-inside-of
python - AttributeError: object has no attribute 'reader' online when CSV used inside of a METHOD - Stack Overflow
python xmen.py D:\ProgramData\Anaconda2\lib\csv.pyc [['user_name'], ['mensfashionpost'], ['creativefasion']] Traceback (most recent call last): File "xmen.py", line 25, in <module> csv.read() File "xmen.py", line 18, in read self.xyz = csv.reader(open('D:\\dev\\scrapy\\instagram_influencers\\instagram_influencers\\input\\user_names.csv','r')) AttributeError: 'GetInstgramUsernames' object has no attribute 'reader' D:\dev\scrapy\instagram_influencers>
🌐
Reddit
reddit.com › r/learnpython › pandas dataframe to csv attribute error
r/learnpython on Reddit: Pandas dataframe to csv Attribute error
August 12, 2017 -

I am trying to use pandas to create a CSV of the historical data from coinmarketcap. Just this simple code fails and I can't seem to find the answer on the web at all. Any help is greatly appreciated.

import pandas as pd
df = pd.read_html('https://coinmarketcap.com/currencies/bitcoin/historical-data/?start=20130428&end=20170812')
df.to_csv('test.csv')

File "test.py", line 3, in <module>

df.to_csv('test.csv')

AttributeError: 'list' object has no attribute 'to_csv'

🌐
DaniWeb
daniweb.com › programming › software-development › threads › 425633 › python-csv-module-object-has-no-attribute-writer
Python/csv: 'module' object has no attribute ... [SOLVED] | DaniWeb
June 14, 2012 - The AttributeError indicates you are not importing the standard library csv module (which does have writer). Your printout shows a third-party egg at ~/.python-eggs/.../csv.so shadowing the stdlib.
🌐
Brainly
brainly.com › computers and technology › high school › does a list object have an attribute 'to_csv'?
[FREE] Does a list object have an attribute 'to_csv'? - brainly.com
In Python, a list is a built-in ... 'list' object has no attribute 'to_csv' indicates that you attempted to call the 'to_csv()' method on a list object, which is not valid....
🌐
GeeksforGeeks
geeksforgeeks.org › pandas › how-to-fix-module-pandas-has-no-attribute-read_csv
How To Fix Module Pandas Has No Attribute read_csv - GeeksforGeeks
July 23, 2025 - The error "Module 'Pandas' Has No Attribute 'read_csv'" can sometimes be caused by a namespace conflict, where the name 'pandas' is being used for something other than the Pandas library.
🌐
Codecademy
codecademy.com › forum_questions › 555893fb51b887b127000338
AttributeError: '_csv.reader' object has no attribute 'write' | Codecademy
import csv import re import random · csvFile = open(“standard licenseplates.txt”,”w”) speedLimit = 50 distance = 250