Home Page [www.mystudyzone.com]



WORKSHEET (PYTHON PANDAS)Q.1 Name some common data structures of python’s pandas library.Q.2 Given a list L=[3,4,5] and an ndarray N having elements 3,4,5. What will be the result produced by:(a) L*3 (b) N*3 (c)L+L (d) N+N Q.3 Given following Series objects:S1S20 3 0 121 5 2 102 6 4 20What will be the result of S1+S2?Q.4 Why does python change the datatype of a column as soon as it stores an empty value(NaN) even though it has all other values stored as integer.Q.5 Write code statements to list the following, from a dataframe namely sales. (a) List only columns ?tem’ and ‘Revenue’. (b) List rows from 3 to 7. (c) List the value of cell in 5th row,’Items ’column.Q.6 Find out error in the following code fragment:S=pd.Series( 1,2,3,4,index=range(7))____________________________________________________________________________ ________________________________________________________________________________________________________________________________________________________________Q.7 Given a dataframe df as shown below: A B D0 15 17 191 16 18 202 20 21 22What will be the result of following code statements?Df[‘C’]=np.NaN (b) df[‘C’] = [2,5] (c) df[‘C’]=[12,15,27]Q.8 Write code statements for a dataframe df for the following:(a) delete an existing column from it.(b) delete rows from 3 to 6 from it.(c ) Check if the dataframe has any missing values.(d)Fill all missing values with 999 in it.Q.9 Find output of the below print statement?print df.val==np.NaNdf=pd.DataFrame({?d’:[1,2,3,4],’val’:[2,5,,np.NaN,6]})Q.10Consider dataframe wdf as shown below:yearMonthPassengersamount02009JANUARY1124500012009FEBRUARY1185612022009MARCH1328000032009APRIL1297550042009MAY12160000Using above dataframe, write commands for the following:Compute total passengers per pute average passengers per month. ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download