Tabulate - Python Library of the Day

preview_player
Показать описание
Okay todays python library of the day, including a no-expense spared intro, is Tabulate, which is a super fast way of getting your output neat and pretty after you've spent tons of time. Using libraries allows you to concentrate and work on your code, not worry about the getting the output clean - whilst allowing that output to still represent the quality of thinking that you put into generating the data.

This also works beautifully with pandas, and basically anything which produces an iterator.

It auto formats, and whats really nice is it formats into different formats like Jira or Media wiki, which means producing output that can be quickly pasted into other situations is super awesomely great.

Its libraries like this one save us so many hours, it improves the quality of the code, and makes our life better. That's what I love about open-source community which is when you get something of quality and everyone benefits.

Python is a wonderful language to code in, because its very clear which makes it maintainable. Not only does it make an excellent rapid prototyping language, but its great and scalable to real business applications that you can rely on as well.
Рекомендации по теме
Комментарии
Автор

Your reviewing of such libraries is incredibly useful! Thank you!

samrijijkot
Автор

Great video! Can you please explain how to make rows start from 1? Thanks!

aaante
Автор

Great video, I was wondering, with tabulate can you instead of numbers add in code to output a number in the table, such as:

x = [
['NDVI_min', np.min(NDVI92), np.min(NDVI01), np.min(NDVI06)],
['NDVI_max', np.max(NDVI92), np.max(NDVI01), np.max(NDVI06)],
['NDVI_mean', np.mean(NDVI92), np.mean(NDVI01), np.mwan(NDVI06)]
]

Would that still output the data from that code into numerical values?

I'm pretty new to python (started about 2 months ago, with very little teaching input) and need to create a table to display data that is otherwise imputed like this:

print("The max NDVI value for 2006 is", np.max(NDVI06))
print("The min NDVI value for 2006 is", np.min(NDVI06))
print("The mean NDVI value for 2006 is", np.mean(NDVI06))

This doesn't look very tidy and annoying, it doesn't matter whether I input this bit code above or below the image code, the text output always appears at the top of the output. The image code I have input is:

THNIR92 = copy.copy(NIR92)
THNIR92_int = THNIR92.astype(np.int16)
THRED92 = copy.copy(RED92)
THRED92_int = THRED92.astype(np.int16)
NIRRED92_minus = THNIR92_int - THRED92_int
NIRRED92_add = THNIR92_int + THRED92_int
NDVI92 = NIRRED92_minus / NIRRED92_add

plt.subplot(2, 3, 1)
plt.imshow(NDVI92, cmap = 'RdYlGn', vmin=-1, vmax=1)
plt.axis('on')
plt.title('NDVI Image for 1992')
plt.colorbar()

I get a similar thing happen with figure names, I input the figure, like this:

plt.tight_layout()
txt="Fig 2: The NDVI images represent land use in 1992, 2001, and 2006"
plt.figtext(0.5, 0.35, txt, wrap=True, horizontalalignment='center', fontsize=12)

And that appears below the images and at the top of the output section.

Honestly, I can't seem to find any solutions, but then I don't know where to look or what to search tbh. I was looking at trying to improve the code, making the layout look tidier and generally nicer, but I'm stumped.

Any help or signposting to useful pages would be great.

Cheers :)

adammorgan
welcome to shbcf.ru