Python Forum
Remove values for weekend in a panda series - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Remove values for weekend in a panda series (/thread-38934.html)



Remove values for weekend in a panda series - JaneTan - Dec-12-2022

Hi

I have a range of daily values. I want to remove the weekend (Sat + Sun) period and the accompanying values. How do I do so?

df=pd.read_excel(input_file, sheet_name='daily', usecols='A:D', na_values='ND', index_col=0, header=0)
df.index.names = ['Period']
df.index = pd.to_datetime(df.index)

q= pd.Series(df['Values'], index=df.index)
Period Values
20-Jan-89 3
27-Jan-89 4
3-Feb-89 2
10-Feb-89 5
17-Feb-89 3
24-Feb-89 5
3-Mar-89 5
10-Mar-89 6
17-Mar-89 4
24-Mar-89 5
31-Mar-89 7
7-Apr-89 6
14-Apr-89 6
21-Apr-89 4
28-Apr-89 7
5-May-89 5
12-May-89 6
19-May-89 5
26-May-89 7
2-Jun-89 7