Pandas vs SQL

Overview

Both Pandas and SQL are two of the most import tools used in data science and machine learning. However, the only thing these two have in common that they both work on data that is represented in the form of tables.

What is Pandas?

Pandas is an open source Python Package that is used mostly for data analytics and machine learning. This library provides a huge set of inbuilt functions that allow easy to perform complex operations. Typically, it will be used to read .csv data files. Pandas features include data cleansing, merges and joins, data inspection and statistical analysis. The only downside of pandas is that collecting large amount of data can be tricky.

What is SQL?

Unlike Pandas, SQL is a programming language that is used for database creation and manipulation. Typically SQL will read data that is stored in RDBMS files. While Pandas support row and column metadata, SQL only support column metadata. This language is utilize for fast query data processing. Basically, it allows you to collect a lump sum of data without too much issues. Performing complex operations however isn’t as easy to do compared to Pandas.

Example (Select)

With Pandas, selecting columns can be done simply by passing a list of the column names into your DataFrame. For this example we are going to take a DataFrame called teams and select the wins and loses columns for each row.

import pandas as pd
teams[["wins","loses"]]
import pandas as pd

teams[["wins","loses"]]
import pandas as pd teams[["wins","loses"]]

Enter fullscreen mode Exit fullscreen mode

Compare this to SQL, selecting columns would be done by using a list separated by commas.

SELECT wins, loses
FROM teams;
SELECT wins, loses 
FROM teams;
SELECT wins, loses FROM teams;

Enter fullscreen mode Exit fullscreen mode


Output:
wins loses
0 23 10
1 19 14
2 20 13
[3 rows x 2 columns]
Output:
     wins    loses
0     23      10
1     19      14
2     20      13

[3 rows x 2 columns]
Output: wins loses 0 23 10 1 19 14 2 20 13 [3 rows x 2 columns]

Enter fullscreen mode Exit fullscreen mode

Conclusion

While there are some key differences between both Pandas and SQL, both are extremely vital in the world of data science and machine learning. If you are interested in working with Pandas and SQL, I will provide a links at the bottom where you can learn more about them.

原文链接:Pandas vs SQL

© 版权声明
THE END
喜欢就支持一下吧
点赞13 分享
Worrying does not empty tomorrow of its troubles, it empties today of its strength.
担忧不会清空明日的烦恼,它只会丧失今日的勇气
评论 抢沙发

请登录后发表评论

    暂无评论内容