Solution to python problem

topic description

AttributeError: module "pandas" has no attribute" DataFrame"

sources of topics and their own ideas

programming encounters

related codes

import requests
from lxml import etree

url = "https://book.douban.com/subject/1084336/comments/"
r = requests.get(url).text

s = etree.HTML(r)
file = s.xpath("//div[@class="comment"]/p/span/text()")

import pandas as pd
df = pd.DataFrame(file)
df.to_excel(pinglun.xlsx)

what result do you expect? What is the error message actually seen?

the solutions that have been searched on the Internet are useless. I beg all of you to solve your doubts!

Apr.29,2021
There is no DataFrame, under the

pandas module. Is there a package called pandas under your entry file? Python packet search order, first, from the system default module, second, from the entry file, third, from the sys.path inside.

Menu