How do I rename columns in a pandas DataFrame?

  Рет қаралды 149,372

Data School

Data School

8 жыл бұрын

You will often want to rename the columns of a DataFrame so that their names are descriptive, easy to type, and don't contain any spaces. In this video, I'll demonstrate three different strategies for renaming columns so that you can choose the best strategy to fit your particular situation.
SUBSCRIBE to learn data science with Python:
kzbin.info?su...
JOIN the "Data School Insiders" community and receive exclusive rewards:
/ dataschool
== RESOURCES ==
GitHub repository for the series: github.com/justmarkham/pandas...
"rename" documentation: pandas.pydata.org/pandas-docs/...
"read_csv" documentation: pandas.pydata.org/pandas-docs/...
"str.replace" documentation: pandas.pydata.org/pandas-docs/...
== LET'S CONNECT! ==
Newsletter: www.dataschool.io/subscribe/
Twitter: / justmarkham
Facebook: / datascienceschool
LinkedIn: / justmarkham

Пікірлер: 328
@dataschool
@dataschool 6 жыл бұрын
Starting in pandas version 0.21 (released October 2017), you can rename columns using a "mapper" along with the "axis", similar to how you specify which columns you want to drop. Learn more in my latest video, "5 new changes in pandas you need to know about": kzbin.info/www/bejne/qpaYe6WJeLxggrs
@NitinSaseendran
@NitinSaseendran 6 жыл бұрын
Thanks for your amazing videos. It helped me a lot.
@dataschool
@dataschool 6 жыл бұрын
You're very welcome!
@IncredibleGrim
@IncredibleGrim 4 жыл бұрын
2:05 why are names like u'City' instead of just 'City'?
@xyxyirish
@xyxyirish 5 жыл бұрын
You are a good, kind man. One day people are going to write poems about you.
@dataschool
@dataschool 5 жыл бұрын
HA! Thank you :)
@user-mx8pn1ky5s
@user-mx8pn1ky5s 5 жыл бұрын
Great teacher. I could not find an explanation for all this nuance in my own language. And here is a gift. Thank you so much, I am waiting for any of your lessons on the channel.
@dataschool
@dataschool 5 жыл бұрын
Thank you so much! Have you seen my latest pandas tutorial? kzbin.info/www/bejne/moHafZ-AoLh7gtE
@AlexanderMoen
@AlexanderMoen 4 жыл бұрын
Thank you, man. I've been searching forever for this seemingly simple thing, and minute 1-3 did it for me. Thanks again.
@dataschool
@dataschool 3 жыл бұрын
Awesome!
@nikhilkorra5712
@nikhilkorra5712 4 жыл бұрын
During this Quarantine, thought to gain a new skill but fortunately, I got the best tutor. Thank you, Sir.
@Elias-ce3ze
@Elias-ce3ze 5 жыл бұрын
Hello, I am from Brazil and I'm usually write my codes in Fortran and Matlab. However I've decided to learn python. Your channel is amazing, it is clear and easy to understand and straight to the goal. Congratulations !!!!
@dataschool
@dataschool 5 жыл бұрын
Awesome! Thanks so much for your kind words!
@felipecaannavarro5441
@felipecaannavarro5441 4 жыл бұрын
Opa conterrâneo (=-) Estou começando a aprender programação e estou muito ansioso para fazer aqueles projetos massa com pandas e matplotlib 00 TAMU JUNTO!! BORA FICAR RICO!! kkk
@ramlabasharat4334
@ramlabasharat4334 5 жыл бұрын
best tutorials on youtube... your all videos are really informative and easy to understand. I'm watching continuously but didn't get bored. your way of teaching is really awesome
@dataschool
@dataschool 5 жыл бұрын
Thanks so much, I really appreciate it! :)
@mokhadra9289
@mokhadra9289 8 жыл бұрын
That bonus worth the whole 9 minutes :) you are ROCK ... thank you :D
@dataschool
@dataschool 8 жыл бұрын
Awesome! You're welcome!
@nilewilliams9613
@nilewilliams9613 3 жыл бұрын
Incredible tutor, definitely going to watch the entire series.
@dataschool
@dataschool 3 жыл бұрын
Great to hear!
@anantgupta305
@anantgupta305 4 жыл бұрын
Bro u are simply awesome, you dont know how much of my time u saved and made everything so simple
@syedramishhussain5362
@syedramishhussain5362 4 жыл бұрын
short and to the point, was v helpful! Thank you
@tanned_cosines_
@tanned_cosines_ 3 жыл бұрын
helped a lot, this playlist; you've provided multiple ways to do a single task thanks a lot
@dataschool
@dataschool 3 жыл бұрын
Glad it was helpful!
@fet1612
@fet1612 5 жыл бұрын
I found the Data School's videos to be super helpful for beginners or absolute beginners alike. One thing every learner needs to do is PRACTICE ALONG as Kevin of Data School walks them through each ITEM of EACH video. PAUSE and PRACTICE, PAUSE and PRACTICE, PAUSE and PRACTICE. This way you will be surprised how fast this PAUSE and PRACTICE exercise elevates your rate of understanding. I experimented with the THEMATICS employing this PEDAGOGY, and it worked WONDERS. Data School short videos are most helpful and my most favorite. In an hour-long video, your study material might GET BURIED in HEAPs. But here, you can easily LOCATE your MATERIAL. Good luck with anyone learning at DATA SCHOOL, and BECOME DATA SCIENTISTS of the FUTURE.
@dataschool
@dataschool 5 жыл бұрын
Thanks so much for your kind words!
@yucelozyazgan
@yucelozyazgan 7 жыл бұрын
Simply, he is a great tutor !
@dataschool
@dataschool 7 жыл бұрын
Thanks!
@travelogue.brothers
@travelogue.brothers Жыл бұрын
how everything you teach gets stored in the brain library. can import what you have taught anytime. I am a begineeer to data science and the way you teach topi by topic it is so smooth and satisfying to learn. Thanks a lot
@dataschool
@dataschool Жыл бұрын
Thanks very much for your kind words!
@mohamedel-gazzar5818
@mohamedel-gazzar5818 3 жыл бұрын
This dude is the man. You have helped me soooo much you have no idea!
@dataschool
@dataschool 3 жыл бұрын
🙌
@mahnoorafridi9872
@mahnoorafridi9872 3 жыл бұрын
Best tutor I ever had ,you did a great job
@dataschool
@dataschool 3 жыл бұрын
Wow, thanks!
@nataliaagudelo8635
@nataliaagudelo8635 5 жыл бұрын
All of your videos are amazing, thank you again!
@dataschool
@dataschool 5 жыл бұрын
Thanks!
@bhavyakothari635
@bhavyakothari635 5 жыл бұрын
Simple and easy to understand. You are the best !!! :))
@dataschool
@dataschool 5 жыл бұрын
Thanks so much! :)
@samiagharib3796
@samiagharib3796 3 жыл бұрын
Thanks for the tutorial especially the bonus tip .
@dataschool
@dataschool 3 жыл бұрын
Glad it was helpful!
@satyamagrawal1191
@satyamagrawal1191 5 жыл бұрын
Your bonus tips are awesome!
@dataschool
@dataschool 5 жыл бұрын
Thanks!
@airevancarmen
@airevancarmen 5 жыл бұрын
very simple and complete overview of methods!
@dataschool
@dataschool 5 жыл бұрын
Thanks!
@shankeybharadwaj1561
@shankeybharadwaj1561 4 жыл бұрын
Awesome video lectures... For the bonus tip , I used ufo.columns = list(map(lambda s:s.replace(' ','_') , ufo.columns))
@maikeruschannel9002
@maikeruschannel9002 Жыл бұрын
Great video. Really helpful for beginners
@dataschool
@dataschool Жыл бұрын
Thank you!
@s.baskaravishnu22
@s.baskaravishnu22 7 жыл бұрын
I very much congratulate you for sharing code used in video with us. Many thanks for that. It is very much useful to me. My warm regards to you.
@dataschool
@dataschool 7 жыл бұрын
Glad to hear that it is useful to you! All of the code from this video series can be found in the following notebook: nbviewer.jupyter.org/github/justmarkham/pandas-videos/blob/master/pandas.ipynb
@akira_asahi
@akira_asahi Жыл бұрын
Thank you for the video. I am grateful for your time and contribution. Kind regards, Akira.
@dataschool
@dataschool Жыл бұрын
You're welcome!
@rainfrog4116
@rainfrog4116 7 жыл бұрын
Another great video! Thank you, Kevin!
@dataschool
@dataschool 7 жыл бұрын
You're very welcome! Thanks for your comment.
@TR3NDSETR
@TR3NDSETR 4 жыл бұрын
Fabulous, and on to the next.
@dataschool
@dataschool 4 жыл бұрын
Thank you!
@pranitgandhi6832
@pranitgandhi6832 5 жыл бұрын
Where were you?? If I had found you earlier my job would have been so easy. Nevertheless, you have done a world of good to me. Thanks a lot for saving my time on reading this stuff from books.
@dataschool
@dataschool 5 жыл бұрын
That's so kind of you to say! I really appreciate it 😊
@jordiblanco5223
@jordiblanco5223 7 жыл бұрын
Many thanks for the tutorials. Great job!
@dataschool
@dataschool 7 жыл бұрын
You're very welcome!
@jaquesderasmo5496
@jaquesderasmo5496 4 жыл бұрын
You are the best man. Thank you
@dataschool
@dataschool 4 жыл бұрын
Thank you!
@jongcheulkim7284
@jongcheulkim7284 3 жыл бұрын
Thank you so much. This is very helpful.
@dataschool
@dataschool 3 жыл бұрын
Great to hear! 🙏
@robindong3802
@robindong3802 6 жыл бұрын
Very detailed lesson. thank you!
@dataschool
@dataschool 6 жыл бұрын
You're welcome!
@juanmoctezuma9225
@juanmoctezuma9225 3 жыл бұрын
awesome tutorial thanks!
@leojames22
@leojames22 6 жыл бұрын
This is very useful video. Thanks for sharing. Well explained as well.
@dataschool
@dataschool 6 жыл бұрын
You're welcome!
@cutedevil069
@cutedevil069 6 жыл бұрын
Best Tutorial ever
@dataschool
@dataschool 6 жыл бұрын
Thanks!
@sameeral-janabi5966
@sameeral-janabi5966 4 жыл бұрын
Thank you .... excellent information.
@jingchu4629
@jingchu4629 6 жыл бұрын
Thanks for the awesome tutorial!
@dataschool
@dataschool 6 жыл бұрын
You're welcome!
@isaiaspereira2796
@isaiaspereira2796 4 жыл бұрын
Dude, you are awesome!!!
@dataschool
@dataschool 4 жыл бұрын
Thank you!
@riteshsingh118
@riteshsingh118 2 жыл бұрын
Love your work ❤️❤️❤️
@dataschool
@dataschool 2 жыл бұрын
Thank you!
@void2258
@void2258 8 жыл бұрын
I was typing out your bonus question to ask it just as you got to it.
@dataschool
@dataschool 8 жыл бұрын
+Elliot Jenner Ha! Great :)
@joescanlon7502
@joescanlon7502 8 жыл бұрын
ha - i had the exact same query!
@observer_1983
@observer_1983 7 жыл бұрын
super, clear and helpful
@dataschool
@dataschool 7 жыл бұрын
Great! Thanks for your kind words.
@dishonfano7599
@dishonfano7599 5 жыл бұрын
Great job man...
@dataschool
@dataschool 5 жыл бұрын
Thanks!
@ramakanthrayanchi8888
@ramakanthrayanchi8888 8 жыл бұрын
Excellent video. Cheers :) :)
@dataschool
@dataschool 8 жыл бұрын
Thanks! :)
@mauricioluisvega3137
@mauricioluisvega3137 Жыл бұрын
VERY CLEAR!!!!. I hope you are OK!. take care. bYe.!
@dataschool
@dataschool Жыл бұрын
Thanks!
@phuccoiinkorea3341
@phuccoiinkorea3341 7 жыл бұрын
Easy to a person bad English like me! Thank so much!
@dataschool
@dataschool 7 жыл бұрын
You're very welcome!
@jeanaimegakwerere5359
@jeanaimegakwerere5359 9 ай бұрын
Thank you Sir.
@dataschool
@dataschool 9 ай бұрын
You're welcome!
@komaljaswani7497
@komaljaswani7497 3 жыл бұрын
awesome video as usual :D
@dataschool
@dataschool 3 жыл бұрын
Thanks again!
@ankhts
@ankhts 3 жыл бұрын
Thank you for all the videos.It provides almost all fundamental operations that can be done on Data frames. What understood from this video is that df.columns is used as series along the row 0.Can we do similar thing along column 0 (i.e. index column ) and apply similar operations ? Many thanks
@dharmendra811
@dharmendra811 6 жыл бұрын
nice to have these videos, helping me alot...would you please make on video to add existing dataframe to predefined worksheet.
@dataschool
@dataschool 6 жыл бұрын
Do you mean an Excel worksheet?
@dharmendra811
@dharmendra811 6 жыл бұрын
Yes.
@dataschool
@dataschool 6 жыл бұрын
Great, thanks for the suggestion!
@09january
@09january 4 жыл бұрын
Great stuff
@dataschool
@dataschool 4 жыл бұрын
Thanks!
@ashhvinikamble-gaikwad8623
@ashhvinikamble-gaikwad8623 3 жыл бұрын
Thank you so much...
@suren6885
@suren6885 3 жыл бұрын
Brilliant stuff
@dataschool
@dataschool 3 жыл бұрын
Thanks!
@burakbey21
@burakbey21 4 жыл бұрын
Great video
@dataschool
@dataschool 4 жыл бұрын
Thanks!
@Abo7amoElmasony
@Abo7amoElmasony 2 жыл бұрын
Thank you sir
@dataschool
@dataschool 2 жыл бұрын
You're welcome!
@lukerengel8533
@lukerengel8533 7 жыл бұрын
When you renamed the columns to all be lower case by first creating a list and then assigning that list to your df.columns object you could also use your tip at the end to do df.columns = df.columns.str.lower() to get the same result in one line of code.
@dataschool
@dataschool 7 жыл бұрын
Great suggestion, thank you!
@AshishSahu25
@AshishSahu25 7 жыл бұрын
Thanks for the lucid explanation and bonus tips. I'm wondering using your last bonus tip code snippet, how would I replace or rename few columns' white spaces with underscore, without applying it on all.
@dataschool
@dataschool 7 жыл бұрын
Glad you liked the video! Regarding your question, my methodology would depend on the exact circumstances. There's not one obvious way to do what you are describing... sorry!
@terrancedejesus625
@terrancedejesus625 7 жыл бұрын
Great video! I would like to know how I can look for certain values in each row or column and then replace those values with a specific value. An example would be, for each cell in a dataframe where the Shape Reported is TRIANGLE and the State is NY, change the cell value in the City column to Buffalo. I hope that makes sense. Thank you!
@dataschool
@dataschool 7 жыл бұрын
You can definitely do that. Try watching these two videos (in order), and see if you are able to figure out: kzbin.info/www/bejne/rqfTf3Rtl6hrmdU kzbin.info/www/bejne/aoOXiKZ6f5J-jMU Let me know if that helps! :)
@assafcohen3173
@assafcohen3173 2 жыл бұрын
I was looking for a way to easily replace column names using regex and got lost in an endless stack overflow loop - thanks for providing an easy solution.
@dataschool
@dataschool 2 жыл бұрын
You're welcome!
@didierleprince6106
@didierleprince6106 4 жыл бұрын
Bravissimo ! Merci (:
@dataschool
@dataschool 3 жыл бұрын
You're welcome!
@salayhin
@salayhin 8 жыл бұрын
Following line will lowercase the column name and replace space with underscore: ufo.columns = ufo.columns.str.lower().str.replace(' ', '_')
@dataschool
@dataschool 8 жыл бұрын
Indeed it will! The chaining together of multiple string methods is often useful.
@annayakovleva6983
@annayakovleva6983 4 жыл бұрын
Thank you for this! I was just wondering how to save the newly formatted column names to the df!
@tapas511
@tapas511 6 жыл бұрын
Great ! session
@dataschool
@dataschool 6 жыл бұрын
Thanks for your kind comments!
@IBRAHIMDEMIREZ
@IBRAHIMDEMIREZ Жыл бұрын
Hi Kevin! Your videos are really helpful and very informative, my question is how am i suppose to rename column name on the base of condition? I mean df.columns = df.iloc[16] . row 16 has some NaN values so only for these case I want pd take value from row 17. Thank you!
@ish694
@ish694 7 жыл бұрын
Hey man ! Loving this series. Just one question. How do you remember all these commands and functions and where to put where ? i am new to coding and so i keep forgetting what the commands were. :/
@dataschool
@dataschool 7 жыл бұрын
I hear you! It's easy to forget when you are getting started. I just remember them more and more over time! Plus, I make cheat sheets for myself like this: nbviewer.jupyter.org/github/justmarkham/pandas-videos/blob/master/pandas.ipynb
@ish694
@ish694 7 жыл бұрын
Thanks a lot :D I think these will do the work
@pankajnagpal3110
@pankajnagpal3110 6 жыл бұрын
Great man !! I like it. Can you create one video on juptyr notebook with shortcuts ... i am new to python
@dataschool
@dataschool 6 жыл бұрын
Great suggestion! I'll see what I can do :)
@aidaa.5953
@aidaa.5953 6 жыл бұрын
Thank you!
@dataschool
@dataschool 6 жыл бұрын
You're welcome!
@valeriapir1268
@valeriapir1268 5 жыл бұрын
Your tutorials are just great! Thank you for that!! One question: Is it possible to change the cells depending on its content? I mean, if we see "ABC12" in cell that should be renamed with "Sample"? Thank you in advance! :)
@dataschool
@dataschool 5 жыл бұрын
You could use the map or replace methods to do that, I think!
@valeriapir1268
@valeriapir1268 5 жыл бұрын
Thanks to your tutorials i start my journey with Python language!
@sdoken
@sdoken 7 жыл бұрын
If I have column labels that are of time datetime, and I want to convert them to strings, how can I do that? Without using a loop. (I already figured out how to do it with a loop by using the rename function at each iteration) Thanks!
@dataschool
@dataschool 7 жыл бұрын
This should work: df.column_name.astype(str)
@abhishekp9423
@abhishekp9423 6 жыл бұрын
Hi Kevin, Thanks for the awesome videos on Panda . In the second method to rename columns , we have to be cautious about the sequence in which the original name of the column has.Right??
@dataschool
@dataschool 6 жыл бұрын
Right!
@abhishekp9423
@abhishekp9423 6 жыл бұрын
Thanks Sir
@DennisAllard
@DennisAllard 7 жыл бұрын
There are several ways to run Python in a command line REPL (read eval print loop). NOT all of them have the pretty format shown in these videos. And some have annoying screen width limitations and different behavior for TAB, ,shift-TAB, etc. To see the exact same GUI being used in in these videos I use: Anaconda Navigator > Jupyter > New > Notebook: Python3
@dataschool
@dataschool 6 жыл бұрын
Thanks for sharing!
@latifyanar2853
@latifyanar2853 4 жыл бұрын
Thank you ..
@dataschool
@dataschool 4 жыл бұрын
You're welcome!
@yandongbi1800
@yandongbi1800 7 жыл бұрын
Very grateful for your perfect contribution. I want to ask you what "header = 0" means.Look forward to your reply.
@dataschool
@dataschool 7 жыл бұрын
header=0 means that the first row (row zero) is contains the header information.
@subashkattel7033
@subashkattel7033 6 жыл бұрын
Kevin, you are doing great job with nice tutorials. Thanks. I have a question, how can we assign name to the series rather than renaming? Say I have 100 columns in a csv file with common index and header are empty(no names). Now I want to assign name to each column like P1, P2, ......P100. Can I do that?
@dataschool
@dataschool 6 жыл бұрын
The columns attribute of a DataFrame always has values, it is never empty. If you want to change those values, you could use a string method. Hope that helps!
@rhettsmedia
@rhettsmedia 4 жыл бұрын
Hi there this is the right place to do this when you paste in a line from your snippets please read the entire line character by character if possible for those of us with visual impairment we do not look at the screen but we must hear all the characters the same as with your URL secure paste in it was very hard to find that this was the I T.LY because we can’t really see the tail the Y from the eye thank you
@rajarshichowdhury8617
@rajarshichowdhury8617 3 жыл бұрын
I have a question whether you can suggest for a python and R course of data science
@alexandermuir8160
@alexandermuir8160 4 жыл бұрын
Excellent information provided. Qn: Can you use more than one DataFrame simultaneously? If so what is the protocol so the program does not confused as to which one it is using?
@dataschool
@dataschool 4 жыл бұрын
You reference DataFrames by name, that's all. Glad you liked the video!
@sdoken
@sdoken 7 жыл бұрын
Is that .str() method at the end of the video (bonus tip) a method of pandas Series or is it a method of string type in python? I am just curious about this. Thanks for the video.
@dataschool
@dataschool 7 жыл бұрын
You're welcome! 'str' is a namespace where pandas string methods are stored, and 'replace' is a Series method. It's designed to work similar to a Python string method, but it is actually implemented in pandas code. More information about string methods is here: kzbin.info/www/bejne/mKDJknZmfsieftE Hope that helps!
@chd9841
@chd9841 6 жыл бұрын
some of my variables have spaces and some have dots. I want to replace the spaces dots by underscore how can I do that in one code?
@dataschool
@dataschool 6 жыл бұрын
You could chain two str.replace operations together in the same line.
@sdoken
@sdoken 6 жыл бұрын
Thanks for the cool trick at 8:06 A question about this tip: How could we have known (without you telling us here) that we can call .str. method on ufo.columns here? >>> type(ufo.columns) returns pandas.core.indexes.base.Index object. You showed in another video that we can call .str. on pandas dataframes and linked us to pandas api which shows this under string handling. But I did not know you could run .str. method on ufo.columns because ufo.columns is not a dataframe object. I will appreciate your help!
@dataschool
@dataschool 6 жыл бұрын
I think I just figured out that string methods works on the columns attribute by trying it! I'm not sure if it's explicitly documented.
@maamounhajnajeeb209
@maamounhajnajeeb209 Жыл бұрын
Thanks
@dataschool
@dataschool Жыл бұрын
You're welcome!
@merumomo
@merumomo 8 жыл бұрын
I really like your tutorials. Thank you for all your work! When you get a chance, could you please do a demo for "if __name__ == "__main__"?
@dataschool
@dataschool 8 жыл бұрын
+merumomo Great idea! I'll see if I can cover that at some point.
@abdulwalikhanafridi1834
@abdulwalikhanafridi1834 Жыл бұрын
wonderful...
@dataschool
@dataschool Жыл бұрын
Thanks!
@elijahfalope3414
@elijahfalope3414 4 жыл бұрын
helpful af
@dataschool
@dataschool 4 жыл бұрын
Thanks!
@keerthiallam830
@keerthiallam830 7 жыл бұрын
Thanks for the video! While replacing the column names with .rename method, I am getting 'TypeError: 'set' object is not callable'. Could you please explain this?
@dataschool
@dataschool 7 жыл бұрын
I'm pretty sure you have a typo... could you check that you are typing the code exactly the same way?
@szamoransky
@szamoransky 5 ай бұрын
Does str.replace also have an inplace argument?
@saidul14319
@saidul14319 7 жыл бұрын
Thank You so much bro this is awesome !!! please let me know that how to change the columns position, like if a columns is in position columns[1] to columns[5]. how to do that ? and thanks again for this nice video.
@dataschool
@dataschool 7 жыл бұрын
Glad you like the videos! There are many options for reordering columns presented here: stackoverflow.com/questions/13148429/how-to-change-the-order-of-dataframe-columns
@frankowusu1260
@frankowusu1260 7 жыл бұрын
Do you have scipy, sympy and numpy videos too? i love your tutorials and would love to have tutorials on them too. and maybe scikit-learn
@dataschool
@dataschool 7 жыл бұрын
Thanks! I have a scikit-learn series: kzbin.info/aero/PL5-da3qGB5ICeMbQuqbbCOQWcS6OYBr5A I'm considering NumPy for the future. Stay tuned!
@ajaykushwaha4233
@ajaykushwaha4233 Жыл бұрын
Best video
@dataschool
@dataschool Жыл бұрын
Thanks!
@vaibhavdesai6998
@vaibhavdesai6998 5 жыл бұрын
How do we change data types of multiple columns from object to integer in a pandas dataframe? Do you have a video on this? If not could you please make one. That would be really helpful.
@dataschool
@dataschool 5 жыл бұрын
Great question! This video includes the answer: kzbin.info/www/bejne/Y3_Fimp7bs1-rs0m45s
@NicatBehbudov
@NicatBehbudov 6 жыл бұрын
Amazing videos. One questions please. Doest the term DataFrame correspond to specific kind of a table? Or it is just a table like ufo or chipotleorders or something else? I see you use the term a lot in your videos. Why don't you just say 'table'? Thanks!
@dataschool
@dataschool 6 жыл бұрын
A DataFrame is a specific type of pandas object, that contains tabular data. You might like to see this video: kzbin.info/www/bejne/a5C0iYCtmt-DgKc
@Dheerashrm13
@Dheerashrm13 3 жыл бұрын
sir pls make a video on latest changes on Pandas if possible for you.
@dataschool
@dataschool 3 жыл бұрын
Thanks for your suggestion!
@gokulkannan788
@gokulkannan788 4 жыл бұрын
How do we make our DataFrame or table representation in our jupyter notebook look like yours - with borders? :) We get tables without any borders only.
@ChartExplorers
@ChartExplorers 3 жыл бұрын
Sometimes when you use print() the table will not have borders. You can also put this into any cell and you should get borders. %%HTML table.dataframe td, table.dataframe th { border: 1px black solid !important; color: black !important; }
@mohitseventeen
@mohitseventeen 3 жыл бұрын
How can we use the way explained at 4:40 but in method chaining way.
@ChandraShekhar-ds8cp
@ChandraShekhar-ds8cp 4 жыл бұрын
Hey! How can we rename column names using assign function or replace function? Is that even possible? Thanks in Adv
@ChartExplorers
@ChartExplorers 3 жыл бұрын
df.columns = df.columns.str.replace('what you are replacing', 'what you want it replaced with') See 3:25 kzbin.info/www/bejne/bJatnYWMrsx4g80
@vivektiwari3459
@vivektiwari3459 7 жыл бұрын
Can we create a transition table and use the translate method instead of replace?
@dataschool
@dataschool 7 жыл бұрын
I've never used the translate method in pandas, but it looks like translate is for character-by-character translation, so it wouldn't be appropriate in this case.
@vivektiwari3459
@vivektiwari3459 7 жыл бұрын
I tried using translate method on a data set to replace ' ' with '_' and '-' with '_' and it worked in a single line of code. Though you are right it would not be appropriate in this case and not likely to be of significant use in any other case, I guess. Thanks for the video series.
@dataschool
@dataschool 7 жыл бұрын
You're welcome!
@varunupadhyay3836
@varunupadhyay3836 7 жыл бұрын
Hi Kevin, Does header=0 and header=None means the same as they both are producing the same results?
@dataschool
@dataschool 7 жыл бұрын
Actually, header=0 means that row 0 of the file is the header row, whereas header=None means that there is no header row in the file. Does that help?
@varunupadhyay3836
@varunupadhyay3836 7 жыл бұрын
Yes. Sorts things out. Thanks
@salq6585
@salq6585 5 жыл бұрын
How to create data structure for my dataset? Note : I opened the data in the same way you did it but I want to help creating the data structure like dictionary. Thanks
@dataschool
@dataschool 5 жыл бұрын
I'm sorry, I don't understand your question. Could you clarify? Thanks!
@rohiniik
@rohiniik 2 жыл бұрын
can u plz tell me how to anonymize data
@kevincarrasco5187
@kevincarrasco5187 5 жыл бұрын
Hi what if the dataframe doesn't have a name in columns how can I give names for the first time ??? Thanks
@dataschool
@dataschool 5 жыл бұрын
You can overwrite the columns attribute.
@merumomo
@merumomo 8 жыл бұрын
Hi! I got a question. How do you undo the changes? How do you change the column names back to what they were before.
@dataschool
@dataschool 8 жыл бұрын
If you use the "inplace=True" parameter, the changes are permanent, and there is no undo. If you use "inplace=False" (the default), then the change is only temporary. I have a video about inplace coming out on Tuesday!
@merumomo
@merumomo 8 жыл бұрын
+Data School ok. cool. thank you!
How do I remove columns from a pandas DataFrame?
6:36
Data School
Рет қаралды 137 М.
How do I select multiple rows and columns from a pandas DataFrame?
21:47
Русалка
01:00
История одного вокалиста
Рет қаралды 5 МЛН
Looks realistic #tiktok
00:22
Анастасия Тарасова
Рет қаралды 98 МЛН
How do I use the MultiIndex in pandas?
25:01
Data School
Рет қаралды 172 М.
How do I filter rows of a pandas DataFrame by column value?
13:45
Data School
Рет қаралды 278 М.
How do I make my pandas DataFrame smaller and faster?
19:06
Data School
Рет қаралды 66 М.
Learn NUMPY in 5 minutes - BEST Python Library!
13:38
Python Programmer
Рет қаралды 832 М.
When should I use a "groupby" in pandas?
8:25
Data School
Рет қаралды 242 М.
Learning Pandas for Data Analysis? Start Here.
22:50
Rob Mulla
Рет қаралды 85 М.
How do I handle missing values in pandas?
14:28
Data School
Рет қаралды 196 М.