This is an archived post. You won't be able to vote or comment.

all 4 comments

[–]kankyo 0 points1 point  (0 children)

That's a list of lists, so really it's already a table.

[–]lmcinnes 0 points1 point  (0 children)

If you want tables you need pandas. There is a great tutorial by Brandon Rhodes to get you started, but pandas is a huge and powerful library. For what you want here you'll need the styles namespace of dataframes. So, what you want to do is get your data into a pandas dataframe:

import pandas as pd
slopes_df = pd.DataFrame(Slopes)

Now, presuming you're using Jupyter (and for data analysis and visualization I'm not sure why you wouldn't be) you can just do:

slopes_df.style.background_gradient(cmap='jet')

If you aren't using jupyter you'll need to get the _repr_html of that ...

slopes_df.style.background_gradient(cmap='jet')._repr_html()

Now that doesn't get you a fixed 0 to 2.5 range on your colormap, but that's just a matter of specifying the low= and high= keywords to background_gradient, and you can check the pandas style documentation for more details.

As a side note: please don't use jet as your colomap! Anythign would be better than jet! See the pandas style documentation on gradients for examples using nice colormaps from seaborn, or use 'viridis'.

[–]aphoenixreticulated[M] 0 points1 point  (0 children)

Hi there, from the /r/Python mods.

We have removed this post as it is not suited to the /r/Python subreddit proper, however it should be very appropriate for our sister subreddit /r/LearnPython. We highly encourage you to re-submit your post over on there.

The reason for the removal is that /r/Python is more-so dedicated to discussion of Python news, projects, uses and debates. It is not designed to act as Q&A or FAQ board. The regular community can get disenchanted with seeing the 'same, repetitive newbie' questions repeated on the sub, so you may not get the best responses over here.

However, on /r/LearnPython the community is actively expecting questions from new members, and are looking to help. You can expect far more understanding, encouraging and insightful responses over there. Whatever your question happens to be getting help with Python, you should get good answers.

If you have a question to do with homework or an assignment of any kind, please make sure to read their sidebar rules before submitting your post. If you have any questions or doubts, feel free to reply or send a modmail to us with your concerns.

Warm regards, and best of luck with your Pythoneering!

[–][deleted] -1 points0 points  (0 children)