Hi I'm trying to build a simple webscraper of ESG data for S&amp;P500 companies but for some reason I keep getting NameError:  name 'web_scraper' is not defined Tried a few things now but cannot get it to work. I'm a beginner so must be overlooking something. Thanks in advance from bs4 import BeautifulSoup import pandas as pd import requests import ipywidgets as widgets from ipywidgets import interact  def get_tickers():  # wiki_page = requests.get()   sp_data = pd.read_html('https://en.wikipedia.org/wiki/List_of_S%26P_500_companies')   ticker_df = sp_data[0]   ticker_options = ticker_df['Symbol']   return ticker_options    def level(x):     if x == 0.0:         return 'No Controversy'     elif x == 1.0:         return 'Little Controversy'     elif x == 2.0:          return 'Moderate Controversy'     elif x == 3.0:          return 'Relatively High Controversy'     else:         return 'Little Controversy'      def web_scraper(ticker):         elements = []         web_data = requests.get('https://finance.yahoo.com/quote/'+ticker+'+/sustainability?p='+ticker).text         soup = BeautifulSoup(web_data, 'html.parser')         esg_score = soup.find('div', {'class':'Fz(36px) Fw(600) D(ib) Mend(5px)'})         datapoint = esg_score.text         controversy_score = soup.find('div', {'class':'D(ib) Fz(36px) Fq(500)'})         controversy_datapoint = controversy_score.text         scores = soup.find_all('div', {'class': 'D(ib) Fz(23px) smartphone_Fz(22px) Fq(600)'})         for score in scores:             elements.append(score.text)      df = pd.DataFrame({'Total ESG Score': datapoint,                    'Environment Score': elements[0],                    'Social Score': elements[0],                   'Governance Score': elements[2],                  'Controversy Score': controversy_datapoint},                   index = [ticker])     df = df.astype('float')     df['Controversy Assessment'] = df.apply(lambda x: level(x['Controversy Score']), axis=1)     return df  @interact def get_esg(ticker=widgets.Dropdown(description='Ticker',                                       options=get_tickers(),                                     value = 'F')):   esg_data = web_scraper(ticker)   return esg_data
What exactly are the Python scoping rules?  If I have some code:  code1 class Foo:    code2    def spam.....       code3       for code4..:        code5        x()   Where is x found?  Some possible choices include the list below:   In the enclosing source file In the class namespace In the function definition In the for loop index variable Inside the for loop   Also there is the context during execution, when the function spam is passed somewhere else. And maybe  pass a bit differently?  There must be a simple reference or algorithm somewhere.  It's a confusing world for intermediate Python programmers.
I understand that the expressions on both sides of an equal sign are the same entity, and I know that when you modify one side, the other must be changed because it is referring to the same thing. What I do not understand is why making a new equation (adding or taking away from an expression) allows one to know what an unknown represents. What about equations lets us do this? What's the deepest reason why QCD bound states have integer charge? Word for the opposite of "hypochondriasis" How can I view and examine the Android log? I can't get grub menu to show up during boot After trying (and failing) to install better ATI drivers in 11.10, I've somehow lost my grub menu at boot time.  The screen does change to the familiar purple colour, but instead of a list of boot options it's just blank solid colour, and then disappears quickly and boots into the default entry normally.    How can I get the bootloader back?  I've tried sudo update-grub and also various different combinations of resolutions and colour depths in startupmanager application with no success (640x480, 1024x768, 1600x1200, 16 bits, 8 bits, 10 second delay, 7 second delay, 2 second delay...)   edit:   I have already tried holding down Shift during bootup and it does not seem to change the behaviour.  I get the message "GRUB Loading" in the terminal, but then the place where the grub menu normally appears I get a solid blank magenta screen for a while.  Here are the contents of /etc/default/grub  # If you change this file, run 'update-grub' afterwards to update # /boot/grub/grub.cfg. # For full documentation of the options in this file, see: #   info -f grub -n 'Simple configuration'  GRUB_DEFAULT=0 GRUB_HIDDEN_TIMEOUT=0 GRUB_HIDDEN_TIMEOUT_QUIET=true GRUB_TIMEOUT=10 GRUB_DISTRIBUTOR=`lsb_release -i -s 2&gt; /dev/null || echo Debian` GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" GRUB_CMDLINE_LINUX=" vga=798 splash"  # Uncomment to enable BadRAM filtering, modify to suit your needs # This works with Linux (no patch required) and with any kernel that obtains # the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...) #GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"  # Uncomment to disable graphical terminal (grub-pc only) #GRUB_TERMINAL=console  # The resolution used on graphical terminal # note that you can use only modes which your graphic card supports via VBE # you can see them in real GRUB with the command `vbeinfo' #GRUB_GFXMODE=640x480  # Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux #GRUB_DISABLE_LINUX_UUID=true  # Uncomment to disable generation of recovery mode menu entries #GRUB_DISABLE_RECOVERY="true"  # Uncomment to get a beep at grub start #GRUB_INIT_TUNE="480 440 1" How do I get the coordinates of a mouse click on a canvas element? Why not group search results by thread? I like the new search, but the listing can become quite verbose. That is generally excellent because Stack Exchange is searching in more places. But now that you  to the original question, it becomes quite difficult to remember "that's not the question(s) I want &hellip; that's not the question(s) I want" when the questions' answers appear dozens of times scattered throughout the listings.  Why not group same-question entries together in the search results?  I realize that each individual post wont be sorted strictly "by relevance", but the most relevant question threads will be listed first&hellip; making it easier to skip over those entries once you decide that's not the question you're looking for.  Consider what we have now &mdash;  Apple SE > Search "Exchange contacts"   A: Exchange contacts do not appear in iCloud A: Exchange contacts do not appear in iCloud Q: iPhone Contact Sync A: How to use Gmail contacts on an iPod Touch A: Exchange contacts do not appear in iCloud A: Exchange contacts do not appear in iCloud A: How to use Gmail contacts on an iPod Touch A: Exchange contacts do not appear in iCloud A: Exchange contacts do not appear in iCloud A: iPhone Contacts Sync Q: Best way to transfer iphone contacts away from Exchange server Q: Can I use Google's new CardDAV-based contacts sync to sync between my Exchange contacts and … A: How to delete contacts from iPhone? A: Can I use Google's new CardDAV-based contacts sync to sync between my Exchange contacts and … : etc, etc. :   Once I realize I don't want that iCloud question&hellip; or that iPod Touch question&hellip; or that sync question &mdash; or a dozen others &mdash; it becomes extremely cumbersome to remember and search the listings for questions I didn't eliminate yet.  I'm not suggesting rolling up the results back to the original question&hellip; just grouping these posts together (I like seeing each answer-match with the text excerpt underneath). But once I eliminate the question entirely, it would be nice to scroll past those entries to continue my search&hellip; without all the noise of those entries reappearing over and over again in the search results. given value of matrix, getting it's coordinate How should I parse user input in a text adventure game? Parsing user commands in a text adventure is a spectrum from 's simple "go north" to some mind-bogglingly clever ones in .  I seem to remember reading nice how-tos in computer magazines back in the 80s, but now I find almost nothing on the 'net except a .  How would you do it?    Update: I went with the simplest approach possible in . Is there a way to find out if I need a transit visa for Canada? If $a, b$ are positive real numbers and $a+b = 1$, prove that :  $$\left(a+\frac{1}{a}\right)^2 + \left(b+\frac{1}{b}\right)^2 \geq \frac{25}{2}$$  I can see that the value $\frac{25}2$ is attained for $a=b=\frac12$. But I do not know how to show that this is the minimal possible value.  Thank you. Inadvertent use of = instead of == It seems that   if (x=y) { .... }   instead of  if (x==y) { ... }    is a root of many evils.  Why don't all compilers mark it as error instead of a configurable warning?  I'm interested in finding out cases where the construct if (x=y) is useful. Prove that $\phi(n) \geq \sqrt{n}/2$ I thought of this question right after I posted a tweet about a service upgrading me to a free student account since I am in college. I said "That really helps a broke college student out." I actually paused for a second while I was writing that to decide if I should say     That really helps out a broke college student.   or     That really helps a broke college student out.   Are there any prescriptive rules about splitting phrasal verbs like this? I know this breaks the "don't put a preposition at the end of a sentence" rule, but that "rule" has an exception for phrasal verbs.  To clarify:   Is there any rule that says phrasal verbs can't be split, even if it is just an imposed, prescriptive rule? Does splitting a phrasal verb to put a preposition at the end of a sentence fall under the phrasal verb exception to the prepositions at the end of a sentence rule? How many bandits must agree? Problem  A group of $n~(1 \leq n \leq 30)$ bandits hid their stolen treasure in a room.  The treasure needs to be locked away.  The bandits want to ensure that at least $k~(1 \leq k \leq n)$ of the bandits must agree in order to retrieve the treasure.  They have decided to place multiple locks on the door such that the door can be opened if and only if all the locks are opened.  Each lock may have up to n keys, distributed to a subset of the bandits.  A group of bandits can open a particular lock if and only if someone in the group has a key to that lock.  Given $n$ and $k$, how many locks are needed such that if the keys to the locks are distributed to the bandits properly, then every group of bandits of at least size $n$ can open all the locks, and no smaller group of bandits can open all the locks?  For example, if $n=3$ and $k=2$, only 3 locks are needed - keys to lock 1 can be given to bandits 1 and 2, keys to lock 2 can be given to bandits 1 and 3, and keys to lock 3 can be given to bandits 2 and 3.  No single bandit can open all the locks, but any group of 2 bandits can open all the locks.  My thoughts  At first glance, I thought it was just a simple combinations problem ($nCr$), and the provided test cases confirmed my suspicions: when $n=3$ and $k=2$, $\binom{3}{2}=3$.  Likewise, when $n=5$ and $k=3$, $\binom{5}{3}=10$.  However, two cases where this doesn't work are where $n=2$ and $k=1$ and $n=5$, $k=4$ (it gives $2$ and $5$, respectively, when the correct answer according to the judging data should be $1$ and $10$).  Next, I bothered a colleague who's a math major, and he briefly glanced at it and suggested it might be a hypergeometric distribution problem.  However, if this is correct, I'm having trouble wrapping my head around it - all the examples I can find have 2 distinct categories, e.g. red and green marbles being drawn from an urn, and I don't see that here.  An example in the terms of this problem would be extremely helpful.  If this isn't correct, where do I go from here?  I've been spinning my wheels on it for quite a while.  Background  This is for homework for a CS class (I'm a CS major with 2 semesters of calc plus discrete).  I'd like to be able to understand the math behind it, because once I can understand it, I can program it.  This problem originally came from an ACM ICPC regional contest this year, but my professor has made it into a challenge homework problem. Code in beamer presentation Good day! So, I need to present my disertation code to my thesis advisors, but I'm quite unsure how to actually do it in a proper way. I found  showing some ideas.  Is there a way of making the slides 48-67 in beamer without using tikz? Any ideas to implement the whole ideas the author propose?  Thanks in advance. Is it possible to add a user and restrict him to run special programs? For example after this user logs in, he can only open Firefox to use Internet and no other programs can be run by this user. For example in a terminal, commands will not be accessible when you delete some environment variables like $HOME. But is it possible to avoid running programs in a graphical shell, like Gnome? If yes, how? Let $g_n= {2^2}^n +1 $. Prove $g_0 · g_1 · · · g_{n−1} = g_{n} − 2$.    I'm not sure how to start this proof, if it should be done algebraically or if I should try to use a proof by induction. Initiate an oAuth flow via an Auth Provider How to randomly subset X% of selected points? What methods are available in ArcGIS 10.2 to randomly subset a selection of points.  For example, in the attached screenshot I am interested in keeping 20% of the selected points and deleting the rest.