No video

Matplotlib Tutorial (Part 2): Bar Charts and Analyzing Data from CSVs

  Рет қаралды 341,953

Corey Schafer

Corey Schafer

Күн бұрын

Пікірлер: 347
@Sharmapawan98
@Sharmapawan98 5 жыл бұрын
Who needs python docs when you have such an amazing teacher
@seanli75
@seanli75 4 жыл бұрын
True:
@niteshprajapat7918
@niteshprajapat7918 3 жыл бұрын
Exactly Brother
@JoshKonoff1
@JoshKonoff1 3 жыл бұрын
Where is the CSV for this? I don't see it in the description. Thank you!
@SimonYells
@SimonYells 2 жыл бұрын
True
@OT-tn7ci
@OT-tn7ci 2 жыл бұрын
the teacher
@ishanpand3y
@ishanpand3y 4 жыл бұрын
In case you don't know, the shortcut for 8:13 in jupyter notebook is *Ctrl + left mouse click* on the different lines one by one. You can write at different lines at the same time.
@jaxnaur218
@jaxnaur218 2 жыл бұрын
Nice! Thanks form 2years later!
@jeffery_tang
@jeffery_tang 2 жыл бұрын
alt + left mouse in vs code
@damalkkoklannou1620
@damalkkoklannou1620 8 ай бұрын
thanks u @@jeffery_tang
@MrBuion
@MrBuion 4 жыл бұрын
These series is much better than the curses in Udemy I paid for. Thank you very much.
@DendrocnideMoroides
@DendrocnideMoroides 3 жыл бұрын
what "curses"
@iscoto4914
@iscoto4914 2 жыл бұрын
@@DendrocnideMoroides wannabe savage
@TheShubham67
@TheShubham67 4 жыл бұрын
This series with pandas one has taken my skills to a new level.
@sunshadow9704
@sunshadow9704 2 жыл бұрын
Corey, you are great teacher. You have rare ability to explain calmly. Much appreciating your efforts.
@fangshizhu9383
@fangshizhu9383 3 жыл бұрын
At 8:12, when you selected multiple locations and simultaneously type the same code to multiple lines, my world just expanded!
@bmwmhamam
@bmwmhamam 4 жыл бұрын
No body teaches like you. You are the best. Amazing delivery of information, truly useful tutorials. Thank you so much.
@Ghasakable
@Ghasakable 5 жыл бұрын
Man, you are awesome, everything I have learned about python started from your channel, I wish you the very best all success, as you make everyone happy, keep up the excellent work, we all heavily rely on you.
@coreyms
@coreyms 5 жыл бұрын
Thanks! That's very kind of you.
@apoorvwatsky
@apoorvwatsky 5 жыл бұрын
23:40 here's that one liner if anybody's interested. Personally, I like this more. languages, popularity = map(list, zip(*language_counter.most_common(15)))
@costasvas341
@costasvas341 4 жыл бұрын
Really nice! Could you please explain what the "*" symbol does?
@paklong2556
@paklong2556 4 жыл бұрын
nice
@jg9193
@jg9193 4 жыл бұрын
Or just: list(zip(*language_counter.most_common(15))). Map is unnecessary as list() automatically maps over an Iterable
@corben3348
@corben3348 4 жыл бұрын
@@jg9193 but if you don't use map(list, iterable) then languages and popularity will be tuples so you cannot use reverve() for the rest of the tutorial. Or languages, popularity = [list(e) for e in zip(*language_counter.most_common(15))] without map
@jg9193
@jg9193 4 жыл бұрын
@@corben3348 Fair point, I didn't think of that. That said, he could just do languages[::-1] instead of languages.reverse() to reverse a tuple Then again, using list() would even be unnecessary if he did that
@shadowmasked7188
@shadowmasked7188 Жыл бұрын
Thank you very much bro, Greetings from Azerbaijan.
@borhansiddiki7079
@borhansiddiki7079 4 жыл бұрын
I think your videos are more understandable than rest of the youtube channels
@SahilKhan-rv9xb
@SahilKhan-rv9xb 3 жыл бұрын
for those wondering how to obtain the CSV file, once you've clicked on it and you see all of the data in your web browser, just right click and say save as
@Alejandro-ry9ny
@Alejandro-ry9ny 3 жыл бұрын
jaja that was very useful, Thanks!
@shashankbanakar8766
@shashankbanakar8766 2 жыл бұрын
Thanks so much!
@abhishek_raj
@abhishek_raj 3 жыл бұрын
Right from reading data from a csv file to plotting it, you helped a lot of people.
@KienDoanTrung168
@KienDoanTrung168 5 жыл бұрын
such a great Python instructor with an angelic voice. Thank you so much 😊
@nicholasmaloof8378
@nicholasmaloof8378 5 жыл бұрын
2 weeks later and still not a single dislike on this video
@shuklarahul17
@shuklarahul17 4 жыл бұрын
As you mentioned Zip can also be used language = cnt.most_common(10) language.reverse() language_X, language_Y = list(zip(*language)) plt.barh(language_X, language_Y)
@djadamkent
@djadamkent 5 жыл бұрын
Another great video, thank-you. A Pandas series of videos would be awesome!
@introduction_official6547
@introduction_official6547 5 ай бұрын
Very informative video, good job Mr Corey
@akunnaemeka395
@akunnaemeka395 2 жыл бұрын
thank you Brilliant for supporting Corey
@ericfricke4512
@ericfricke4512 4 жыл бұрын
Programming is so fun.
@miosz952
@miosz952 4 жыл бұрын
The great thing about your tutorials is that despite main topic, you learn a lot useful tricks, modules etc.
@dalanxd
@dalanxd 3 жыл бұрын
Corey Schafer saves my life once again... Deep gratitude for your work, man!
@lalu225
@lalu225 5 жыл бұрын
Excellent tutorial Corey! Real life stuff and practical, including the use of Counter. It's important to show these data preparation steps. Very helpful indeed, thank you.
@manosmakris8308
@manosmakris8308 Жыл бұрын
You can also do this for geting the languages and popularity lists. languages = list(map(lambda x: x[0], language_counter.most_common(15))) print(languages) popularity = list(map(lambda x: x[1], language_counter.most_common(15))) print(popularity)
@Thedevineforce
@Thedevineforce 4 жыл бұрын
@Corey Schafer .. I came up with below function which will handle the bar widths for multiple bar plots by itself. Just in case anybody wants to use it : ages_x = np.asarray([25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35]) count = 5 width = 0.8/count def width_cal(position): shift = np.array([]) if count < 2: return ages_x if count % 2 == 0: for i in range(1, count, 2): shift = np.append(shift, (width/2 * i)) shift = np.sort(np.append(shift, np.negative(shift))) else: for i in range(0, count, 2): shift = np.append(shift, (width/2 * i)) shift = np.unique(np.sort(np.append(shift, np.negative(shift)))) shift = np.around(shift, decimals=3) return ages_x + shift[position] plt.bar(width_cal(0), dev_y, width=width, color='#444444', label="All Devs")
@ahmedskasmani
@ahmedskasmani 4 жыл бұрын
Amazing content Corey. The way you simplify the material and explain is awesome, many thanks. Can you please also do a video showing your setup and how you make video's. Thanks !!!
@micheliwrmg
@micheliwrmg Жыл бұрын
sad fact, if you want to open csv file in PYcharm , you have to pay for PYcharm Professional(~$230) :( btw you are the best teacher I've ever seen
@dhssb999
@dhssb999 Жыл бұрын
best matplotlib tutorial ever!
@SM-vu6fm
@SM-vu6fm 2 жыл бұрын
Counter() is the best thing I learned today
@luiggitello8546
@luiggitello8546 8 ай бұрын
This is the best content on KZbin, thank you for so much
@storiesshubham4145
@storiesshubham4145 2 жыл бұрын
I can't express how amazing this video is. What a great teacher you are. 🔥🔥
@58_yesilgul
@58_yesilgul 7 ай бұрын
What a perfect lesson, fast and insightful pieces of knowledge...
@mohammedismail308
@mohammedismail308 5 жыл бұрын
Thanks a lot Corey. Really your videos are endless treasure. Just a way for plotting bar charts for more than one dataset on the same plot without need to numpy. Just use built-in map function. width = 0.25 #Width of bar plt.bar(list(map(lambda x: x-width/2, age_x)), salaries1, color = 'k', width = width) plt.bar(list(map(lambda x: x+width/2, age_x)), salaries2, color = 'r', width = width)
@Anon282828
@Anon282828 2 жыл бұрын
thank you for always showing the clear code before abbreviating
@rotrose7531
@rotrose7531 2 жыл бұрын
Thank you very much. Please, please come back!
@dgh25
@dgh25 Жыл бұрын
Your videos are just sprinkled with little golden nuggets! I love it ❤
@brumarul7481
@brumarul7481 3 жыл бұрын
This is pure Gold .
@rahil1575
@rahil1575 Жыл бұрын
you are a life saviour for people like me
@ItzSenaCrazy
@ItzSenaCrazy 5 жыл бұрын
What I really like is your videos, Corey. I can learn Python and English ;D Thanks!!
@MagnusAnand
@MagnusAnand 2 жыл бұрын
I can't believe we need this hack to make a bar chart. Great video.
@eziola
@eziola 11 ай бұрын
Would still love to see a video on counters and DefaultDict!
@dhairyaoza5422
@dhairyaoza5422 3 жыл бұрын
thank you so much sir,really glad i found ur playlist and didn't waste time on other platforms
@gamengine1176
@gamengine1176 4 жыл бұрын
Very helpful video. The pandas method is much simpler and easier to understand. Thanks Corey!
@pratikarai8115
@pratikarai8115 4 жыл бұрын
Your explanation is awesome...thank you so much ...A great teacher for a lifetime...
@markkennedy9767
@markkennedy9767 10 ай бұрын
Thanks for this. Great lesson. As you say, creating multiple bars seems extraordinarily hacky. I would have thought this would be easily dealt with by a plotting library
@muzaianghanem5644
@muzaianghanem5644 4 жыл бұрын
That's true......you are an amazing teacher. This was very helpful
@androkranjcevic1988
@androkranjcevic1988 3 жыл бұрын
Really nice work over here, the most important man on youtube for me.
@redferne01
@redferne01 5 жыл бұрын
Thank you for your work. I enjoy every lesson.
@luiscesar_agais
@luiscesar_agais 2 жыл бұрын
Very nice your explanations. Congratulations.
@LashaGoch
@LashaGoch 3 жыл бұрын
This is gold! Thank you very much for doing this, you have incredible talent to explain complicated stuff in an easy manner, keep up good work :)))
@eliesawan9513
@eliesawan9513 3 жыл бұрын
you are amazing, waiting for your data science ( ML, AI ) course...... THANKS A LOT!
@Lucas-wn5wm
@Lucas-wn5wm 2 жыл бұрын
I jus found the python legend . Thank god
@KC-rl8ub
@KC-rl8ub 5 жыл бұрын
hi Corey....god bless you
@niceday2015
@niceday2015 3 жыл бұрын
for i in range(1,365): print("Thank you very much")
@edcoughlan5742
@edcoughlan5742 5 жыл бұрын
These videos are great! Coming from R (and ggplot) I was a tad skeptical that Python could emulate R when it came to data viz, but I stand corrected.
@kabongontumba9492
@kabongontumba9492 3 жыл бұрын
You're right
@Linshark
@Linshark 3 жыл бұрын
I just came across this series of videos. They are extremely good :-)
@brucegwon
@brucegwon 4 жыл бұрын
This is the best fantastic lecture for the relation of Python and Pandas I've ever seen!!!!!!!!!!!!!! Xie Xie!!!
@SandeepChaudhary-vx9zy
@SandeepChaudhary-vx9zy 4 жыл бұрын
Great explanation...thanks a lot Corey sir
@ronaldjohnson4470
@ronaldjohnson4470 5 жыл бұрын
Corey, I went back to the documentation, and changed by code to ax=plt.subplot() ax.set_xticks(x_indexes) ax.set_xticklabels(ages_x) It worked, but I received a message : MatplotlibDeprecationWarning: Adding an axes using the same arguments as a previous axes currently reuses the earlier instance. In a future version, a new instance will always be created and returned. Meanwhile, this warning can be suppressed, and the future behavior ensured, by passing a unique label to each axes instance. warnings.warn(message, mplDeprecation, stacklevel=1)
@KumarGauravhi
@KumarGauravhi 3 жыл бұрын
Hi Corey, thank you for the wonderful session , I have stuck at this point with the last example :-import csv import numpy as np import pandas as pd from collections import Counter from matplotlib import pyplot as plt plt.style.use("fivethirtyeight") data = pd.read_csv('data.csv') ids = data['Responder_id'] lang_responses = data['LanguagesWorkedWith'] language_counter = Counter() for response in lang_responses: language_counter.update(response.split(';')) languages = [] popularity = [] for item in language_counter.most_common(15): languages.append(item[0]) popularity.append(item[1]) languages.reverse() popularity.reverse() plt.barh(languages, popularity) plt.title("Most Popular Languages") # plt.ylabel("Programming Languages") plt.xlabel("Number of People Who Use") plt.tight_layout() plt.show() ### I am getting an error like AttributeError: 'float' object has no attribute 'split' ...Please explain..
@Coney_island23
@Coney_island23 2 жыл бұрын
thank you!!!! you ar an excellent teacher
@oscar.kiamba
@oscar.kiamba Жыл бұрын
The best in you tube .👏
@franklinlima2571
@franklinlima2571 4 жыл бұрын
Great video! Thank you man
@mamathakavety6529
@mamathakavety6529 Жыл бұрын
Please do a tutorial on numpy as well, it would be super helpful, by the way awesome content😁
@AbubakerMahmoudshangab
@AbubakerMahmoudshangab 2 жыл бұрын
Corey. Million thanks bro
@jsceo
@jsceo 5 жыл бұрын
that feel when I paused tutorial to figure out how to extract languages and popularity from language_counter and later it turns out that you've done that exactly in the same way, lol
@akashdeepchauhan5
@akashdeepchauhan5 3 жыл бұрын
You're making machine learning interesting, thank you
@hayetchekired462
@hayetchekired462 3 жыл бұрын
great instructor
@fourdaysdead
@fourdaysdead 5 жыл бұрын
thank you very much, very clear and straight to the point!
@frankconte2457
@frankconte2457 5 жыл бұрын
Another great tutorial. Thank you. However, using a Jupyter Notebook, I am having a problem with plt.bar, plt.barh. The error I receive is "unsupported operand type(s) for -: 'str' and 'float'.
@thebuggser2752
@thebuggser2752 9 ай бұрын
Another great video. Thanks!!
@abhishek_raj
@abhishek_raj 3 жыл бұрын
You explain things really well, kudos!
@shreddersengupta7384
@shreddersengupta7384 4 жыл бұрын
we can also use the dictionary's keys() and values() for getting x and y axis. x_axis = list(dict.keys())
@Eric-ii4vj
@Eric-ii4vj 3 жыл бұрын
you can just use : plt.barh(list(reversed(df['language'])),list(reversed(df['popularity'])))
@minghaotao6259
@minghaotao6259 5 жыл бұрын
Thank you for sharing your knowledge!
@adirbarak5256
@adirbarak5256 4 жыл бұрын
for unpacking counter.most_common(x) you can use: for a,b in counter.most_common(x) or for a,b in counter.items(): cause they are the same, they are a list of tuples, which is "zipped" already = meaning you can iterate of it simultaneously (a is tuple[0]. b is tuple[1]) I hope it helps you, yea you out there.
@PaoloCondo
@PaoloCondo Жыл бұрын
Thank you for the series of video! :)
@kerimabdul2263
@kerimabdul2263 4 жыл бұрын
great video.
@alexanderten5497
@alexanderten5497 5 жыл бұрын
Thank you very much.its a great tutorial as always
@chandansarkar1123
@chandansarkar1123 5 жыл бұрын
We can not thank you enough..still thanks a ton Corey. I have an interesting observation @9.48. In the plt.xticks(...) method when I use the ticks and labels keywords it gives me AttributeError. It works when I pass the arguments without using keywords. Perhaps it has something to do with my Matplotlib version...
@nikhiledu7556
@nikhiledu7556 5 жыл бұрын
Same happened with me
@asas-jf5iz
@asas-jf5iz 4 жыл бұрын
yes, some old version matplotlib will have this problem.
@kabongontumba9492
@kabongontumba9492 3 жыл бұрын
Thank you guy, I had the same problem
@questscape
@questscape 4 жыл бұрын
For PANDAS folks:- import pandas as pd from collections import Counter df = pd.read_csv('data.csv', index_col=['Responder_id']) language_counter = Counter() for response in df['LanguagesWorkedWith']: language_counter.update(response.split(';'))
@abhishek_raj
@abhishek_raj 3 жыл бұрын
just a suggestion for people with large samples, Use seaborn style, this 538 gets screwed when number of labels is more.
@FerdinandCoding
@FerdinandCoding 4 жыл бұрын
thank you for python tutorial
@DeepakKumar-uz4xy
@DeepakKumar-uz4xy 5 жыл бұрын
thank you professor. love from india. u know what i dont like to read those documentation. when i saw your videos.
@lillyclive2641
@lillyclive2641 4 жыл бұрын
Such a great help, thankyou so much!
@DidaKusAlex
@DidaKusAlex 2 жыл бұрын
great tutorial! the best!! thanks for teaching us!
@rnytpl
@rnytpl 3 жыл бұрын
Thank you man, appreciate the effort and time you've put in creating such amazing content as these.
@guyindisguise
@guyindisguise 4 жыл бұрын
At 9:30 you correct the numbers of the x-axis with plt.xticks() Couldn't we just have circumvented that problem by saying x_indexes = np.array(ages_x) instead of x_indexes = np.arange(len(ages_x)) Since that would have given us an array with the original numbers that we could add/subtract the width to/from? Is there any benefit to the plt.xticks() solution (other than seeing how xticks work)?
@johannesherbert4943
@johannesherbert4943 4 жыл бұрын
I thought the exact same thing, why is he making his life more complicated than necessary? There is no problem with adding/subtracting offsets directly from the ages np.array, it just works. It makes it less hacky, too.
@tongliu1076
@tongliu1076 4 жыл бұрын
Great video as always! Really helpful for detailed explanation.
@johnjones5659
@johnjones5659 4 жыл бұрын
Thanks you and Brilliant
@shazkingdom1702
@shazkingdom1702 5 жыл бұрын
This is the best Corey; Thank you very much from my 🧠 and ❣
@rajivswargiary1536
@rajivswargiary1536 5 жыл бұрын
Great tutorial sir
@rahulp1985
@rahulp1985 3 жыл бұрын
How to have the percentage values also listed along the Y-axis with language names as shown in the plot in the stackoverflow website (towards the end of the video)
@VishalSharma-rn7mt
@VishalSharma-rn7mt 4 жыл бұрын
Great, amazing video
@Martin-ij2fp
@Martin-ij2fp 3 жыл бұрын
Great video!
@hatemsabrey
@hatemsabrey 4 жыл бұрын
Corey, my online teacher, where is the counter video ??? million thanks for your efforts
@randiarisman2419
@randiarisman2419 4 жыл бұрын
Another great video form you, Corey. Thank you, you made my day everyday!!
@OT-tn7ci
@OT-tn7ci 2 жыл бұрын
it might be a better idea to reverse the list of tuples inside the for loop or before that hehe. Also thanks for pointing out the inline zip function, its much easier for my eyes. Thanks a lot
@timeforrice
@timeforrice 4 жыл бұрын
could you do more videos about data cleaning? Thank you and I love your blog.
@emmanueljimawo5595
@emmanueljimawo5595 5 жыл бұрын
Great videos. I'm so grateful...
Matplotlib Tutorial (Part 3): Pie Charts
17:02
Corey Schafer
Рет қаралды 155 М.
Matplotlib Tutorial (Part 1): Creating and Customizing Our First Plots
35:01
How I Did The SELF BENDING Spoon 😱🥄 #shorts
00:19
Wian
Рет қаралды 36 МЛН
小丑把天使丢游泳池里#short #angel #clown
00:15
Super Beauty team
Рет қаралды 45 МЛН
This Is Why Python Data Classes Are Awesome
22:19
ArjanCodes
Рет қаралды 801 М.
Matplotlib Tutorial (Part 4): Stack Plots
14:49
Corey Schafer
Рет қаралды 108 М.
Pydantic Tutorial • Solving Python's Biggest Problem
11:07
pixegami
Рет қаралды 264 М.
I've been using Redis wrong this whole time...
20:53
Dreams of Code
Рет қаралды 353 М.
Matplotlib Full Python Course - Data Science Fundamentals
1:02:41
NeuralNine
Рет қаралды 132 М.
25 Nooby Pandas Coding Mistakes You Should NEVER make.
11:30
Rob Mulla
Рет қаралды 267 М.
How To Make Your Matplotlib Bar Charts Stand Out
19:59
Andy McDonald
Рет қаралды 1,6 М.
Matplotlib Tutorial (Part 6): Histograms
16:36
Corey Schafer
Рет қаралды 185 М.