Pandas Series is a one-dimensional labeled array in Pandas that can hold data of any type, such as integers, floats, strings, booleans, and other objects. Pandas provides many methods and functions to perform various operations on Series. Here are some of the most common operations you can perform on a Pandas Series:
Create a Series: You can create a Pandas Series using the pd.Series() function and passing a Python list or NumPy array as input. For example:
import pandas as pd
s = pd.Series([10, 20, 30, 40])
print(s)
Access elements: You can access elements of a Series using indexing or slicing. For example:
print(s[0]) # Output: 10
print(s[1:3]) # Output: 20 30
Perform arithmetic operations: You can perform arithmetic operations on Series, such as addition, subtraction, multiplication, and division. For example:
s = s + 5
print(s) # Output: 15 25 35 45
Apply functions: You can apply various functions to a Series, such as sum(), mean(), max(), min(), and std(). For example:
print(s.sum()) # Output: 120
print(s.mean()) # Output: 30.0
print(s.max()) # Output: 45
Filtering: You can filter a Series based on a condition using boolean indexing. For example:
print(s[s == 35]) # Output: 35
Sorting: You can sort a Series by values using the sort_values() function. For example:
print(s.sort_values()) # Output: 15 25 35 45
Unique values: You can get the unique values in a Series using the unique() function. For example:
s = pd.Series(['apple', 'banana', 'cherry', 'apple', 'banana'])
print(s.unique()) # Output: ['apple' 'banana' 'cherry']
@ParagDhawan
Here
empty attribute
se = pd.Series()
print(se)
print(" is the object empty ")
print(se.empty)
axes attribute
s2 = pd.Series(np.random.rand(4),index=[11,12,13,14])
print(s2)
print("The axes are: ")
print(s2.axes)
How to get dimension of series
s = pd.Series([1,2,3,4,5], index=['a','b','c','d','e'])
print(s)
print('print the dimension of the object')
print(s.ndim)
How to get Size (Number of elements in Series)
s = pd.Series([1,2,3,4,5], index=['a','b','c','d','e'])
print(s)
print('print the size of object')
print(s.size)
How to get Actual Values of seires
print ('the actula data series is :')
print(s.values)
Getting top N elements of Series
print("Print the first two elemnts of the data series")
print(s.head(2))
Getting Last N elements of series
print("print the last two element of the data series")
print(s.tail(2))
=============================================================================
Link for Tutorial Series
Jupyter Notebook Tutorial Series:-
• How To Open Jupyter Notebook in Windows
Python Tutorial Series:-
• Introduction to Python | Python Applications
Python Assignments and Objective Questions:-
• Objective Questions Python - 1
Tech. Videos By Parag Dhawan;-
• Template Matching Using OpenCV (Python) | ...
Object-Oriented Programming in Python:-
• How to Create Class and Object in Python
File Handling in Python:-
• How to Create a file in Python | Python Fi...
Exception Handling in Python:-
• Exception Handling in Python
NumPy Tutorial Series:-
• NumPy
=============================================================================
Feel free to connect and ask your queries:-
Linkedin:- / parag-dhawan
Youtube:- / paragdhawan
Facebook Page:- http://fb.me/dhawanparag
Instagram: - / paragdhawan
Twitter:- / dhawan_parag
GitHub:- https://github.com/paragdhawan/
=============================================================================
Show your support by Subscribing to the channel:-
https://www.youtube.com/c/ParagDhawan...
=============================================================================
#ParagDhawan
#Pandas
#DataScience
#DataAnalysis
#PandasTutorial
#PandasCourse
#Python3
#Python
#PythonProgramming
============================================================
How to Record Your Screen and make a tutorial video or demo video: -
• How to Record Screen and Edit Video Using ...
============================================================
Информация по комментариям в разработке