![]() |
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. Pandas .str has to be prefixed every time before calling this method to differentiate it from the Python’s default string method.
To download the Csv file used, 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. Example #1: Joining string elements In this example, the str.join() method is used on Name column (Series of String). As discussed earlier, a string is also an array of character and hence every character of string will be joined with the passed separator using str.join() method.
Output: In this example, the str.join() method is applied to a series of list. The Data in team column is separated into list using str.split() method.
Output: Dataframe after splitting – DataFrame after joining list – |
Reffered: https://www.geeksforgeeks.org
Python |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 9 |