Skip to content
Advertisement

how to get the output of this SQL query in python language

SELECT * FROM Sales where SKUDESC='samsung' AND Full_month='January'

i want output which this query gives but in python code

i am trying to groupby and i am getting name of groups .how to get values like it gives in SQL query

field=['product', 'month']
grouped=df.groupby(field).groups

Advertisement

Answer

SQL:

SELECT * FROM Sales where SKUDESC='samsung' AND Full_month='January'

Python:

new_df = df.loc[(df.SKUDESC == 'samsung') & (df.Full_month == 'January')]
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement