Slicing and Dicing a Pandas DataFrame
In this lesson you’ll learn how you can remove columns from a Pandas DataFrame, which are not important for your analysis.
00:00 We have a bunch of data here. Not all of it is particularly useful, like, we always know that Kevin Durant in 2012 and 2013 played for OKC, so we don’t need to worry about this team and we really don’t care about who they’re playing against and whether they’re away or not. In this particular set, I’m interested in a few other things. Things like opponent are needed.
00:20
So I’m going to go ahead and delete those columns. All you do is simply call del
, the DataFrame
, and then the key for the column that you want to delete, and that’ll remove it from the dataset and we won’t have to deal with it anymore. So, as you can see here,
00:35
we have a more manageable dataset. I’m actually going to get rid of our "Win/Lose"
one as well, because I’m not interested in that as well either. We’re just looking particularly at Kevin Durant and when he does badly and when he does well. So we’re going to go ahead and do that. As you can see, we’ve moved the win/loss column from the dataset.
00:55 Let’s go ahead and see if we can get some averages on how many points per minute Kevin Durant scores. That’ll require us to look at minutes played and field goals scored.
01:06 Maybe you might be interested in how many shots he takes in a minute, which might be interesting. We’re going to do that next.
Sathia on March 24, 2024
hi Mahdi, I get this message and no output not sure whats wrong <IPython.core.display.HTML object>
Become a Member to join the conversation.
thamizhselvan on Aug. 8, 2019
Hi all,
I ran python script which pull all our network device connected ports and saved into csv. I m want to convert this csv file to html file so that people can easily read.
Can you help me out on this.
Many thanks.