Pandas Series #5
rubydamodar
started this conversation in
Show and tell
Replies: 1 comment
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
0. Introduction to Pandas and Pandas Series
Pandas Overview
pip install pandas
)Pandas Series Basics
1. Basics of Pandas Series
Creating a Pandas Series in More Detail
dtype
(e.g.,dtype=int64
,dtype=float32
)astype()
method)pd.Series([1, 2, 3, 4])
pd.Series({"a": 1, "b": 2})
pd.Series(np.array([1, 2, 3]))
pd.Series(5, index=[0, 1, 2, 3])
Index Customization
pd.Series([10, 20], index=[(2023, 'Q1'), (2023, 'Q2')])
Series Metadata
dtype
: Handling categorical, object, and mixed data typesDatetimeIndex
2. Data Operations in Pandas Series
Element-wise Operations and Broadcasting
series + 5
series1 + series2
(alignment by index)Advanced Mathematical Functions
skipna=True
)std()
,var()
)np.log(series)
,np.exp(series)
Function Application to Series
applymap()
for element-wise custom functions.apply()
for row-wise and element-wise operations, like:3. Indexing and Selection in Pandas Series
Position-based Indexing with
.iloc[]
series.iloc[2]
series.iloc[[0, 2, 4]]
series.iloc[2:5]
Label-based Indexing with
.loc[]
series.loc['a']
series.loc[['a', 'b', 'c']]
series.loc['a':'c']
Advanced Boolean Indexing
series[series > 10]
(series > 10) & (series < 20)
.where()
and.mask()
for conditional replacementsseries.where(series > 10, other=0)
4. Handling Missing Data in Series
Detecting Missing Data with More Detail
isnull()
,notnull()
)series.isnull().sum()
pd.NaT
for missing datetime dataAdvanced Techniques for Handling Missing Data
fillna(0)
fillna(method='ffill')
,fillna(method='bfill')
fillna(method='ffill', limit=1)
interpolate()
):series.interpolate(method='linear')
5. Series Indexing and Reindexing
Understanding the Index Object
series.index = new_index
series.reset_index()
Reindexing with Fine Control
series.reindex(['a', 'b', 'c'])
series.reindex(new_index, fill_value=0)
ffill
,bfill
):Set Operations on Index
series1.index.union(series2.index)
series1.index.intersection(series2.index)
series1.index.symmetric_difference(series2.index)
6. Series Alignment and Broadcasting
Series Alignment in Depth
series1 + series2
aligns data by index labelsBroadcasting Operations
7. Data Transformation in Series
Using Map for Value Mapping
map()
:Apply for More Advanced Operations
Sorting Operations
series.sort_index()
series.sort_values(ascending=False)
na_position='first'
8. Working with Time Series Data
Time Series Creation and Manipulation
DatetimeIndex
:series.resample('W').mean()
Handling Dates and Timestamps
9. Combining and Merging Series
Appending and Concatenation in Detail
Combining Series Data with Alignment
10. Advanced Techniques for Series
Memory Optimization
Working with Categorical Data
11. Series Visualization
Beta Was this translation helpful? Give feedback.
All reactions