In this article, we will discuss how to select a single column of data as a Series in Pandas.
For example, Suppose we have a data frame : Name Age MotherTongue Akash 21 Hindi Ashish 23 Marathi Diksha 21 Bhojpuri Radhika 20 Nepali Ayush 21 Punjabi
Now when we select column Mother Tongue as a Series we get the following output:
Hindi Marathi Bhojpuri Nepali Punjabi
Now let us try to implement this using Python:
Step1: Creating data frame:
Step 2: Selecting Column using dataframe.column name:
Step 3: Selecting column using dataframe[column_name]
In the above two examples we have used pd.Series() to select a single column of a data frame as a series.
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course