filmov
tv
Styling DataFrames | #49 of 53: The Complete Pandas Course
![preview_player](https://i.ytimg.com/vi/OQv-qh8ZmRM/maxresdefault.jpg)
Показать описание
The next trick is very interesting. It's about Styling the Dataframe in Pandas. Panda's provides a very nice way to display the data present in data frames. It works very well with Jupyter notebooks. Let's see how it works
Join ML+ membership for exclusive Data science content
🔹 Tips and Tricks on Applying Styling in Python Pandas Dataframes in Python Pandas.
On top of this, you can further enhance the way your numbers are displayed by coloring the numbers or by highlighting the different rows and columns or specific cells that you want to highlight that you can style it using pandas.
The way to do it is quite straightforward. pandas has a style method, let's look at it based on this particular data frame where this contains random integers, some of them are negative numbers.
Now suppose you want to highlight or color the negative numbers in red color, you can do that using df dot the style attribute, this attribute contains various methods. Here I'm using apply nap we have seen this function before this applies to every cell of your data frame use apply map and this apply map should return a certain CSS coloring scheme.
For instance, what we are doing here is if the value is lesser than zero, it should return red. If it is not then Black, right, the return value is color colon or red or color colon black, that will be the return value.
Let's run this and see the output. Here we have a nice representation wherever the number values are negative, all those numbers are in red.
Let me know in the comments section if you have any questions!
🤝 Like, Share, Subscribe for more!
Follow us on our social media handles for all updates, events and live sessions-
If you enjoyed this video, be sure to throw it a like and make sure to subscribe to not miss any future videos!
Thanks for watching!
#machinelearningplus #python #pandas #datascience
Join ML+ membership for exclusive Data science content
🔹 Tips and Tricks on Applying Styling in Python Pandas Dataframes in Python Pandas.
On top of this, you can further enhance the way your numbers are displayed by coloring the numbers or by highlighting the different rows and columns or specific cells that you want to highlight that you can style it using pandas.
The way to do it is quite straightforward. pandas has a style method, let's look at it based on this particular data frame where this contains random integers, some of them are negative numbers.
Now suppose you want to highlight or color the negative numbers in red color, you can do that using df dot the style attribute, this attribute contains various methods. Here I'm using apply nap we have seen this function before this applies to every cell of your data frame use apply map and this apply map should return a certain CSS coloring scheme.
For instance, what we are doing here is if the value is lesser than zero, it should return red. If it is not then Black, right, the return value is color colon or red or color colon black, that will be the return value.
Let's run this and see the output. Here we have a nice representation wherever the number values are negative, all those numbers are in red.
Let me know in the comments section if you have any questions!
🤝 Like, Share, Subscribe for more!
Follow us on our social media handles for all updates, events and live sessions-
If you enjoyed this video, be sure to throw it a like and make sure to subscribe to not miss any future videos!
Thanks for watching!
#machinelearningplus #python #pandas #datascience