AttributeError: 'TextFileReader' object has no attribute 'get_chunck' [closed] - python

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 3 years ago.
Improve this question
I am trying to read a huge file lazily in with the pandas get_csv function. I want to access the first 5000 elements of a specified column. But I am getting the error I mentioned in my title.
#fetching data
train = pd.read_csv(os.path.join(dir,"Train.csv"),iterator = True)
test = pd.read_csv(os.path.join(dir,"Test.csv"),iterator = True)
Getting the parts of the data I need:
labels = np.array(train.get_chunk(5000))[:,3]
train = np.array(train.get_chunck(5000))[:,2]
test = np.array(test.get_chunk(5000))[:,2]
Error:
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-43-b164e8752510> in <module>()
1 labels = np.array(train.get_chunk(5000))[:,3]
----> 2 train = np.array(train.get_chunck(5000))[:,2]
3 test = np.array(test.get_chunk(5000))[:,2]
AttributeError: 'TextFileReader' object has no attribute 'get_chunck'
Apparently I am not allowed to do it like this? If not, how could I rewrite this to achieve what I am trying to achieve with this code?

get_chunck is a spelling error!

Try get_chunk instead of get_chunck.

get_chunck is the culprit ! get_chunk

Related

How to fix 'tuple' object has no attribute 'open'? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 months ago.
Improve this question
Im parsing data for study purposes so I create scraping module, data frame module and now I need to finish "upload to Google Drive data frame as Google Sheet" but stuck on this error.
from fileinput import filename
import gspread
credentials = {...
}
gc = gspread.oauth_from_dict(credentials)
tag = bs_search
sh = gc.open(filename, 'kid')
worksheet = sh.add_worksheet(title = tag, rows=100, cols=20)
worksheet.update([df.columns.values.tolist()] + df.values.tolist())
worksheet.update_cell(1, 4, 'Send to')
worksheet.update_cell(1, 5, 'Not Send to')
worksheet.update_cell(1, 6, 'Instagram')
Output:
13 gc = gspread.oauth_from_dict(credentials)
15 tag = bs_search
---> 16 sh = gc.open(filename, 'kid')
17 worksheet = sh.add_worksheet(title = tag, rows=100, cols=20)
18 worksheet.update([df.columns.values.tolist()] + df.values.tolist())
AttributeError: 'tuple' object has no attribute 'open'
If you look at the docs for the gspread project, they have an example for this function:
gc, authorized_user = gspread.oauth_from_dict(credentials)
Notice there are two values before the equals.
More information: https://docs.gspread.org/en/latest/oauth2.html

AttributeError: 'DataFrame' object has no attribute 'to_CSV' [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I'm trying to store my extracted chrome data into a csv format using df.to_CSV
here is my code :
content = driver.page_source
soup = BeautifulSoup(content)
for a in soup.findAll('a',href=True, attrs={'class':'_13oc-S'}):
name=a.find('div', attrs={'class':'_4rR01T'})
price=a.find('div', attrs={'class':'_30jeq3 _1_WHN1'})
rating=a.find('div', attrs={'class':'hGSR34 _2beYZw'})
products.append(name.text)
prices.append(price.text)
ratings.append(rating.text)
df = pd.DataFrame({'Product Name':products, 'Price':prices, 'Rating':ratings})
df.to_CSV(r'C:\Users\Krea\Documents\products.csv', index=False)
It's case-sensitive, should be df.to_csv(...)
Python is case sensitive. Change the last row to:
df.to_csv(r'C:\Users\Krea\Documents\products.csv', index=False)

python Flask, TypeError: 'NoneType' object is not subscriptable [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
I'm studying Flask very recently and trying to create API.
However, when It request json data, this error occurs.
if content['words'] is not None:
TypeError: 'NoneType' object is not subscriptable
could anyone can help this?
Thanks
my code is below:
#app.route("/process",methods=['GET', 'POST'])
def process():
content = request.json
words = {}
if content['words'] is not None:
for data in content['words'].values():
words[data['word']] = data['weight']
process_from_text(content['text'], content['maxCount'], content['minLength'], words)
result = {'result':True}
return jsonify(result
The problem is most likely that request is not a valid json request. If that is the case then content will be equal to None which means it is not subscriptable.

Sending differing emails to addresses [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
I am trying to automate an emailing process at work and got everything working down to the final line.
Here is the issue confined to its own test script to ensure the error is not something else:
import win32com.client as win32
outlook = win32.Dispatch("Outlook.application")
addresses = ["email1", "email2"]
for address in addresses:
email = outlook.CreateItem(0)
email.To = address
email.Subject = "Attendance"
email.Body = " - "
email.send()
The email will send to the first email address if valid, but not the second.
Here is the error:
Traceback (most recent call last):
File "C:\Users\jbruce\OneDrive - Stirling Skills Training\Reporting\EST\Auto attendance\Test.py", line 12, in <module>
email.send()
TypeError: 'bool' object is not callable
I am mainly puzzled about why the script will run one step of the for loop, but not the other.
Thanks for your help in advance.
You're looking for:
email.Send()
The issue here is that:
email.send
is, in fact, a Bool.

Detail AttributeError: 'module' object has no attribute 'workbook' [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I keep getting the Detail AttributeError: 'module' object has no attribute 'workbook' error.
below is my code
import xlwt
workbook = xlwt.workbook()
sheet = workbook.add_sheet('Eswar')
sheet.write (4,4,'Test passed')
workbook.save("D:\resultsLatest.xls")
what have i done wrong?
I am using python 2.7
In source code on github you can see right spelling Workbook. Your code should be:
import xlwt
workbook = xlwt.Workbook()
sheet = workbook.add_sheet('Eswar')
sheet.write(4,4,'Test passed')
workbook.save("D:\\resultsLatest.xls")

Categories