In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
This article is to share with you about how to achieve SQL query data operation in Pandas, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.
1. Select Row
SELECT * FROM
If you want to select the entire table, simply call the name of the table:
# SQL SELECT * FROM table_df # Pandas table_df
SELECT a, b FROM
If you want to select a specific column from the table, list the column you want in double parentheses:
# SQL SELECT column_a, column_b FROM table_df # Pandas table_df [['column_a',' column_b']]
SELECT DISTINCT
Just use .drop\ u duplicates () to get different values:
# SQL SELECT DISTINCT column_a FROM table_df # Pandas table_df ['column_a']. Drop_duplicates ()
SELECT an as b
Use .rename () if you want to rename the column:
# SQL SELECT column_a as Apple, column_b as Banana FROM table_df # Pandas table_df [['column_a',' column_b']] .rename (columns= {'column_a':' Apple', 'column_b':'Banana'})
SELECT CASE WHEN
For the equivalent of "SELECT CASE WHEN", you can use np.select (), where you first specify the selection and value of each option.
# SQL SELECT CASE WHEN column_a > 30 THEN "Large" WHEN column_a 30, table_df ['column_b']
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.