Adding source code files for Chapter 6
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
# pandas7.py
|
||||
import pandas as pd
|
||||
|
||||
weekly_data = {'day':['Monday','Tuesday', 'Wednesday', 'Thursday',
|
||||
'Friday', 'Saturday', 'Sunday'],
|
||||
'temp':[40, 33, 42, 31, 41, 40, 30],
|
||||
'condition':['Sunny','Cloudy','Sunny','Rain','Sunny',
|
||||
'Cloudy','Rain']
|
||||
}
|
||||
|
||||
df = pd.DataFrame(weekly_data)
|
||||
df.index = ['MON', 'TUE','WED','THU','FRI','SAT','SUN']
|
||||
print(df)
|
||||
df1=df.drop(index=['SUN','SAT'])
|
||||
df2=df1.drop(columns=['condition'])
|
||||
|
||||
print(df2)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user