|
Also note that Pandas has some basic plotting capacities (MPL-based ofc).
|
# ? May 21, 2015 21:03 |
|
|
# ? Jun 3, 2024 16:18 |
|
OnceIWasAnOstrich posted:I notice your requirements didn't include being Pythonic... There is always the option of plotting by programming R in Python with ggplot. The interface is rather R-like, but ggplot in R makes a lot more sense than Matlab's plotting so it is a step up, and it is integrated fairly well with Pandas and statsmodels, Call that an implied requirement. My main beef with matplotlib (while admitting it's a powerful package lots of people love) is that it just doesn't stick to my brain and feels like I'm swapping to another language when I do plotting. And should you look at the source to see how things work, you're confronted with a whole lot of functions using kwargs. Doing an R call may be the way to go.
|
# ? May 22, 2015 14:16 |
|
To be clear, the library I linked is actually a Python library that just happens to have an interface very very similar to ggplot has in R.
|
# ? May 22, 2015 14:55 |
|
OnceIWasAnOstrich posted:To be clear, the library I linked is actually a Python library that just happens to have an interface very very similar to ggplot has in R. And it looks pretty good from what I've seen of it.
|
# ? May 22, 2015 16:16 |
|
outlier posted:Call that an implied requirement. My main beef with matplotlib (while admitting it's a powerful package lots of people love) is that it just doesn't stick to my brain and feels like I'm swapping to another language when I do plotting. And should you look at the source to see how things work, you're confronted with a whole lot of functions using kwargs.
|
# ? May 22, 2015 17:51 |
|
Sitting down over a weekend and reading the docs and tweaking my matplotlibrc file to my liking was one of the best things I ever did. While I went through the docs, I created dummy template files that have the code for the most common plots I do, so now I just copy and paste it over and I'm off to the races. I tried out seaborn and some of the other graphics libraries, but just always came back to matplotlib.Cingulate posted:I think that's being a bit too down on matplotlib - you can still do reasonably pythonic stuff that would be rather different in Matlab. Like, iterating over axes to set their properties etc. Yeah, this is really nice as well. Especially when you are handling multiple subplots in one figure.
|
# ? May 22, 2015 18:17 |
|
Cingulate posted:I think that's being a bit too down on matplotlib - you can still do reasonably pythonic stuff that would be rather different in Matlab. Like, iterating over axes to set their properties etc. Yes, it's much better than plotting in Matlab, but it could still use some improvement. Better documentation would be a good start, since matplotlib isn't doing much better than Matlab in that regard, and I think that both Matlab and matplotlib are practically impenetrable to new users who want to do something other than the most basic poo poo. Plus all of the aspects of matplotlib that were designed to mimic Matlab resulted in a bunch of methods and functions that are just frustrating to use, and it feels like the more Pythonic side of things was neglected. For instance, if you create a new Figure, and then want to plot something on an old Figure, how do you do that? There are two solutions as far as I can tell 1) Call figure(N) where N is a magic number referring to the old figure, then call pyplot.plot. This is the Matlab style of doing things and it sucks. 2) Using the old Figure instance, call Figure.add_subplot(1,1,1) to get an Axes object, then call Axes.plot. This is way more Pythonic, but still pretty awkward. Instead, it would be to be able to call Figure.plot, which would return an Axes object. Basically, it shouldn't be necessary to call add_subplot in the case where you only want a single plot on the figure. I don't take issue with there being a Matlab style of doing things, since the developers wanted to appeal to Matlab users as well as Python users. I take issue with the basic Tutorial offering only the Matlab solution. I also take issue with the Python solution being so clunky, which suggests to me that the Pythonic side of matplotlib has a lot of neglect. It would be really nice if matplotlib provided a "For MATLAB users" tutorial next to a "For PYTHON users" tutorial that would address the respective styles of these very different languages. Instead, most of the tutorials provide the Matlab-style solution, with all of the global imports and magic numbers and horrible bullshit code that you'd expect to see in a Matlab script.
|
# ? May 22, 2015 18:54 |
|
EDIT:Figured my problem out. In my executemany statement, I had movieList inside the quotes containing the SQL statement, instead of outside. Moving it outside the quotes fixed my problem. I'll leave the problem incase it may help any other beginners. Ok, I'm stuck. I'm trying to scrape an XML file full of TV show info and save it to a database. Figured it'll teach me a little bit about both. So, I've successfully scraped the XML file and can parse out the Title and the ID. The XML file looks very similar to this, except it holds information on about 50,000 shows. Since I can successfully scrape and print out the tv show Title and ID, I added code to commit it to an sqlite3 database. When trying to execute the script, I receive the error: code:
Below is the code I'm trying to execute. Below that is the script I initially used to create my db. Python code:
Python code:
Hughmoris fucked around with this message at 03:51 on May 24, 2015 |
# ? May 24, 2015 03:40 |
|
Looks like a typo. I believe it'll work if you change:code:
code:
|
# ? May 24, 2015 03:49 |
|
Fergus Mac Roich posted:Looks like a typo. I believe it'll work if you change: Good eyes! As soon as I submitted it I went back and took a look at the python docs example and caught the mistake. Corrected it and launched the script. It ran just fine. Thanks.
|
# ? May 24, 2015 03:52 |
|
Speaking of Bokeh, we just had a 0.9 release last week. You can now add callback on selections and widgets with a handful of lines of JavaScript so that all kinds of rich interactions are possible without a server (i.e. in static HTML documents). You can see some simple examples in in the Adding Interactions section of the new User's Guide. FWIW I use to work on Chaco (years ago.. I added contour and image plots to it, among other things). If you need interactive plotting solely for rich clients it's definitely an option, tho I find it a bit excessively fiddly, syntax-wise. BigRedDot fucked around with this message at 00:18 on May 25, 2015 |
# ? May 25, 2015 00:15 |
|
I have a couple years of professional experience as a SW engineer, and I just accepted a new job in a Python shop. I'm familiar with the basics of Python and have written small scripts and ETL stuff with it before, but have never really used it in a professional capacity. I'm looking for one or more books to read to help me get up to speed. I'm not looking for something targeted at beginning programmers, but but rather something that will teach me the ins and outs and how to be "pythonic." I'm not sure which version of Python they use, but I do know that they use Tornado extensively. Any recommendations?
|
# ? May 26, 2015 19:26 |
|
Fluent Python. It's written for Python 3 but calls out the differences from 2, which is what your job will be using.
more like dICK fucked around with this message at 00:20 on May 27, 2015 |
# ? May 27, 2015 00:17 |
|
Thanks, I'll check that out. They only started using Python about two years ago, so there is an outside possibility that they may be using 3.
|
# ? May 27, 2015 03:06 |
|
I seem to be getting "Forbidden 403, CSRF cookie not set" on IE, FIreFox, and Chrome, when running the local dev server. I'm getting the error when submitting the standard django admin site login form. I don't think it's likely that all of a sudden none of the browsers on my machine are accepting cookies. What else could cause this? I can see the csrfmiddlewaretoken hidden input in the html source. Edit: Django 1.7.7 Edit: vvv Whoops! Thank you. epswing fucked around with this message at 17:33 on May 28, 2015 |
# ? May 28, 2015 17:14 |
|
epalm posted:I seem to be getting "Forbidden 403, CSRF cookie not set" on IE, FIreFox, and Chrome, when running the local dev server. I'm getting the error when submitting the standard django admin site login form. I don't think it's likely that all of a sudden none of the browsers on my machine are accepting cookies. What else could cause this? I can see the csrfmiddlewaretoken hidden input in the html source. FWIW, there's a Django thread.
|
# ? May 28, 2015 17:29 |
|
*Solved. I'm stumped on a problem in Flask. I'm trying to test how to submit input and do something with it, then return it to the user. In this case, the user enters a string and submits it, and the webapp returns the string in all uppercase. My problem is understanding the routes and how GET/POST works. This code right here works as intended: Python code:
Python code:
Hughmoris fucked around with this message at 04:05 on May 29, 2015 |
# ? May 29, 2015 02:17 |
|
What does the html for your form look like? Is the "action" attribute pointing to your new route?
more like dICK fucked around with this message at 03:47 on May 29, 2015 |
# ? May 29, 2015 03:41 |
|
more like dICK posted:What does the html for your form look like? Is the "action" attribute pointing to your new route? HTML code:
Hughmoris fucked around with this message at 04:03 on May 29, 2015 |
# ? May 29, 2015 04:01 |
|
more like dICK posted:Fluent Python. It's written for Python 3 but calls out the differences from 2, which is what your job will be using. Not necessarily. My side job (rather large Django app and lots of automation scripting) runs everything on 3.4.
|
# ? May 29, 2015 13:37 |
|
Fergus Mac Roich posted:Looks like a typo. I believe it'll work if you change: Most editors will use a different color for the contents of python string literals (eg "words inside quotes") so you know when/if you've terminated your quotes properly. In this case you would have quickly seen that the entirety of the code inside c.executemany was a single string, which is probably not what you wanted.
|
# ? May 31, 2015 21:50 |
|
ShadowHawk posted:Incidentally, this is a good time to mention you should reexamine your choice of editor. Not only that, but PyCharm would specifically switch to an SQL context when the cursor was inside the SQL statement and do syntax highlighting and code completion.
|
# ? Jun 1, 2015 03:34 |
|
Some posters recently recommended I learn about testing, and coincidentally the next Coursera course in the series I'm taking is testing focused. So far so good but one question is bugging me. I know how to run a test suite to test for situations where I know the expected result, but how do I test with randomness? For example, while making a game I initialize a game board and can easily test that the initialization works as expected. Then I add a number to a random square. Using my testing suite, there isn't an expected value for the board to compare to the computed value. Obviously this case is trivial and can easily be tested by just printing the board, but what about for more complex functions? Again, this might be a tough question to tackle in a forums post.
|
# ? Jun 2, 2015 09:38 |
|
dantheman650 posted:Some posters recently recommended I learn about testing, and coincidentally the next Coursera course in the series I'm taking is testing focused. So far so good but one question is bugging me. I know how to run a test suite to test for situations where I know the expected result, but how do I test with randomness? For example, while making a game I initialize a game board and can easily test that the initialization works as expected. Then I add a number to a random square. Using my testing suite, there isn't an expected value for the board to compare to the computed value. Obviously this case is trivial and can easily be tested by just printing the board, but what about for more complex functions? Again, this might be a tough question to tackle in a forums post. random.seed(0) etc
|
# ? Jun 2, 2015 09:45 |
|
dantheman650 posted:Some posters recently recommended I learn about testing, and coincidentally the next Coursera course in the series I'm taking is testing focused. So far so good but one question is bugging me. I know how to run a test suite to test for situations where I know the expected result, but how do I test with randomness? For example, while making a game I initialize a game board and can easily test that the initialization works as expected. Then I add a number to a random square. Using my testing suite, there isn't an expected value for the board to compare to the computed value. Obviously this case is trivial and can easily be tested by just printing the board, but what about for more complex functions? Again, this might be a tough question to tackle in a forums post. Some ways to do it: Use a fixed random seed and make a test for whatever you happen to get out: This is pretty fragile, but it can be okay if you have a result that must never change. Python code:
Python code:
Or you can go with the randomness and check invariants instead of comparing to an exact result: Python code:
|
# ? Jun 2, 2015 21:15 |
|
Does anyone have a good resource for understanding decorators? I'm roughly a month into learning Python and I'm having a hard time wrapping my head around them. They're just an easy way to pass one function to another as an argument? Why do I want to do that?
|
# ? Jun 2, 2015 23:04 |
|
Baby Babbeh posted:Does anyone have a good resource for understanding decorators? I'm roughly a month into learning Python and I'm having a hard time wrapping my head around them. They're just an easy way to pass one function to another as an argument? Why do I want to do that? Have you read this: http://thecodeship.com/patterns/guide-to-python-function-decorators/ ? Also, have a look at the Python Decorator Library. Thanks for the awesome example of using mock.
|
# ? Jun 2, 2015 23:20 |
|
Baby Babbeh posted:Does anyone have a good resource for understanding decorators? I'm roughly a month into learning Python and I'm having a hard time wrapping my head around them. They're just an easy way to pass one function to another as an argument? Why do I want to do that? Let's say you're trying to figure out a codebase someone else wrote Python code:
Or you have a set of functions that interact w/ a system/session/request/etc with the same setup or tear down behavior Python code:
--- PEP-0492: async & await and PEP-0484: type hints have been accepted. Good: Python is becoming slow C# Bad: Comments can mean something other than "ignore everything after the # until a new line" salisbury shake fucked around with this message at 07:45 on Jun 4, 2015 |
# ? Jun 3, 2015 19:01 |
|
salisbury shake posted:Bad: Comments can mean something other than "ignore everything after the # until a new line" I think everyone involved acknowledges that this isn't the best possible solution, but getting PEP-0484 accepted for 3.5 wasn't going to happen with new syntax and supporting 3.4 was definitely not going to happen with new syntax. Guido seems to favor new syntax for this in 3.6.
|
# ? Jun 3, 2015 19:44 |
|
Thanks for the help, accipter & salisbury shake. That makes it a bit clearer to me. I think I wasn't getting it because the test code I was given to explain it was just a useless function that demonstrated that the original function wouldn't run, so I couldn't see why I'd want to write a decorator like that rather than just modifying the original function. Decorators seem like they could be really handy!
|
# ? Jun 3, 2015 20:29 |
|
salisbury shake posted:Stick a @dump_args on a bunch of methods/functions and you'll get a map of how poo poo flows through the program
|
# ? Jun 3, 2015 21:29 |
|
That said, it is pretty much just convenient syntax. You could equivalently addPython code:
Someone who has read PEP492 and understands asyncio better than I do: what's the significance for this with asnycio applications? Is it basically replacing yield from with await to make the meaning more transparent? Or does it include deeper changes?
|
# ? Jun 4, 2015 16:47 |
|
SurgicalOntologist posted:Is it basically replacing yield from with await to make the meaning more transparent? Yes. Using @asyncio.coroutine and yield from will continue to work as before, though. It's kind of a weird thing they did, but I guess they wanted to not introduce any new keywords for 3.4.
|
# ? Jun 4, 2015 17:35 |
|
Is there any downside for the average Python hobbyist to use Anaconda? It looks like it comes with a ton of great modules.
|
# ? Jun 7, 2015 00:13 |
|
Hughmoris posted:Is there any downside for the average Python hobbyist to use Anaconda? It looks like it comes with a ton of great modules. No downside, but if you use python properly (ie. a virtualenv for each project) there's not much upside either.
|
# ? Jun 7, 2015 00:17 |
|
Hughmoris posted:Is there any downside for the average Python hobbyist to use Anaconda? It looks like it comes with a ton of great modules. No. I guess the default install is kind of huge, like a couple of GB. So if you're using a 20 year-old machine, that could be an issue.
|
# ? Jun 7, 2015 00:18 |
|
Hughmoris posted:Is there any downside for the average Python hobbyist to use Anaconda? It looks like it comes with a ton of great modules.
|
# ? Jun 7, 2015 00:19 |
|
Nippashish posted:No downside, but if you use python properly (ie. a virtualenv for each project) there's not much upside either. I would say the upside of Conda/Anaconda is ease of installation in Windows.
|
# ? Jun 7, 2015 16:41 |
|
accipter posted:I would say the upside of Conda/Anaconda is ease of installation in Windows. I didn't think of that because I never use python on windows, but that is a good point.
|
# ? Jun 7, 2015 18:48 |
|
|
# ? Jun 3, 2024 16:18 |
|
accipter posted:I would say the upside of Conda/Anaconda is ease of installation in Windows. Anaconda is also great for enterprise environments where getting Anaconda approved is one piece of paperwork, and you can't run "pip install" etc., because instead you're supposed to do more paperwork for each module.
|
# ? Jun 8, 2015 01:44 |