I'm getting that error eventhough the name of my function is different from that of my variable inside the function. import pandas as pd  df = pd.read_csv('file.csv', usecols=('Date','Col2','Col3'))  def foo():     df['Date'] = pd.to_datetime(df.Date)     df = df.dropna()     return df print(foo())  Here's the error that I'm getting: df['Date'] = pd.to_datetime(df.Date) UnboundLocalError: local variable 'df' referenced before assignment  What should i do to resolve the issue?
The following code works as expected in both Python 2.5 and 3.0:  a, b, c = (1, 2, 3)  print(a, b, c)  def test():     print(a)     print(b)     print(c)    # (A)     #c+=1       # (B) test()   However, when I uncomment line (B), I get an UnboundLocalError: 'c' not assigned at line (A). The values of a and b are printed correctly. This has me completely baffled for two reasons:   Why is there a runtime error thrown at line (A) because of a later statement on line (B)? Why are variables a and b printed as expected, while c raises an error?   The only explanation I can come up with is that a local variable c is created by the assignment c+=1, which takes precedent over the "global" variable c even before the local variable is created. Of course, it doesn't make sense for a variable to "steal" scope before it exists.  Could someone please explain this behavior?
Wrong Java resource bundle loaded Perpendicular Chord parabola If $r_1,r_2$ be the length of the perpendicular chords drawn through the vertex of a parabola $y^2=4ax$, then show that $$(r_1r_2)^{4/3}=16a^2(r_1^{2/3}+r_2^{2/3})$$ Python interpreter error, x takes no arguments (1 given) (java) ObjectInputStream deserializing wrong version of object Need help identifying a comic book about a wizard I need help with identifying the comicbook, what follows is my best effort to gather whatever I remember from reading it years ago (circa year 2000, but I'm positive it was older than that):   The main character was a guy with white hair, who wanted to become powerful.  Through some training and a deal of some kind he was able to become a mage of sorts. The training was set on some other world, or possibly even parts were happening in different dimension. His powers might have had something with travelling between dimensions, but I'm not  100% sure. Also, I seem to recall there was a hard limit of how many times he could use them. Then followed a part where he was famous, but someone framed him into a scandalous plot (it was a sexual scandal, I think) using his clone or a doppelganger. At the end of the issue     the main character is seen trapped in some strange state, unable to move or escape using his powers (this might have to do something with the deal he made earlier). I remember the scene at the end as this: he is suspended in mid-air, his friends look at him in disbelief while some malevolent figure explains to them that he is now trapped forever.  His name was the title of the comic. The second and third parts were set on futuristic-looking planet.   Rings any bells? I'd like to read it again only I can't google it out. Differentiation operator and eigenvalues Let $V = \{p(x) \in F[x] \ | \ \deg(p(x)) \le n\}$. Let $T : V \to V$ be given by differentiation, in essence $$T(p(x)) = p'(x)$$ It seems to me that the only eigenvalue that can exist is $\lambda =0$, since the given operator lowers the degree of any given polynomial and hence makes it impossible for a constant multiple of a polynomial to be equal to the polynomial's derivative. Is my claim correct? TRON: Game A.I algorithm? Center of a group ring? Let $R$ be a ring with unity and let $G$ be a group. Then what is the center of the group ring $R(G)$? I feel that the center $Z(R(G))$ is $R(Z(G))$. I assumed if $x=\sum_{i=1}^{n} r_i g_i$, then it should commute with every element of $R(G)$. In particular it should commute with $g=1 \cdot g \in R(G)$ Thus we get $$\big(\sum_{i=1}^{n} r_i g_i\big)g=g\big(\sum_{i=1}^{n} r_i g_i\big)$$ Thus I get $$g_i \cdot g=g_i \cdot g \text{ }\text{ }\text{ }\text{ }\text{ }\text{ }\text{ }\text{ }\text{ }\text{ } \forall g \in G$$ Hence $x \in Z(R(G)) $. Is this correct? Full page image as title page Background  Wrote a technical manual in LyX. The technical manual currently has two parts:   Cover image (PDF) Manual text (PDF)   Problem  When merging the two PDF files (with GhostScript or other software tools), there are a number of issues:   Bookmarks (lost in merging) Colours (obvious changes) PDF tags (lost in merging)   I would rather include the cover page image as a full page (no margins) at the start of the manual and have LyX (LaTeX) generate the front page when it creates the PDF. In this fashion, the cover page and the manual text need not be merged as a separate step.  Question  How do you instruct LaTeX to generate a full page image as the first page in a PDF using KOMA-Script?  Update  Using the pdfpages package produces the following result:    Note the white space above and below the image. The white space is removed using the following:  \includepdf[fitpaper]{cover}   Update  Part of the preamble contains:  % Resize figures that are too wide for the page. \let\oldincludegraphics\includegraphics \renewcommand\includegraphics[2][]{%   \graphicsformat{%     \oldincludegraphics[width=\ScaleIfNeeded,#1]{#2}%   }% }   The full preamble is at:   The error message is:  !pdfTeX error: pdflatex (file cover.pdf): cannot find image file   The file ch_02.lyx and test.latex are in the same directory. The file test.latex is the document in Martin's post. The file test.latex can find the file cover.pdf, yet the file ch_02.lyx cannot find the file. Both use the following code:  \includepdf[fitpaper]{cover.pdf}   Update  The most minimal LyX example that produces the problem:  #LyX 1.6.7 created this file. For more info see http://www.lyx.org/ \lyxformat 345 \begin_document \begin_header \textclass scrbook \begin_preamble \usepackage{pdfpages} \end_preamble \use_default_options false \language english \inputencoding utf8 \font_roman lmodern \font_sans helvet \font_typewriter courier \font_default_family default \font_sc false \font_osf false \font_sf_scale 100 \font_tt_scale 100  \graphics default \float_placement H \paperfontsize default \spacing single \use_hyperref true \pdf_bookmarks true \pdf_bookmarksnumbered false \pdf_bookmarksopen false \pdf_bookmarksopenlevel 1 \pdf_breaklinks false \pdf_pdfborder false \pdf_colorlinks false \pdf_backref false \pdf_pdfusetitle true \papersize letterpaper \use_geometry false \use_amsmath 2 \use_esint 1 \cite_engine basic \use_bibtopic false \paperorientation portrait \secnumdepth 3 \tocdepth 3 \paragraph_separation indent \defskip medskip \quotes_language english \papercolumns 1 \papersides 1 \paperpagestyle default \bullet 0 5 11 -1 \bullet 1 5 24 -1 \bullet 2 0 0 -1 \tracking_changes false \output_changes false \author ""  \author ""  \end_header  \begin_body  \begin_layout Standard \begin_inset ERT status collapsed  \begin_layout Plain Layout   \backslash includepdf[fitpaper]{cover.pdf} \end_layout  \end_inset   \end_layout  \begin_layout Standard Test \end_layout  \end_body \end_document   Thank you! Am I being scammed by a sugar daddy? How can I typeset this accented, dotless i? See the rough sketch above. I am able to typeset the accented i shown in the middle (for which I used the \v macro) and, obviously, the plain and simple i shown on the left also. However, I can't figure out how to typeset the one shown on the right. How can I do that? Backgrounder:  The  (Pointer to IMPLementation) is a technique for implementation hiding in which a public class wraps a structure or class that cannot be seen outside the library the public class is part of.  This hides internal implementation details and data from the user of the library.  When implementing this idiom why would you place the public methods on the pimpl class and not the public class since the public classes method implementations would be compiled into the library and the user only has the header file?  To illustrate, this code puts the Purr() implementation on the impl class and wraps it as well.  Why not implement Purr directly on the public class?  // header file: class Cat {     private:         class CatImpl;  // Not defined here         CatImpl *cat_;  // Handle      public:         Cat();            // Constructor         ~Cat();           // Destructor         // Other operations...         Purr(); };   // CPP file: #include "cat.h"  class Cat::CatImpl {     Purr(); ...     // The actual implementation can be anything };  Cat::Cat() {     cat_ = new CatImpl; }  Cat::~Cat() {     delete cat_; }  Cat::Purr(){ cat_-&gt;Purr(); } CatImpl::Purr(){    printf("purrrrrr"); } Does the series $\sum_{n=1}^{\infty}|x|^\sqrt n$ converge pointwise? If it then what would be the sum? Proof that disjoint cycles commute CronJob not running Automatically run commands over SSH on many servers There is a list of IP addresses in a .txt file, ex.:  1.1.1.1 2.2.2.2 3.3.3.3   Behind every IP address there is a server, and on every server there is an sshd running on port 22. Not every server is in the known_hosts list (on my PC, Ubuntu 10.04 LTS/bash).  How can I run commands on these servers, and collect the output?  Ideally, I'd like to run the commands in parallel on all the servers.  I'll be using public key authentication on all the servers.  Here are some potential pitfalls:   The ssh prompts me to put the given servers ssh key to my known_hosts file. The given commands might return a nonzero exit code, indicating that the output is potentially invalid. I need to recognize that. A connection might fail to be established to a given server, for example because of a network error. There should be a timeout, in case the command runs for longer than expected or the server goes down while running the command.   The servers are AIX/ksh (but I think that doesn't really matter. Why $\sqrt[3]{{2 + \sqrt 5 }} + \sqrt[3]{{2 - \sqrt 5 }}$ is a rational number? Sam developed an annual sweepstakes promotion entitled “The Free Gas Punt Return Game”.    Do I need a comma after entitled or not? I have this problem where I can't built slide documents with beamer every time I include a math environment as simple as $\mu = A$. The log file posts this message at the end:  !pdfTeX error: miktex-pdftex.exe (file mathkerncmssi10): Font mathkerncmssi10 a t 657 not found  ==&gt; Fatal error occurred, no output PDF file produced!   I understand that the file (mathkerncmssi10) that is apparently missing is part of the package sansmathaccent, but the package is already there and updated.  This is driving me crazy, I would appreciate any help.    Sure, I tried this with several examples. I can post this one  \documentclass{beamer} \usepackage[latin1]{inputenc} \usetheme{Warsaw} \title[Make a LaTeX presentation using Beamer]{Introduction  to Beamer\\How to make a presentation with LaTeX?} \author{Nadir Soualem -- Astozzia} \institute{Math-linux.com} \date{Jule 13, 2007} \begin{document} \begin{frame} \titlepage \end{frame} \begin{frame}{Introduction} This is a short introduction to Beamer class. $\mu=A$ \end{frame} \end{document}    By the way, it turns out that I just tried this one in another PC and works fine. Which way is up? (electric outlet) My house has electric outlets in both orientations.  Which one is correct?  Should the ground hole be at the bottom or the top?    OR