Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric Python packages. Pandas is one of those packages and makes importing and analyzing data much easier.
tolist() is used to convert a series to list. Initially the series is of type pandas.core.series.Series and applying tolist() method, it is converted to list data type.
Return type: Converted series into List
To download the data set used in following example, click here.
In the following examples, the data frame used contains data of some NBA players. The image of data frame before any operations is attached below.
In this example, the data type of Name column is stored in a variable. After that it is converted using tolist() method and again data type is stored and printed.
As shown in the output image, the data type was converted from Series to List. The output of salary_list was in list format.
- Python | pandas.map()
- Python | Pandas Timestamp.second
- Python | Pandas DataFrame.where()
- Python | Pandas Series.gt()
- Python | Pandas.CategoricalDtype()
- Python | Pandas Series.sem()
- Python | Pandas Index.max()
- Python | Pandas TimedeltaIndex.max
- Python | Pandas Index.min()
- Python | Pandas Series.agg()
- Python | Pandas DataFrame.ix[ ]
- Python | Pandas Series.dt.day
- Python | Pandas Series.take()
- Python | Pandas Series.lt()
- Python | Pandas.Categorical()
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.