Python | Панды Series.asobject
Python - отличный язык для анализа данных, в первую очередь из-за фантастической экосистемы пакетов Python, ориентированных на данные. Pandas - один из таких пакетов, который значительно упрощает импорт и анализ данных.
Pandas Series.asobject attribute returns an array of object data type. It converts the series data into an array of object type.
Syntax:Series.asobject
Parameter : None
Returns : array of objects
Example #1: Use Series.asobject attribute to return object series containing boxed value for the given Series object.
# importing pandas as pdimport pandas as pd # Creating the Seriessr = pd.Series(["First", "Second", "Third", "Fourth"]) # Print the seriesprint(sr) |
Выход :

Now we will use Series.asobject attribute to convert the series into an array of object type.
# to return the series as objectsr.asobject |
Выход :

As we can see in the output, the Series.asobject attribute has successfully returned an array of objects.
Example #2 : Use Series.asobject attribute to return object series containing boxed value for the given Series object.
# importing pandas as pdimport pandas as pd # Creating the Seriessr = pd.Series(["Sam", 21, "Alisa", 18, "Sophia", 19, "Max", 17]) # Print the seriesprint(sr) |
Выход :

Now we will use Series.asobject attribute to convert the series into an array of object type.
# to return the series as objectsr.asobject |
Выход :

As we can see in the output, the Series.asobject attribute has successfully returned an array of objects.
Внимание компьютерщик! Укрепите свои основы с помощью базового курса программирования Python и изучите основы.
Для начала подготовьтесь к собеседованию. Расширьте свои концепции структур данных с помощью курса Python DS. А чтобы начать свое путешествие по машинному обучению, присоединяйтесь к курсу Машинное обучение - базовый уровень.