Python | Pandas Series.str.encode() Last Updated : 27 Mar, 2019 Comments Improve Suggest changes Like Article Like Report Series.str can be used to access the values of the series as strings and apply several methods to it. Pandas Series.str.encode() function is used to encode character string in the Series/Index using indicated encoding. Equivalent to str.encode(). Syntax: Series.str.encode(encoding, errors='strict') Parameter : encoding : str errors : str, optional Returns : encoded : Series/Index of objects Example #1: Use Series.str.encode() function to encode the character strings present in the underlying data of the given series object. Use 'raw_unicode_escape' for encoding. Python3 # importing pandas as pd import pandas as pd # Creating the Series sr = pd.Series(['New_York', 'Lisbon', 'Tokyo', 'Paris', 'Munich']) # Creating the index idx = ['City 1', 'City 2', 'City 3', 'City 4', 'City 5'] # set the index sr.index = idx # Print the series print(sr) Output : Now we will use Series.str.encode() function to encode the character strings present in the underlying data of the given series object. Python3 # use 'raw_unicode_escape' encoding result = sr.str.encode(encoding = 'raw_unicode_escape') # print the result print(result) Output : As we can see in the output, the Series.str.encode() function has successfully encoded the strings in the given series object. Example #2 : Use Series.str.encode() function to encode the character strings present in the underlying data of the given series object. Use 'punycode' for encoding. Python3 # importing pandas as pd import pandas as pd # Creating the Series sr = pd.Series(['Mike', 'Alessa', 'Nick', 'Kim', 'Britney']) # Creating the index idx = ['Name 1', 'Name 2', 'Name 3', 'Name 4', 'Name 5'] # set the index sr.index = idx # Print the series print(sr) Output : Now we will use Series.str.encode() function to encode the character strings present in the underlying data of the given series object. Python3 # use 'punycode' encoding result = sr.str.encode(encoding = 'punycode') # print the result print(result) Output : As we can see in the output, the Series.str.encode() function has successfully encoded the strings in the given series object. Comment More infoAdvertise with us Next Article Python | Pandas Series.str.encode() S Shubham__Ranjan Follow Improve Article Tags : Python Pandas Python-pandas Python-pandas-series-str AI-ML-DS With Python +1 More Practice Tags : python Similar Reads Python | Pandas Series.str.decode() Series.str can be used to access the values of the series as strings and apply several methods to it. Pandas Series.str.decode() function is used to decode character string in the Series/Index using indicated encoding. This function is equivalent to str.decode() in python2 and bytes.decode() in pyth 2 min read Python | Pandas Series.str.len() 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.len() method is used to determine length of each string in a Pandas series. 3 min read Python | Pandas Series.str.index() 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.index() method is used to search and return lowest index of a substring in 3 min read Python | Pandas Series.str.center() Series.str can be used to access the values of the series as strings and apply several methods to it. Pandas Series.str.center() function is used for filling left and right side of strings in the Series/Index with an additional character. The function is equivalent to Python's str.center(). Syntax: 3 min read Python | Pandas series.str.get() 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.get() method is used to get element at the passed position. This method wor 3 min read Python | Pandas Series.str.pad() 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 provide a method to add padding (whitespaces or other characters) to every stri 4 min read Python | Pandas Index.to_series() 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 Index.to_series() function create a Series with both index and values equal to 2 min read Python | Pandas Series.str.extract() Series.str can be used to access the values of the series as strings and apply several methods to it. Pandas Series.str.extract() function is used to extract capture groups in the regex pat as columns in a DataFrame. For each subject string in the Series, extract groups from the first match of regul 4 min read Python | Pandas Series.to_csv() Pandas series is a One-dimensional ndarray with axis labels. The labels need not be unique but must be a hashable type. The object supports both integer- and label-based indexing and provides a host of methods for performing operations involving the index. Pandas Series.to_csv() function write the g 3 min read Python | Pandas Series.str.isdecimal() 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 isdecimal() is used to check whether all characters in a string are decimal. Th 2 min read Like