|
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 |
|
|
# ¿ May 9, 2024 12:20 |
|
Opulent Ceremony posted:What's 3 doing differently? Treating range() like xrange() from python 2, I think.
|
# ¿ Jun 9, 2015 16:24 |
|
Amberskin posted:Hello, I'd recommend starting by reading about the python debugger: https://docs.python.org/2/library/pdb.html It works just fine in iPython notebooks.
|
# ¿ Jul 30, 2015 22:11 |
|
If you don't have many labels, just pass them in explicitly and be done with it.
|
# ¿ Aug 3, 2015 07:19 |
|
Gothmog1065 posted:Okay, I need some help, namely with the error that's being thrown. Basically link_list is a list of tuple pairs ( ex: list = [(1,2),(2,3)...] ), but I'm having issues removing them at the end. Here's my lovely code. I'm working through this myself, so I'm hoping to get that specific part working before I move on (then I'll get advice on how to be less stupid with my code). Indentation error technically, but really a scope problem. You define "disconnect" at a level lower (inside the for loop) than what you are calling (inside the while loop).
|
# ¿ Sep 8, 2015 20:48 |
|
Thermopyle posted:Because the vast majority of things people do with Python get no particular benefit out of numpy? This. When I first started using python I had no needs outside of the standard library, but once I started doing my data analysis/cleaning/plotting in python I moved over to the Anaconda distribution since pandas, numpy, and MPL are daily drivers for me now. Once of the things I loved as a beginner to the language was how robust (at least to me) the standard library was in helping me do what I needed.
|
# ¿ Oct 16, 2015 15:12 |
|
I usually use a combination of requests and Beautiful Soup to download and scrape information from websites. Not sure if there is anything newer that has supplanted this. For working with tabular data I use pandas.
|
# ¿ Oct 17, 2015 03:26 |
|
Hughmoris posted:I'm trying to explore and understand pandas and numpy. i have a data set that looks like this: Phone posting, but get discharge delay into numeric units and then use group by: df.groupby("unit", sort=True)["discharge_delay"].mean() This will find the mean discharge delay for each unit in the data. You can then take the series that's returned and easily plot a bar graph in matplotlib or the the built in pandas functions.
|
# ¿ Oct 20, 2015 03:53 |
|
Fwiw, Anaconda on Windows has been pretty hassle free for me and comes with a bunch of stuff pre installed (well at least everything I usually use regularly).
|
# ¿ Jan 29, 2016 01:07 |
|
politicorific posted:Jesus christ... I've never had any issues like this with Anaconda before. Do you have multiple python installations on the same machine?
|
# ¿ Jan 29, 2016 15:42 |
|
Is morphology unique to each word (this may be stupid if you know the problem)? If so, couldn't you just merge the two frames on morphology and then keep the intersection? pandas.merge(df1, df2, on="morphology", how="inner")
|
# ¿ Feb 7, 2016 14:43 |
|
Yeah, string.whitespace is a longer string than just "\t"
|
# ¿ Mar 1, 2016 17:22 |
|
You can use a list comprehension to do that cleaner. Or you could use a dict of lists.
|
# ¿ Apr 8, 2016 18:59 |
|
drainpipe posted:I'm coding up the k-means clustering algorithm for a homework assignment. I'm given a list of data points (each with two coordinates) and I need to put them into k clusters. The way I'm doing it is to define k empty lists and fill them up with indices of my data points according to which cluster they belong to. I just realized that adding an extra column to the data array to indicate cluster assignment might work just as well. Have you looked into pandas? Stuff like this seems like it would be suited well. For example, to find the mean of a cluster is a simple groupby function call. Accessing the data points of a cluster is just indexing, etc.
|
# ¿ Apr 8, 2016 21:06 |
|
drainpipe posted:Oh cool, I haven't looked at that. Are you talking about the DataFrames structure? I'm not familiar with Python and its packages so I'm using this class also as an opportunity to learn Python. Yep.
|
# ¿ Apr 8, 2016 21:40 |
|
Go ahead and queue up the math/stats notation in code argument.
|
# ¿ Apr 10, 2016 17:59 |
|
I write terrible scientific/data analysis code, but I'd like to think this thread has helped me clean it up a lot over the last couple of years.
|
# ¿ Apr 10, 2016 19:39 |
|
Not sure what you're really looking for as the output goes, but is this similar to what you have in mind?code:
code:
vikingstrike fucked around with this message at 22:58 on Jul 1, 2016 |
# ¿ Jul 1, 2016 22:52 |
|
I work with much larger data frames in pandas and for most things it's quick enough with the built in functions. Every now and then it will blow up and I'll get a bit more involved with coding what I need but the developers have really done a nice job over the last year or so at making it faster and using cython when possible.
|
# ¿ Jul 3, 2016 16:52 |
|
I'll have to look closer when not on a phone but can definitely use & and | for row indexing in pandas. I'm pretty sure your .loc[] commands are slightly wrong from a quick glance. Here's what you want code:
vikingstrike fucked around with this message at 20:57 on Nov 18, 2016 |
# ¿ Nov 18, 2016 20:07 |
|
Eela6 posted:You want to use numpy / MATLAB style logical indexing. BTW, touching on your post before the edit, I believe that this is something the pandas devs do on purpose to make it better align with other data analysis platforms.
|
# ¿ Nov 19, 2016 00:13 |
|
Yeah, just use pandas. CSV is usually more convenient though, IME, especially with larger files since you'll likely never want to open them ... in Excel. But we work in real office places (I'm assuming some of us at least) and you're sent what you're sent. I usually will take a raw file like that, clean/sanity check it, and then write an HDF file with the type info.
|
# ¿ Nov 29, 2016 05:35 |
|
For scipy I remember when building from source it can be really picky about the compiler version and flags that are being used. Not sure if this helps you any. :/
|
# ¿ Feb 4, 2017 15:25 |
|
I'm trying to make the transition to python 3.6, and am wondering if there are any helpful resources online that summarize the big changes in python 3? I found the What's New section of the official documentation, but am looking for more of a Cliff Notes version until I have time to finish reading through the docs.
|
# ¿ Feb 7, 2017 21:49 |
|
Dominoes posted:.... Eela6 posted:... Thanks!
|
# ¿ Feb 9, 2017 23:15 |
|
If you are going to be doing data analysis in python, you'll want to learn and be comfortable with pandas and numpy. Given you are coming from R I would guess pandas is exactly what you are looking for. import pandas as pd frame = pd.read_csv(my.csv) And go to town.
|
# ¿ Feb 11, 2017 04:47 |
|
Fusion Restaurant posted:1. Do people use spaces or tabs to indent? I've noticed when copy pasting that sublime text is giving me tabs by default while Spyder is giving me spaces. Why would it be that much different in python? Of course working on smaller chunks of a larger data set and then putting them together will lower the amount of RAM you need at any one time.
|
# ¿ Feb 13, 2017 18:58 |
|
Merge in pandas has a "copy" parameter that controls that exact behavior. You'll want to set it to False.
|
# ¿ Feb 14, 2017 14:13 |
|
|
# ¿ May 9, 2024 12:20 |
|
Just use the short blurbs y'all sent me when I asked a couple of weeks ago. Super short, no politics, etc.
|
# ¿ Mar 7, 2017 14:14 |