-2

So below is my code. The output, as a nested list, is that it goes on almost infinitely (not literally, just metaphorically) from left to right. Here is a video showing the output as a DF. But here's my problem.... I've been told before that my PyCharm is bewitched, and that people get wildly different appearances in their version of PyCharm. I have the latest updated version, straight out the box. It looks rather messy. Thoughts? 
 
 Source code: 
 


from bs4 import BeautifulSoup
import requests
import pandas as pd
r = requests.post('https://opir.fiu.edu/instructor_evals/instr_eval_result.asp', data={'Term': '1175', 'Coll': 
'CBADM'})
soup = BeautifulSoup(r.text, 'lxml')


tables = [[x.text.strip() for x in y.find_all('td')] for y in soup.find_all('table')]

# This gives you a nested list. For instance,
# tables[0] # gives you the first table, in list form tables
# [1] # gives you the second table, in list form

df = pd.DataFrame(tables)
print(df)

    


J Sowwy
  • 244
  • 2
  • 11

1 Answers1

0

As far as PyCharm behavior goes, using your code and PyCharm 2017.2.3, I get the same results as in the video.

Not entirely sure what your question is but if you were looking for an alternative to the dataframe.

print(*tables, sep='\n')

['Term: 1175 - Summer 2017', 'Instructor Name: Elias...
['Term: 1175 - Summer 2017', 'Instructor Name: Ling,...
['Term: 1175 - Summer 2017', 'Instructor Name: Hossa...
...

or

[print(*table) for table in tables]

Term: 1175 - Summer 2017 Instructor Name: Elias,...
Term: 1175 - Summer 2017 Instructor Name: Ling,...
Term: 1175 - Summer 2017 Instructor Name: Hossai...
...
JerodG
  • 1,248
  • 1
  • 16
  • 34
  • As you can see here in The link below, another user here on stack was telling me that they were getting a completely different output for the exact same code I was writing and it was my PyCharm that was messing the code up… So I was wondering if it was me. Their output looks perfectly clean and extremely nice and neat, while the output on my video is ugly and wraps. https://stackoverflow.com/questions/46528003/how-to-clean-up-the-data-from-this-webscraping-script#comment80011703_46528003 – J Sowwy Oct 04 '17 at 20:28
  • So this image: https://imgur.com/a/RtcHI is yours and the video is what you'd like it to be? Are you on lin/win/mac? File-Encoding? – JerodG Oct 04 '17 at 21:19