Prerequisite: Creating views on Pandas DataFrame | Set – 1
Many times while doing data analysis we are dealing with a large data set has a lot of attributes. All the attributes are not necessarily equally important. As a result, we want to work with only a set of columns in the dataframe. For that purpose, let’s see how we can create views on the Dataframe and select only those columns that we need and leave the rest.
Given a Dataframe containing nba data, create views on it such that only desired columns are included.
Note : For link to the CSV file used in the code, click here
Solution #1: While reading the data from the csv file into Python, We can select all those columns that we want to read into the DataFrame.
Solution #2 : While reading the data from the csv file into Python, we can list all those columns that we do not want to read into the DataFrame. It is like dropping those columns.
Solution #3 : We can use the
difference() method to drop the columns that we do not need.
Now we will drop those columns which we do not need by using the
- Creating views on Pandas DataFrame
- Creating a Pandas dataframe using list of tuples
- Creating a Pandas DataFrame
- Python | Creating a Pandas dataframe column based on a given condition
- Creating a dataframe from Pandas series
- Creating Pandas dataframe using list of lists
- Python | Pandas DataFrame.fillna() to replace Null values in dataframe
- Pandas Dataframe.to_numpy() - Convert dataframe to Numpy array
- Convert given Pandas series into a dataframe with its index as another column on the dataframe
- Creating a dataframe using Excel files
- Python | Creating DataFrame from dict of narray/lists
- Creating a dataframe using CSV files
- Views In Django | Python
- Render a HTML Template as Response - Django Views
- Create View - Function based Views Django
- Update View - Function based Views Django
- Delete View - Function based Views Django
- List View - Function based Views Django
- Django CRUD (Create, Retrieve, Update, Delete) Function Based Views
- Createview - Class Based Views Django
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.