Reading An Entire File at Once: Generating Current Date
Reading An Entire File at Once: Generating Current Date
col_start_index:col_stop_index_exclusive]
df.iloc[df.column_name ==
SELECT DISTINCT city, merged_inner = pd.merge(left=XXX,right=YYY) if a row in
country XXX has a value of AA that doesn’t appear in AA column of
“???”,col_start_index:col_stop_index_exclusive] FROM customers YYY, it will not be included
df.loc[:,’XXX’]read (row,column_name) ORDER BY country;
df.loc[[0,2]]row index 0 & 2 4. Find the number of tracks for each album ID
df.loc[2:4,’XXX’]read row 2 to 4, in that particular column SELECT albumid,
df.loc[df['gender']=='Female', COUNT(trackid)
[‘column_name1’,’column_name2’] FROM tracks
df.loc[0,['EmpID']] EmpID 21 (read down) GROUP BY albumid;
df.loc[[0],'EmpID'] 0 21 (read across) 5. Find the total length and bytes for each album ID
df.loc[0,'EmpID'] 21 (read across) SELECT albumid,
df.loc[[0],["EmpID"]] 0 21 , with column name on top SUM(milliseconds) AS length,
(read down) SUM(bytes) AS size
FROM track
df.sort_values(‘XXX’)sort one column in ascending order GROUP BY albumid;
df.sort_values(‘XXX’,ascending=False)sort in descending 6. Display the track IDs & track names for which media type id
order is 1 or 2
df.sort_values([‘XXX’,’YYY’],ascending = (True, False) ) SELECT TrackId,
#not saved, if want need to add ,inplace =True Name,
data[‘ZZZ’] = data[‘XXX’] * data[‘YYY’] Mediatypeid
data[‘ZZZ’] = data.loc[:,[‘XXX’,’YYY’]].sum(axis=1)add FROM Tracks
column ZZZ=XXX+YYY WHERE MediaTypeId IN (1, 2);