Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
pubic void nullo
May 17, 2002


huhu posted:

Would this be the best way to log errors on a script that I'm running?

code:
try:
    # Threading here for 3 different functions
except Exception as e:     
    logf = open("log.txt", "a")
    logf.write("Error: {} \n".format(str(e)))
    logf.close()
finally:
    pass

I know this is already answered, but here's an entire blog post on the topic of logging exceptions, with some helpful examples for Python 2 and 3. It includes how to log the stack trace. https://realpython.com/blog/python/the-most-diabolical-python-antipattern/

Adbot
ADBOT LOVES YOU

pubic void nullo
May 17, 2002


Slimchandi posted:

You asked for it...

Is there any way to create a pandas column multiindex where some of the columns headings 'span' down? In effect, some columns might have 2 levels of column but others have 3.

For example

Region: North, South
Widget Type: type 1, type 2
Rate: Day, Night (only applies to type 2 widgets)

So I could index a type 1 widget by ['North','type 1'] but type 2 would require ['North','type 2','Day'].

Believe it or not, I actually have the same question right now.

I'm trying to do basic data analysis on a series of electricity bills. Most of the spreadsheet is indexed by the same row, but there are a couple sections that have a grouping header above that row, like this:

I have to use pd.read_excel to bring the sheets in, and I'm trying not to use a panel because apparently that's being deprecated as of pandas 0.20.

pubic void nullo
May 17, 2002


Boris Galerkin posted:

Is there a conda equivalent to "pip download -r requirements.txt"?

I have an environment set up and I'd like to export it along with all the required downloaded things to install on non networked computers.

I found this link

https://stackoverflow.com/questions/32956583/how-do-i-download-anaconda-packages-without-installing-them

Which links to the official FAQ but that question/answer has been removed.

Can you use the instructions for building identical conda environments and target the 'root' environment on the target machines? Root is supposed to be the name of the default environment and I know you said no virtual envs.

Then you can copy the cache directory that conda already keeps from the first machine and they should install from cache, unless there is some URL that it has to hit before it will install local packages.

pubic void nullo fucked around with this message at 13:47 on Sep 15, 2017

pubic void nullo
May 17, 2002


huhu posted:

I'm looking to start a pretty large Python project with the hopes of actually releasing it. The last time I tried this I failed pretty badly and have learned a bit but would love any suggestions before jumping in again. My thoughts thus far are to try and diagram the entire project, use a virtualenv, and document everything as best I can as I go. Any other suggestions?

This whole podcast episode is worth a listen, but something that you might be interested in is discussed from around 48:00 on. Basically, Glyph is talking about his Pycon talk and saying that people should start the deployment/continuous integration process earlier in the development timeline instead of starting it late and finding that their app needs major work in order to be deployable, esp. across multiple platforms.

pubic void nullo
May 17, 2002


Rocko Bonaparte posted:

If I'm not working with scientific applications or teaching, is there another reason I might want to use Jupyter for stuff?

I use it for taking notes on courses for the LaTeX embedding. It's perfect for things like Project Euler and the Python Challenge. I also use it for doing one-off analyses that are bigger than what you would comfortably do right in the REPL, whether that be experimenting with map APIs or crunching some imported Excel.

Adbot
ADBOT LOVES YOU

pubic void nullo
May 17, 2002


cinci zoo sniper posted:

Yeah the scientific view array-like object viewer is pretty great.

This works for Pandas just as well in the free version with no scientific mode, too.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply