the entire gamut of parameters available and you are encouraged to read the documentation of this function as this is one of the starting point of most python based data analysis databases to dataframe the most important data source for data scientists is the existing data sources used by their organizations relational databases (dbsand data warehouses are the de facto standard of data storage in almost all of the organizations pandas provides capabilities to connect to these databases directlyexecute queries on them to extract dataand then convert the result of the query into structured dataframe the pandas from_sql function combined with python' powerful database library implies that the task of getting data from dbs is simple and easy due to this capabilityno intermediate steps of data extraction are required we will now take an example of reading data from microsoft sql server database the following code will achieve this task server 'xxxxxxxxaddress of the database server user 'xxxxxxthe username for the database server password 'xxxxxpassword for the above user database 'xxxxxdatabase in which the table is present conn pymssql connect(server=serveruser=userpassword=passworddatabase=databasequery "select from some_tabledf pd read_sql(queryconnthe important to thing to notice here is the connection object (conn in the codethis object is the one which will identify the database server information and the type of database to pandas based on the endpoint database server we will change the connection object for example we are using the pymssql library for access to microsoft sql server here if our data source is changed to postgres databasethe connection object will change but the rest of the procedure will be similar this facility is really handy when we need to perform similar analyses on data originating from different sources once againthe read_sql function of pandas provides lot of parameters that allow us to control its behavior we also recommend you to check out the sqlalchemy librarywhich makes creating connection objects easier irrespective of the type of database vendor and also provides lot of other utilities data access the most important part after reading in our data is that of accessing that data using the data structure' access mechanisms accessing data in the pandas dataframe and series objects is very much similar to the access mechanism that exist for python lists or numpy arrays but they also offer some extra methods for data access specific to dataframe/series head and tail in the previous section we witnessed the method head it gives us the first few rows (by default of the data corresponding function is tailwhich gives us the last few rows of the dataframe these are one of the most widely used pandas functionsas we often need to take peek at our data as and when we apply different operations/selections on it we already have seen the output of headso we'll use the tail function on the same dataframe and see its output in [ ]city_data tail(out[ ]city city_ascii lat lng pop country mutare mutare - zimbabwe