,question,train_code 0,Plot the rolling 30-day average PM2.5 for Uttarakhand in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Uttarakhand') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Uttarakhand 2024', width=600, height=300) " 1,Create a table with mean and standard deviation of PM10 by city in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2,Tabulate area-adjusted PM2.5 (per km²) for each state in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, { 'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM2.5 per km²', 'numerator': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)', 'PM2.5 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3,Show a cumulative area chart of PM2.5 readings for Indore across 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Indore') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Indore 2022', width=600, height=300) return chart " 4,Tabulate average PM10 for each city in Maharashtra across all months of 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Aurangabad', 'Chandrapur', 'Nagpur', 'Nashik', 'Navi Mumbai', 'Solapur', 'Thane']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5,"On January 27, 2022, which station showed the minimum PM10 level?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 6,"Which station showed the third-highest 75th percentile for PM10 on March 31, 2021?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 7,"Visualize the monthly average PM10 for Odisha, Meghalaya, and West Bengal in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Odisha', 'Meghalaya', 'West Bengal'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Odisha, Meghalaya, UP – 2021', width=550, height=320) return chart " 8,Generate a year-by-year summary table of PM10 readings for Karnataka.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 9,Tabulate average PM10 for each city in Punjab across all months of 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Amritsar', 'Bathinda', 'Jalandhar', 'Khanna', 'Ludhiana', 'Mandi Gobindgarh', 'Patiala', 'Rupnagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 10,Show a monthly bar chart of the number of days Chhattisgarh exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Chhattisgarh') & (data['Timestamp'].dt.year == 2024)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Chhattisgarh Exceeded WHO PM2.5 Guideline per Month – 2024', width=500, height=300) return chart " 11,Show a pivot table of monthly average PM10 by city for Gujarat in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Gujarat'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Ahmedabad', 'Ankleshwar', 'Gandhinagar', 'Nandesari', 'Surat', 'Vapi', 'Vatva']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 12,Which city had the lowest average PM10 in September 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 13,Show the monthly average PM2.5 for Jalore in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Jalore') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Jalore 2019', width=450, height=280) " 14,Show the monthly average PM10 trend for Virar from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Virar'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Virar (2019–2024)', width=600, height=300) return chart " 15,List the bottom 20 states with the lowest average PM10 in 2022 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 16,Which city had the 3rd highest 25th percentile of PM2.5 in July 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 17,List average PM2.5 by month for Patna in 2023 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Patna'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 18,Show a year-wise table of average PM2.5 for Telangana from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Telangana'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 19,Create a month-wise PM2.5 breakdown table across cities in Odisha for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Odisha'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Brajrajnagar', 'Talcher']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 20,Show the monthly average PM10 trend for Belgaum from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Belgaum'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Belgaum (2017–2022)', width=600, height=300) return chart " 21,"On March 31, 2019, which state had the lowest 25th percentile for PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 22,Visualize NCAP city-level funding for FY 2021-22 as a horizontal bar chart for the top 12 cities.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = ncap_funding_data[['city','state','Amount released during FY 2021-22']].copy() df.columns = ['city','state','Amount (Cr)'] df = df.nlargest(12, 'Amount (Cr)') df['City_State'] = df['city'] + ', ' + df['state'] chart = alt.Chart(df).mark_bar().encode( x=alt.X('Amount (Cr):Q', title='Amount Released (Cr)'), y=alt.Y('City_State:N', sort='-x', title='City, State'), color=alt.Color('state:N', title='State'), tooltip=['city:N','state:N', alt.Tooltip('Amount (Cr):Q', format='.1f')] ).properties(title='Top 12 Cities by NCAP Funding – FY 2021-22', width=500, height=400) return chart " 23,Show a monthly bar chart of the number of days Nagaland exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Nagaland') & (data['Timestamp'].dt.year == 2024)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Nagaland Exceeded WHO PM2.5 Guideline per Month – 2024', width=500, height=300) return chart " 24,Plot the rolling 30-day average PM2.5 for Tripura in 2017 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Tripura') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Tripura 2017', width=600, height=300) " 25,"Plot the yearly average PM2.5 trends for Bihar, Uttarakhand, and West Bengal from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Bihar', 'Uttarakhand', 'West Bengal'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Bihar vs Uttarakhand vs West Bengal', width=550, height=320) return chart " 26,"Create a grouped bar chart comparing the average PM2.5 for Bihar, Tamil Nadu, and Punjab across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Bihar', 'Tamil Nadu', 'Punjab'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 27,Report the state with the 3rd lowest average PM2.5 in December 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 28,Create a table showing annual mean PM2.5 levels for Raipur (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Raipur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 29,Show a monthly bar chart of the number of days Tamil Nadu exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2020.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Tamil Nadu') & (data['Timestamp'].dt.year == 2020)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Tamil Nadu Exceeded WHO PM2.5 Guideline per Month – 2020', width=500, height=300) return chart " 30,Create a table of PM2.5 exceedance frequency above 60 µg/m³ by city for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 31,Determine the state exhibiting the 3rd highest 75th percentile of PM2.5 in February 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 32,"Plot the yearly average PM2.5 trends for Chandigarh, West Bengal, and Puducherry from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chandigarh', 'West Bengal', 'Puducherry'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Chandigarh vs West Bengal vs Puducherry', width=550, height=320) return chart " 33,"Which union territory possesses the smallest population among the top 2 most polluted union territories, determined by total PM10 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'sum', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 2, 'ret': 'state'}}] " 34,Plot the top 10 states by average PM2.5 in 2020 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2020] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(10, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 10 States by Average PM2.5 in 2020', width=500, height=300) return chart " 35,Show how average PM10 varied month by month for Puducherry in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Puducherry'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 36,Show how average PM2.5 varied month by month for Madhya Pradesh in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 37,Identify the station that saw the most significant fall in median PM10 levels when comparing December 2023 to October 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 38,Which city noted the 3rd lowest average PM10 in the Winter season of 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 39,Show the monthly average PM2.5 for Fatehabad in 2022 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Fatehabad') & (data['Timestamp'].dt.year == 2022)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Fatehabad 2022', width=450, height=280) " 40,"Create a grouped bar chart comparing the average PM2.5 for Haryana, Sikkim, and Uttarakhand across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Sikkim', 'Uttarakhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 41,Create a summary table ranking the top 5 citys by PM2.5 concentration in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 42,Create a table with mean and standard deviation of PM10 by city in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 43,Show a cumulative area chart of PM2.5 readings for Bundi across 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bundi') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Bundi 2023', width=600, height=300) return chart " 44,Show the monthly average PM2.5 for Jabalpur in 2023 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Jabalpur') & (data['Timestamp'].dt.year == 2023)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Jabalpur 2023', width=450, height=280) " 45,"Plot the yearly average PM2.5 trends for Rajasthan, Tripura, and Odisha from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Tripura', 'Odisha'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Rajasthan vs Tripura vs Odisha', width=550, height=320) return chart " 46,Identify the city that recorded the 2nd lowest median PM10 value in May 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 47,Show a year-wise table of average PM10 for Tripura from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tripura'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 48,Tabulate the yearly average PM2.5 trend for Varanasi across all years.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Varanasi'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 49,Identify the union territory possessing the 4th lowest 75th percentile of PM10 concentration adjusted for population density.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_capita', 'numerator': 'PM10', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'pm_per_capita', 'ascending': True}}] " 50,Determine the station exhibiting the 2nd lowest median PM10 in May 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 51,Show a box plot of PM2.5 distribution for each state in 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2018].dropna(subset=['PM2.5']) df = df[['state','PM2.5']] state_order = df.groupby('state')['PM2.5'].median().sort_values(ascending=False).index.tolist() chart = alt.Chart(df).mark_boxplot(extent='min-max').encode( x=alt.X('PM2\.5:Q', title='PM2.5 (µg/m³)'), y=alt.Y('state:N', sort=state_order, title='State'), color=alt.Color('state:N', legend=None) ).properties(title='PM2.5 Distribution by State – 2018', width=500, height=450) return chart " 52,Report the station with the 2nd highest average PM2.5 in January 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 53,Tabulate the monthly mean PM10 levels for Moradabad during 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Moradabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 54,"Compare the monthly average PM2.5 of Jalna, Palwal, and Panipat in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Jalna', 'Palwal', 'Panipat'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Jalna vs Palwal vs Panipat – 2019', width=550, height=320) return chart " 55,Plot the distribution of PM2.5 values in Odisha across all years using a histogram.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Odisha'].dropna(subset=['PM2.5']) df = df[['PM2.5']] chart = alt.Chart(df).mark_bar(color='steelblue', opacity=0.75).encode( x=alt.X('PM2\.5:Q', bin=alt.Bin(maxbins=40), title='PM2.5 (µg/m³)'), y=alt.Y('count()', title='Number of Observations'), tooltip=[alt.Tooltip('PM2\.5:Q', bin=True), 'count()'] ).properties(title='PM2.5 Distribution – Odisha (All Years)', width=500, height=300) return chart " 56,"Show mean, median, minimum, and maximum PM10 for each city in 2018 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 57,List how many days each city breached the PM2.5 limit of 100 µg/m³ in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 58,Show a ranked table of the 20 most polluted citys by average PM10 in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 59,Show a pivot table of monthly average PM10 by city for Odisha in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Odisha'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Brajrajnagar', 'Talcher']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 60,"Create a grouped bar chart comparing the average PM2.5 for Arunachal Pradesh, West Bengal, and Jharkhand across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Arunachal Pradesh', 'West Bengal', 'Jharkhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 61,Tabulate average PM10 for each city in Karnataka across all months of 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Bagalkot', 'Bengaluru', 'Chikkaballapur', 'Chikkamagaluru', 'Kolar', 'Mysuru', 'Ramanagara']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 62,"Create a grouped bar chart comparing the average PM2.5 for Madhya Pradesh, Arunachal Pradesh, and West Bengal across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Madhya Pradesh', 'Arunachal Pradesh', 'West Bengal'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 63,Plot the rolling 30-day average PM2.5 for Andhra Pradesh in 2017 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Andhra Pradesh') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Andhra Pradesh 2017', width=600, height=300) " 64,Identify the state that saw the least significant fall in 25th percentile PM2.5 levels when comparing December 2024 to October 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 65,Which city recorded the 3rd highest 25th percentile of PM2.5 in April 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 66,"Which state having a land area less than 50,000 km² registers the 3rd minimum PM10 level, based on its standard deviation of PM10 level?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'std', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}] " 67,List the average PM10 for Lucknow broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Lucknow'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 68,"Tabulate the distribution of PM10 per state in 2020 including mean, median, and std."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 69,Tabulate the yearly average PM10 trend for Chandigarh across all years.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Chandigarh'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 70,"Plot the yearly average PM2.5 trends for Karnataka, Gujarat, and Rajasthan from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Karnataka', 'Gujarat', 'Rajasthan'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Karnataka vs Gujarat vs Rajasthan', width=550, height=320) return chart " 71,Identify the state with the 3rd lowest median PM10 for October 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 72,Create a per-capita PM10 summary table by state for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM10 per million', 'numerator': 'PM10', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'PM10 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 73,How many times did Bangalore city surpass 90 µg/m³ of PM2.5 in 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 90.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 74,Report the state exhibiting the 5th lowest average PM2.5 concentration normalized by population density.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_capita', 'numerator': 'PM2.5', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'pm_per_capita', 'ascending': True}}] " 75,Create a per-capita PM10 summary table by state for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM10 per million', 'numerator': 'PM10', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'PM10 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 76,How many times did Kanchipuram city exceed the WHO guideline for PM2.5 in the year 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 15.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 77,Report which city experienced the third lowest 25th percentile of PM2.5 throughout the Post-Monsoon season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 78,Which city recorded the minimum 75th percentile for PM10 in July 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 79,"Over all years, which May was associated with the second-highest median PM2.5 levels?"," [{'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'Timestamp'}}] " 80,Show the monthly average PM2.5 for Chhal in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Chhal') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Chhal 2017', width=450, height=280) " 81,"Over the past five years in Bilaspur, on which date was the PM2.5 level the third lowest?"," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 5}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'Timestamp'}}] " 82,Create a table showing annual mean PM2.5 levels for Tamil Nadu (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 83,Determine the average PM10 level on Wednesdays in Puducherry.," [{'op': 'FILTER', 'params': {'field': 'state', 'value': 'Puducherry'}}] " 84,List the bottom 20 citys with the lowest average PM10 in 2018 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 85,Generate a city × month cross-tab of mean PM10 for Rajasthan in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Ajmer', 'Alwar', 'Bhiwadi', 'Jaipur', 'Jodhpur', 'Kota', 'Pali', 'Udaipur']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 86,Tabulate mean PM2.5 and land area for each state in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 87,Show how many times PM2.5 exceeded 60 µg/m³ per day across citys in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 88,Identify the state with the 2nd highest average PM2.5 for October 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 89,List average PM2.5 by month for Delhi in 2017 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Delhi'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 90,"Compare the monthly average PM2.5 of Indore, Dholpur, and Singrauli in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Indore', 'Dholpur', 'Singrauli'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Indore vs Dholpur vs Singrauli – 2024', width=550, height=320) return chart " 91,Show a monthly breakdown table of average PM10 for Bengaluru in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Bengaluru'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 92,Determine a week with Gwalior's 2nd lowest PM2.5 levels over all these years.," [{'op': 'FILTER', 'params': {'field': 'city', 'value': 'Gwalior'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'week'}}] " 93,"During 2022, determine the weekday that showed the second-highest median PM2.5 pollution levels."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'Timestamp'}}] " 94,"Visualize the monthly average PM10 for Rajasthan, Odisha, and Tripura in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Odisha', 'Tripura'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Rajasthan, Odisha, UP – 2023', width=550, height=320) return chart " 95,"Scatter plot PM2.5 vs PM10 for West Bengal stations in 2020, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'West Bengal') & (data['Timestamp'].dt.year == 2020)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – West Bengal Stations 2020', width=450, height=350) " 96,"Create a faceted bar chart showing top 8 states by average PM2.5 per year for 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year.isin([2020,2021,2022,2023])].copy() df['Year'] = df['Timestamp'].dt.year agg = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() top = agg.groupby('Year').apply(lambda x: x.nlargest(8,'PM2.5')).reset_index(drop=True) chart = alt.Chart(top).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Avg PM2.5'), y=alt.Y('state:N', sort='-x'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet(facet='Year:O', columns=2).properties(title='Top 8 States by PM2.5 per Year') return chart " 97,"Considering 2024, which season (Winter, Summer, Monsoon, Post-Monsoon) registered the second-highest PM10 levels on average?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'season'}}] " 98,Plot the weekly average PM2.5 for Delhi in 2021 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Delhi') & (data['Timestamp'].dt.year == 2021)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Delhi 2021', width=600, height=300) return chart " 99,Plot the weekly average PM2.5 for Fatehabad in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Fatehabad') & (data['Timestamp'].dt.year == 2020)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Fatehabad 2020', width=600, height=300) return chart " 100,"Scatter plot PM2.5 vs PM10 for Chhattisgarh stations in 2023, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Chhattisgarh') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Chhattisgarh Stations 2023', width=450, height=350) " 101,Determine the city with the 2nd highest 75th percentile of PM2.5 in January 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 102,"Create a grouped bar chart comparing the average PM2.5 for Chhattisgarh, Maharashtra, and Arunachal Pradesh across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chhattisgarh', 'Maharashtra', 'Arunachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 103,Show a pivot table of monthly average PM2.5 by state for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Bihar', 'Delhi', 'Gujarat', 'Haryana', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Odisha', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 104,"In March 2018, which station exhibited the 2nd highest 25th percentile of PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 105,"Considering 2021, what week number had the third-highest 75th percentile for PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'week'}}] " 106,Plot the rolling 30-day average PM2.5 for Nagaland in 2018 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Nagaland') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Nagaland 2018', width=600, height=300) " 107,Tabulate population-adjusted PM2.5 levels for each state in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM2.5 per million', 'numerator': 'PM2.5', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'PM2.5 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 108,Plot the weekly average PM2.5 for Gaya in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Gaya') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Gaya 2023', width=600, height=300) return chart " 109,Show the monthly average PM10 trend for Vrindavan from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Vrindavan'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Vrindavan (2017–2022)', width=600, height=300) return chart " 110,"In February 2022, report the city with the 3rd highest 25th percentile of PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 111,Which 15 states had the lowest mean PM10 in 2022? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 112,Show average PM10 per state in 2018 with area in km².," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 113,"Create a grouped bar chart comparing the average PM2.5 for Odisha, Mizoram, and Nagaland across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Odisha', 'Mizoram', 'Nagaland'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 114,List the average PM2.5 for Moradabad broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Moradabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 115,"Which state (excluding UTs) possesses the 2nd largest population within the top 5 most polluted states, determined by variance of PM2.5 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'var', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 5, 'ret': 'state'}}] " 116,"Considering all years, which January was associated with the second-lowest 25th percentile of PM10 levels?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'Timestamp'}}] " 117,Show annual average PM2.5 for Aurangabad as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Aurangabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 118,Tabulate days with PM10 > 150 µg/m³ and exceedance percentage per city in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 150'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 119,Which state had the third-highest mean PM2.5 concentration in April 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 120,"For the year 2020, which week had the third-lowest median PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'week'}}] " 121,Show a cumulative area chart of PM2.5 readings for Pune across 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Pune') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Pune 2022', width=600, height=300) return chart " 122,Report which station registered the 3rd highest 75th percentile of PM2.5 throughout the Winter season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 123,Tabulate days with PM10 > 150 µg/m³ and exceedance percentage per state in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 150'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 124,Plot the weekly average PM2.5 for Sirohi in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Sirohi') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Sirohi 2023', width=600, height=300) return chart " 125,"Visualize the monthly average PM10 for Haryana, Assam, and Chandigarh in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Assam', 'Chandigarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Haryana, Assam, UP – 2023', width=550, height=320) return chart " 126,"Plot the yearly average PM2.5 trends for Sikkim, Chhattisgarh, and Andhra Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Sikkim', 'Chhattisgarh', 'Andhra Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Sikkim vs Chhattisgarh vs Andhra Pradesh', width=550, height=320) return chart " 127,Name the station with the third-highest 25th percentile of PM10 for April 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 128,Identify the station that recorded the 2nd lowest median PM10 value in May 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 129,"Show mean, median, minimum, and maximum PM10 for each state in 2022 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 130,Which station experienced the third most significant drop in its median PM10 levels between October and December 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 131,Which station recorded the 2nd lowest median PM2.5 in the Summer season of 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 132,Plot the distribution of PM2.5 values in Maharashtra across all years using a histogram.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Maharashtra'].dropna(subset=['PM2.5']) df = df[['PM2.5']] chart = alt.Chart(df).mark_bar(color='steelblue', opacity=0.75).encode( x=alt.X('PM2\.5:Q', bin=alt.Bin(maxbins=40), title='PM2.5 (µg/m³)'), y=alt.Y('count()', title='Number of Observations'), tooltip=[alt.Tooltip('PM2\.5:Q', bin=True), 'count()'] ).properties(title='PM2.5 Distribution – Maharashtra (All Years)', width=500, height=300) return chart " 133,Which 5 citys recorded the highest average PM10 levels in 2019? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 134,How many times did Ernakulam city go above the WHO guideline for PM10 in the year 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 15.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 135,Tabulate average and median PM10 for all states in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 136,Tabulate the top 10 citys for PM2.5 in 2021 along with their corresponding PM10 values.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 137,"Compare the monthly average PM2.5 of Sonipat, Solapur, and Rourkela in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Sonipat', 'Solapur', 'Rourkela'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Sonipat vs Solapur vs Rourkela – 2017', width=550, height=320) return chart " 138,Show the monthly average PM2.5 for Ernakulam in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ernakulam') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Ernakulam 2017', width=450, height=280) " 139,"On August 15, 2019, which station had the third-most elevated PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 140,Identify the city that recorded the 2nd lowest 25th percentile of PM2.5 value in May 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 141,Which year is linked to the highest recorded average PM10 level?," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'Timestamp'}}] " 142,Identify the city that recorded the 3rd highest median PM10 value in October 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 143,Create a table of PM10 standard violations (>100 µg/m³) per state in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 144,"Create a faceted bar chart showing top 13 states by average PM2.5 per year for 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year.isin([2019,2020,2021,2022])].copy() df['Year'] = df['Timestamp'].dt.year agg = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() top = agg.groupby('Year').apply(lambda x: x.nlargest(13,'PM2.5')).reset_index(drop=True) chart = alt.Chart(top).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Avg PM2.5'), y=alt.Y('state:N', sort='-x'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet(facet='Year:O', columns=2).properties(title='Top 13 States by PM2.5 per Year') return chart " 145,Create a table of PM2.5 standard violations (>100 µg/m³) per city in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 146,"Visualize the monthly average PM10 for Andhra Pradesh, Mizoram, and Haryana in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Mizoram', 'Haryana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Andhra Pradesh, Mizoram, UP – 2024', width=550, height=320) return chart " 147,"In 2021, which day of the week corresponded to the second-highest average PM10 pollution levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'Timestamp'}}] " 148,Which station had the lowest median PM2.5 in March 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 149,"Create a grouped bar chart comparing the average PM2.5 for Haryana, Mizoram, and Manipur across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Mizoram', 'Manipur'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 150,Determine the city with the 2nd lowest median PM10 in May 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 151,How many times did Sikkim go above 30 µg/m³ of PM2.5 in 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 30.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 152,Plot the weekly average PM2.5 for Nandesari in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Nandesari') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Nandesari 2023', width=600, height=300) return chart " 153,"Create a grouped bar chart comparing the average PM2.5 for Mizoram, Tamil Nadu, and West Bengal across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Mizoram', 'Tamil Nadu', 'West Bengal'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 154,Create a table of PM2.5 exceedance frequency above 100 µg/m³ by state for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 155,Report the city that was granted the 4th lowest NCAP funding with respect to the standard deviation of its PM2.5 concentration in 2020 (FY 2019-20).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'std', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2020_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 156,Which state had the highest 75th percentile of PM2.5 in March 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 157,Name the city with the highest median PM10 value in November 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 158,Show the monthly average PM2.5 for Banswara in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Banswara') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Banswara 2018', width=450, height=280) " 159,Plot the weekly average PM2.5 for Firozabad in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Firozabad') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Firozabad 2023', width=600, height=300) return chart " 160,List the average PM2.5 for Delhi broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Delhi'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 161,"Which state (excluding Union Territories) presents the 2nd highest PM10 concentration per square kilometer, according to 75th percentile PM10 values?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_km2', 'numerator': 'PM10', 'denominator': 'area (km2)'}}, {'op': 'SORT', 'params': {'col': 'pm_per_km2', 'ascending': False}}] " 162,"Tabulate PM2.5 statistics (mean, std, min, max) for each state in 2023."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 163,Show a monthly bar chart of the number of days Delhi exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2020.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Delhi') & (data['Timestamp'].dt.year == 2020)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Delhi Exceeded WHO PM2.5 Guideline per Month – 2020', width=500, height=300) return chart " 164,"Create a grouped bar chart comparing the average PM2.5 for Arunachal Pradesh, Haryana, and Madhya Pradesh across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Arunachal Pradesh', 'Haryana', 'Madhya Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 165,Generate a monthly average PM2.5 table for Assam for the year 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Assam'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 166,Tabulate average PM2.5 for each city in Kerala across all months of 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Thiruvananthapuram']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 167,Which city experienced the second least significant drop in its average PM10 levels between October and December 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 168,Show the monthly average PM2.5 for Ajmer in 2023 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ajmer') & (data['Timestamp'].dt.year == 2023)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Ajmer 2023', width=450, height=280) " 169,"For the period October to December 2019, which state had the largest decrease in 75th percentile PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 170,"Create a grouped bar chart comparing the average PM2.5 for Sikkim, Manipur, and Bihar across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Sikkim', 'Manipur', 'Bihar'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 171,"Visualize the monthly average PM10 for Chhattisgarh, Delhi, and Sikkim in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chhattisgarh', 'Delhi', 'Sikkim'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Chhattisgarh, Delhi, UP – 2018', width=550, height=320) return chart " 172,During which year was the 75th percentile of PM10 the second highest?," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'Timestamp'}}] " 173,"For the period October to December 2018, which state had the smallest decrease in 25th percentile PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 174,Show PM10 exceedance count and rate (%) above 150 µg/m³ per city in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 150'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 175,Report the state that had the highest median PM10 in February 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 176,"Create a comprehensive state summary with PM10, population, and area for 2020."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 177,"Create a faceted bar chart showing top 13 states by average PM2.5 per year for 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year.isin([2021,2022,2023,2024])].copy() df['Year'] = df['Timestamp'].dt.year agg = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() top = agg.groupby('Year').apply(lambda x: x.nlargest(13,'PM2.5')).reset_index(drop=True) chart = alt.Chart(top).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Avg PM2.5'), y=alt.Y('state:N', sort='-x'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet(facet='Year:O', columns=2).properties(title='Top 13 States by PM2.5 per Year') return chart " 178,"Create a bubble chart of PM2.5 vs area for each state in 2024, sized by population."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): pm = data[data['Timestamp'].dt.year == 2024].groupby('state')['PM2.5'].mean().reset_index().dropna() df = pm.merge(states_data, on='state') chart = alt.Chart(df).mark_point(filled=True, opacity=0.7).encode( x=alt.X('area (km2):Q', title='Area (km²)', axis=alt.Axis(format='~s')), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), size=alt.Size('population:Q', title='Population', scale=alt.Scale(range=[50,1500])), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('population:Q', format=','), alt.Tooltip('area (km2):Q', format=',')] ).properties(title='PM2.5 vs Area (size=Population) – 2024', width=500, height=400) return chart " 179,Identify the state with the 2nd highest 25th percentile of PM2.5 for October 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 180,Show a cumulative area chart of PM2.5 readings for Kanchipuram across 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Kanchipuram') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Kanchipuram 2023', width=600, height=300) return chart " 181,Identify the state that showed the second highest 75th percentile of PM2.5 during the Monsoon season of 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 182,What date during the last two years showed Dharwad's peak PM10 reading?," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 2}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'Timestamp'}}] " 183,What was the third-lowest PM2.5 concentration measured in 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}] " 184,Create a summary table ranking the top 20 citys by PM10 concentration in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 185,"Plot the yearly average PM2.5 trends for Tamil Nadu, Himachal Pradesh, and Gujarat from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Himachal Pradesh', 'Gujarat'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Tamil Nadu vs Himachal Pradesh vs Gujarat', width=550, height=320) return chart " 186,"Visualize the monthly average PM10 for Sikkim, Himachal Pradesh, and Haryana in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Sikkim', 'Himachal Pradesh', 'Haryana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Sikkim, Himachal Pradesh, UP – 2018', width=550, height=320) return chart " 187,Identify the city with the 4th lowest NCAP funding considering the standard deviation of its PM2.5 concentration in 2022 (FY 2021-22).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'std', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2022_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 188,Show a pivot table of monthly average PM10 by state for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Delhi', 'Gujarat', 'Haryana', 'Jharkhand', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 189,"Visualize the monthly average PM10 for Mizoram, Kerala, and Jammu and Kashmir in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Mizoram', 'Kerala', 'Jammu and Kashmir'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Mizoram, Kerala, UP – 2019', width=550, height=320) return chart " 190,Which state registered the 3rd highest median PM2.5 during June 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 191,Tabulate the yearly average PM10 trend for West Bengal across all years.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'West Bengal'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 192,Which city experienced the least significant drop in its average PM10 levels between October and December 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 193,Tabulate average and median PM10 for all states in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 194,Identify the city that recorded the third lowest 25th percentile of PM10 during the Winter season of 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 195,"Visualize the monthly average PM10 for Delhi, Tamil Nadu, and Mizoram in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Delhi', 'Tamil Nadu', 'Mizoram'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Delhi, Tamil Nadu, UP – 2019', width=550, height=320) return chart " 196,"Create a grouped bar chart comparing the average PM2.5 for Jharkhand, Tripura, and Uttarakhand across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Tripura', 'Uttarakhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 197,Create a table with mean and standard deviation of PM2.5 by state in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 198,Which station possessed the 3rd lowest 75th percentile for PM10 in the Summer season of 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 199,"Create a comprehensive state summary with PM2.5, population, and area for 2024."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': { 'map': { 'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 200,Tabulate the top 5 states for PM2.5 in 2022 along with their corresponding PM10 values.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 201,"Compare the monthly average PM2.5 of Eloor, Siliguri, and Indore in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Eloor', 'Siliguri', 'Indore'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Eloor vs Siliguri vs Indore – 2024', width=550, height=320) return chart " 202,Determine the city with the 2nd highest 25th percentile of PM2.5 in December 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 203,Which city displayed the 3rd highest average PM10 in August 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 204,Show a year-wise table of average PM2.5 for Asansol from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Asansol'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 205,Tabulate area-adjusted PM2.5 (per km²) for each state in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, { 'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM2.5 per km²', 'numerator': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)', 'PM2.5 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 206,Create a month-wise summary of average PM10 for Gujarat in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Gujarat'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 207,Identify what percentage of people reside in states where the 25th percentile of PM2.5 concentration surpasses 60.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}] " 208,Show a cumulative area chart of PM2.5 readings for Sonipat across 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Sonipat') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Sonipat 2021', width=600, height=300) return chart " 209,"Identify the station that recorded the second highest PM2.5 level on January 27, 2020."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 210,"Show mean, median, minimum, and maximum PM2.5 for each city in 2024 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 211,Generate a city × month cross-tab of mean PM2.5 for Kerala in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Eloor', 'Ernakulam', 'Kochi', 'Kozhikode', 'Thiruvananthapuram']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 212,"Create a faceted bar chart showing top 6 states by average PM2.5 per year for 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year.isin([2019,2020,2021,2022])].copy() df['Year'] = df['Timestamp'].dt.year agg = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() top = agg.groupby('Year').apply(lambda x: x.nlargest(6,'PM2.5')).reset_index(drop=True) chart = alt.Chart(top).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Avg PM2.5'), y=alt.Y('state:N', sort='-x'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet(facet='Year:O', columns=2).properties(title='Top 6 States by PM2.5 per Year') return chart " 213,Identify the city with the 2nd highest median PM10 in July 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 214,Tabulate average PM2.5 for each city in Bihar across all months of 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Bihar'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Araria', 'Arrah', 'Aurangabad', 'Bettiah', 'Bhagalpur', 'Bihar Sharif', 'Chhapra', 'Gaya', 'Hajipur', 'Katihar', 'Kishanganj', 'Manguraha', 'Motihari', 'Munger', 'Muzaffarpur', 'Patna', 'Purnia', 'Rajgir', 'Saharsa', 'Samastipur', 'Sasaram', 'Siwan']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 215,Visualize the bottom 13 states with the lowest average PM2.5 in 2019 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2019] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(13, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 13 States by Average PM2.5 in 2019', width=500, height=300) return chart " 216,"Plot the yearly average PM2.5 trends for Chandigarh, Delhi, and Delhi from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chandigarh', 'Delhi', 'Delhi'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Chandigarh vs Delhi vs Delhi', width=550, height=320) return chart " 217,"Create a table showing top 15 states ranked by PM2.5 in 2021, also showing PM10."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 218,Create a table with mean and standard deviation of PM10 by state in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 219,Report which state possessed the third highest 25th percentile of PM10 throughout the Monsoon season of 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 220,Plot the rolling 30-day average PM2.5 for Rajasthan in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Rajasthan') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Rajasthan 2024', width=600, height=300) " 221,Report the station with the 2nd lowest 25th percentile of PM10 in January 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 222,Tabulate both PM2.5 and PM10 averages by state for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 223,Generate a city × month cross-tab of mean PM2.5 for Assam in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Assam'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Guwahati']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 224,"In October 2021, report the station with the 3rd highest average PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 225,Tabulate the 10 worst citys for average PM2.5 in 2024 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 226,Which 15 states recorded the highest average PM10 levels in 2024? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 227,"Show a table of average PM10, population, and area for all states in 2020."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 228,"On August 15, 2019, which city registered the third-highest PM2.5 concentrations?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 229,Generate a monthly average PM10 table for Gujarat for the year 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Gujarat'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 230,Tabulate average PM10 for each city in Bihar across all months of 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Bihar'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Araria', 'Arrah', 'Aurangabad', 'Begusarai', 'Bettiah', 'Bhagalpur', 'Bihar Sharif', 'Chhapra', 'Gaya', 'Hajipur', 'Katihar', 'Kishanganj', 'Manguraha', 'Motihari', 'Munger', 'Muzaffarpur', 'Patna', 'Purnia', 'Rajgir', 'Saharsa', 'Samastipur', 'Sasaram', 'Siwan']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 231,List the average PM2.5 for Gujarat broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Gujarat'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 232,Which station had the highest average PM10 in February 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 233,Create a month-wise summary of average PM10 for Patna in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Patna'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 234,List states by PM10 concentration per million inhabitants in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM10 per million', 'numerator': 'PM10', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'PM10 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 235,List the average PM2.5 for Mizoram broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Mizoram'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 236,Plot the weekly average PM2.5 for Hapur in 2021 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Hapur') & (data['Timestamp'].dt.year == 2021)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Hapur 2021', width=600, height=300) return chart " 237,Show annual average PM2.5 for Bihar as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Bihar'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 238,Tabulate mean PM2.5 and land area for each state in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 239,"Tabulate the distribution of PM2.5 per city in 2019 including mean, median, and std."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 240,"Create a grouped bar chart comparing the average PM2.5 for Uttar Pradesh, Delhi, and Chhattisgarh across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttar Pradesh', 'Delhi', 'Chhattisgarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 241,"On January 5, 2019, which city experienced the third-highest average PM10 reading?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 242,Which state experienced the third least significant drop in its average PM10 levels between October and December 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 243,"Create a grouped bar chart comparing the average PM2.5 for Sikkim, Sikkim, and Tamil Nadu across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Sikkim', 'Sikkim', 'Tamil Nadu'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 244,Show a heatmap of average PM2.5 for the top 11 most polluted states by month for 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(11).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 11 Polluted States by Month (2018)', width=500, height=300) return chart " 245,"Compare the monthly average PM2.5 of Ramanathapuram, Kashipur, and Shillong in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Ramanathapuram', 'Kashipur', 'Shillong'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Ramanathapuram vs Kashipur vs Shillong – 2024', width=550, height=320) return chart " 246,Which city recorded the minimum 75th percentile of PM10 in the Monsoon season of 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 247,"Visualize the monthly average PM10 for Kerala, Haryana, and West Bengal in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Kerala', 'Haryana', 'West Bengal'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Kerala, Haryana, UP – 2023', width=550, height=320) return chart " 248,"Create a grouped bar chart comparing the average PM2.5 for Delhi, Himachal Pradesh, and Uttar Pradesh across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Delhi', 'Himachal Pradesh', 'Uttar Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 249,Show PM10 exceedance count and rate (%) above 150 µg/m³ per city in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 150'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 250,Create a table of PM2.5 standard violations (>100 µg/m³) per state in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 251,List how many days each city breached the PM10 limit of 100 µg/m³ in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 252,Generate a table showing the 15 most polluted citys based on mean PM2.5 for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 253,Plot the rolling 30-day average PM2.5 for Karnataka in 2019 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Karnataka') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Karnataka 2019', width=600, height=300) " 254,Show a pivot table of monthly average PM10 by city for Assam in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Assam'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Guwahati']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 255,Identify the most polluted state concerning per capita PM10 exposure in 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'per_capita_pm', 'numerator': 'PM10', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'per_capita_pm', 'ascending': False}}] " 256,"Show the variability of PM2.5 across citys in 2019 using mean, median, and standard deviation."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 257,Tabulate average PM2.5 for each city in Uttar Pradesh across all months of 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Agra', 'Baghpat', 'Bulandshahr', 'Ghaziabad', 'Greater Noida', 'Kanpur', 'Lucknow', 'Moradabad', 'Noida', 'Varanasi']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 258,"Plot the yearly average PM2.5 trends for Rajasthan, Uttar Pradesh, and Sikkim from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Uttar Pradesh', 'Sikkim'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Rajasthan vs Uttar Pradesh vs Sikkim', width=550, height=320) return chart " 259,"Which state, out of those with populations exceeding the median, is allocated the lowest per capita NCAP funding?"," [{'op': 'COMPUTE', 'params': {'new_col': 'funding_per_capita', 'numerator': 'total_fund', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'funding_per_capita', 'ascending': True}}] " 260,"Which city showed the third-highest PM2.5 levels on August 15, 2021?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 261,Create a ranked table of the 20 best-performing states by PM2.5 in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 262,"Across all recorded years, which December was associated with the second-lowest median PM10 levels?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'Timestamp'}}] " 263,Which station had the highest 25th percentile of PM2.5 in April 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 264,Create a summary table ranking the top 15 citys by PM10 concentration in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 265,Tabulate the yearly average PM10 trend for Ghaziabad across all years.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Ghaziabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 266,Identify the station with the second-lowest 75th percentile for PM2.5 in April 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 267,List the top 10 states by average PM10 in 2017 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 268,"Visualize the monthly average PM10 for Karnataka, Haryana, and Gujarat in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Karnataka', 'Haryana', 'Gujarat'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Karnataka, Haryana, UP – 2017', width=550, height=320) return chart " 269,Plot the rolling 30-day average PM2.5 for West Bengal in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'West Bengal') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – West Bengal 2024', width=600, height=300) " 270,Show a table of the 10 cleanest citys by average PM10 in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 271,"Identify the city with the third-lowest 75th percentile for PM2.5 on March 31, 2018."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 272,"Which union territory with a land area below 1,000 km² shows the highest PM2.5 level, based on its standard deviation of PM2.5 level?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'std', 'col': 'PM2.5'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}] " 273,Tabulate daily PM10 exceedances (above 150 µg/m³) per city for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 274,Show a pivot table of monthly average PM2.5 by city for Andhra Pradesh in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Amaravati', 'Anantapur', 'Chittoor', 'Kadapa', 'Rajamahendravaram', 'Tirupati', 'Vijayawada', 'Visakhapatnam']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 275,Tabulate days with PM2.5 > 60 µg/m³ and exceedance percentage per city in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 276,"Tabulate PM2.5 statistics (mean, std, min, max) for each state in 2021."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 277,Identify the city with the 2nd lowest 75th percentile of PM2.5 in December 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 278,"In Puducherry, what is the median PM2.5 concentration on Wednesdays?"," [{'op': 'FILTER', 'params': {'field': 'state', 'value': 'Puducherry'}}] " 279,Determine the state with the third-highest 25th percentile for PM10 during October 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 280,Which station recorded the lowest 75th percentile of PM2.5 in August 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 281,Generate a descriptive stats table for PM2.5 grouped by state in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 282,Show the monthly average PM10 trend for Mandikhera from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Mandikhera'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Mandikhera (2019–2024)', width=600, height=300) return chart " 283,Plot the weekly average PM2.5 for Gurugram in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Gurugram') & (data['Timestamp'].dt.year == 2020)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Gurugram 2020', width=600, height=300) return chart " 284,Report the state that had the 3rd lowest 75th percentile of PM2.5 in August 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 285,"Over all years, which January experienced the maximum 25th percentile for PM2.5 concentration?"," [{'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'Timestamp'}}] " 286,Determine the city exhibiting the lowest average PM2.5 in December 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 287,"Plot the yearly average PM2.5 trends for Gujarat, Tripura, and Karnataka from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Gujarat', 'Tripura', 'Karnataka'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Gujarat vs Tripura vs Karnataka', width=550, height=320) return chart " 288,Show a cumulative area chart of PM2.5 readings for Greater Noida across 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Greater Noida') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Greater Noida 2022', width=600, height=300) return chart " 289,Show the monthly average PM2.5 for Dholpur in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Dholpur') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Dholpur 2019', width=450, height=280) " 290,Show the monthly average PM10 trend for Mumbai from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Mumbai'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Mumbai (2017–2022)', width=600, height=300) return chart " 291,"Scatter plot PM2.5 vs PM10 for Bihar stations in 2024, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Bihar') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Bihar Stations 2024', width=450, height=350) " 292,"In 2019, which week experienced the minimum 25th percentile for PM10 concentrations?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'week'}}] " 293,Show how average PM2.5 varied month by month for Meerut in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Meerut'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 294,Show a monthly bar chart of the number of days Odisha exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Odisha') & (data['Timestamp'].dt.year == 2024)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Odisha Exceeded WHO PM2.5 Guideline per Month – 2024', width=500, height=300) return chart " 295,"Create a grouped bar chart comparing the average PM2.5 for Telangana, Madhya Pradesh, and Gujarat across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Telangana', 'Madhya Pradesh', 'Gujarat'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 296,"Visualize the monthly average PM10 for Bihar, Chandigarh, and Punjab in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Bihar', 'Chandigarh', 'Punjab'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Bihar, Chandigarh, UP – 2021', width=550, height=320) return chart " 297,"Create a faceted bar chart showing top 11 states by average PM2.5 per year for 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year.isin([2020,2021,2022,2023])].copy() df['Year'] = df['Timestamp'].dt.year agg = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() top = agg.groupby('Year').apply(lambda x: x.nlargest(11,'PM2.5')).reset_index(drop=True) chart = alt.Chart(top).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Avg PM2.5'), y=alt.Y('state:N', sort='-x'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet(facet='Year:O', columns=2).properties(title='Top 11 States by PM2.5 per Year') return chart " 298,"Visualize the monthly average PM10 for Mizoram, Puducherry, and Meghalaya in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Mizoram', 'Puducherry', 'Meghalaya'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Mizoram, Puducherry, UP – 2019', width=550, height=320) return chart " 299,"Create a grouped bar chart comparing the average PM2.5 for Rajasthan, Rajasthan, and Himachal Pradesh across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Rajasthan', 'Himachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 300,Tabulate average and median PM10 for all citys in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 301,"Create a grouped bar chart comparing the average PM2.5 for Jammu and Kashmir, Nagaland, and Delhi across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jammu and Kashmir', 'Nagaland', 'Delhi'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 302,"In March 2018, which state recorded the highest 25th percentile of PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 303,Plot the weekly average PM2.5 for Varanasi in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Varanasi') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Varanasi 2023', width=600, height=300) return chart " 304,Determine the station with the lowest 25th percentile of PM10 in January 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 305,Create a summary table ranking the top 20 citys by PM10 concentration in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 306,Create a table with mean and standard deviation of PM2.5 by state in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 307,Plot the rolling 30-day average PM2.5 for Odisha in 2019 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Odisha') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Odisha 2019', width=600, height=300) " 308,Tabulate the yearly average PM2.5 trend for Mumbai across all years.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Mumbai'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 309,List average PM10 by month for Muzaffarpur in 2021 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Muzaffarpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 310,"Visualize the monthly average PM10 for Haryana, Bihar, and Madhya Pradesh in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Bihar', 'Madhya Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Haryana, Bihar, UP – 2021', width=550, height=320) return chart " 311,Report the station with the lowest average PM10 in April 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 312,List average PM10 by month for Jodhpur in 2021 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Jodhpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 313,Which 15 citys recorded the highest average PM2.5 levels in 2018? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 314,"Plot the yearly average PM2.5 trends for Manipur, Gujarat, and Nagaland from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Manipur', 'Gujarat', 'Nagaland'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Manipur vs Gujarat vs Nagaland', width=550, height=320) return chart " 315,Tabulate the 10 worst states for average PM2.5 in 2021 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 316,"Comparing December 2022 to October 2022, which station showed the third least significant drop in median PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 317,Identify the station that recorded the peak 25th percentile of PM2.5 during the Winter season of 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 318,"Which union territory possesses the 2nd largest land area among the top 2 most polluted union territories, based on the standard deviation of PM2.5 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'std', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 2, 'ret': 'state'}}] " 319,Create a month-wise summary of average PM2.5 for Bengaluru in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Bengaluru'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 320,Which city displayed the lowest 25th percentile of PM10 in February 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 321,Create a summary table ranking the top 20 states by PM10 concentration in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 322,"Plot the yearly average PM2.5 trends for Nagaland, Bihar, and Karnataka from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Nagaland', 'Bihar', 'Karnataka'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Nagaland vs Bihar vs Karnataka', width=550, height=320) return chart " 323,"Identify the state with the highest 75th percentile for PM10 on March 31, 2024."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 324,"Which state having a land area exceeding 50,000 km² registers the 3rd minimum PM10 level, based on its standard deviation of PM10 level?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'std', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}] " 325,Tabulate the 15 states with the least PM10 pollution in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 326,Show the monthly average PM2.5 for Ariyalur in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ariyalur') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Ariyalur 2017', width=450, height=280) " 327,Create a table showing PM2.5 levels and population for each state in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 328,Plot the distribution of PM2.5 values in Kerala across all years using a histogram.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Kerala'].dropna(subset=['PM2.5']) df = df[['PM2.5']] chart = alt.Chart(df).mark_bar(color='steelblue', opacity=0.75).encode( x=alt.X('PM2\.5:Q', bin=alt.Bin(maxbins=40), title='PM2.5 (µg/m³)'), y=alt.Y('count()', title='Number of Observations'), tooltip=[alt.Tooltip('PM2\.5:Q', bin=True), 'count()'] ).properties(title='PM2.5 Distribution – Kerala (All Years)', width=500, height=300) return chart " 329,Tabulate average and median PM10 for all states in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 330,Determine the station with the 2nd lowest median PM2.5 in November 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 331,Show how many times PM2.5 exceeded 60 µg/m³ per day across citys in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 332,Which city recorded the highest 75th percentile of PM2.5 in April 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 333,List the average PM10 for Uttar Pradesh broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 334,Tabulate average PM2.5 for each city in West Bengal across all months of 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'West Bengal'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Asansol', 'Durgapur', 'Howrah', 'Kolkata', 'Siliguri']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 335,Show the monthly average PM2.5 for Ulhasnagar in 2022 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ulhasnagar') & (data['Timestamp'].dt.year == 2022)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Ulhasnagar 2022', width=450, height=280) " 336,Show the monthly average PM2.5 for Bengaluru in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bengaluru') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Bengaluru 2020', width=450, height=280) " 337,"Show the top 7 states by average PM10 in 2018 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2018] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(7, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 7 States by Average PM10 in 2018', width=500, height=300) return chart " 338,Which state recorded the highest 25th percentile for PM10 in the Post-Monsoon season of 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 339,Which station experienced the third most significant drop in its 75th percentile PM10 levels between October and December 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 340,"Create a grouped bar chart comparing the average PM2.5 for Puducherry, Meghalaya, and Sikkim across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'Meghalaya', 'Sikkim'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 341,"Identify the city with the third-lowest 25th percentile for PM10 on March 31, 2023."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 342,"Plot the yearly average PM2.5 trends for West Bengal, Maharashtra, and Chandigarh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['West Bengal', 'Maharashtra', 'Chandigarh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: West Bengal vs Maharashtra vs Chandigarh', width=550, height=320) return chart " 343,Determine the city exhibiting the 3rd highest average PM10 over the Winter season of 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 344,"Create a comprehensive state summary with PM10, population, and area for 2023."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 345,Generate a city × month cross-tab of mean PM2.5 for West Bengal in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'West Bengal'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Asansol', 'Durgapur', 'Howrah', 'Kolkata', 'Siliguri']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 346,Name the station showing the second-highest average PM10 for November 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 347,Identify the station that recorded the 2nd highest 75th percentile of PM10 value in July 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 348,"Compare the monthly average PM2.5 of Satna, Vatva, and Dungarpur in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Satna', 'Vatva', 'Dungarpur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Satna vs Vatva vs Dungarpur – 2024', width=550, height=320) return chart " 349,"Which union territory has the largest land area among the top 2 most polluted union territories, according to average PM2.5 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 2, 'ret': 'state'}}] " 350,Which station showed the third-lowest average PM10 in October 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 351,Show a pivot table of monthly average PM2.5 by city for Maharashtra in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Aurangabad', 'Chandrapur', 'Nagpur', 'Nashik', 'Thane']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 352,Tabulate the 10 worst states for average PM2.5 in 2023 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 353,Tabulate average PM10 for each city in Tamil Nadu across all months of 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Ariyalur', 'Chennai', 'Gummidipoondi', 'Hosur', 'Kanchipuram', 'Ooty', 'Ramanathapuram', 'Salem', 'Thoothukudi', 'Tirupur', 'Vellore']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 354,"Visualize the monthly average PM10 for Delhi, Arunachal Pradesh, and Odisha in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Delhi', 'Arunachal Pradesh', 'Odisha'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Delhi, Arunachal Pradesh, UP – 2023', width=550, height=320) return chart " 355,Tabulate area-adjusted PM10 (per km²) for each state in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM10 per km²', 'numerator': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)', 'PM10 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 356,"Plot the yearly average PM2.5 trends for Madhya Pradesh, Mizoram, and Bihar from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Madhya Pradesh', 'Mizoram', 'Bihar'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Madhya Pradesh vs Mizoram vs Bihar', width=550, height=320) return chart " 357,Show a table of the 5 cleanest states by average PM10 in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 358,"In December 2018, identify the station with the 2nd lowest median PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 359,Generate a city × month cross-tab of mean PM10 for Andhra Pradesh in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Amaravati', 'Rajamahendravaram', 'Tirupati', 'Visakhapatnam']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 360,Show a pivot table of monthly average PM10 by city for Odisha in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Odisha'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Brajrajnagar', 'Talcher']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 361,Show a cumulative area chart of PM2.5 readings for Chamarajanagar across 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Chamarajanagar') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Chamarajanagar 2022', width=600, height=300) return chart " 362,"Show the mean, median and standard deviation of PM2.5 per state in 2022 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 363,Identify the city with the 3rd highest average PM10 for June 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 364,Which state showed the 2nd highest median for PM10 in the Monsoon season of 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 365,Which city noted the 2nd minimum median PM2.5 during the Post-Monsoon season of 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 366,Which station recorded the 3rd lowest 25th percentile of PM10 during the Post-Monsoon season of 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 367,"Plot the yearly average PM2.5 trends for Himachal Pradesh, Tripura, and Sikkim from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Himachal Pradesh', 'Tripura', 'Sikkim'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Himachal Pradesh vs Tripura vs Sikkim', width=550, height=320) return chart " 368,"Identify the state (excluding UTs) with the 2nd smallest population among the top 5 most polluted states, based on 25th percentile of PM10 levels."," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 5, 'ret': 'state'}}] " 369,Determine the city exhibiting the most minimal median PM2.5 over the Post-Monsoon season of 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 370,"Compare the monthly average PM2.5 of Bagalkot, Jaisalmer, and Udaipur in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Bagalkot', 'Jaisalmer', 'Udaipur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Bagalkot vs Jaisalmer vs Udaipur – 2024', width=550, height=320) return chart " 371,"Visualize the monthly average PM10 for Tripura, Assam, and Andhra Pradesh in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tripura', 'Assam', 'Andhra Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Tripura, Assam, UP – 2024', width=550, height=320) return chart " 372,Which city had the 3rd lowest average PM10 in March 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 373,How many times did Belgaum city exceed 45 µg/m³ of PM2.5 in the year 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 45.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 374,"Plot the yearly average PM2.5 trends for Telangana, Andhra Pradesh, and Telangana from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Telangana', 'Andhra Pradesh', 'Telangana'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Telangana vs Andhra Pradesh vs Telangana', width=550, height=320) return chart " 375,How many times did Assam go above the Indian guideline for PM10 in the year 2017?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 60.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 376,Show a year-wise table of average PM10 for Maharashtra from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 377,Plot the weekly average PM2.5 for Hajipur in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Hajipur') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Hajipur 2023', width=600, height=300) return chart " 378,"Create a table of PM2.5, PM10 and station counts by state for 2024."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}, {'alias': 'Station Count', 'col': 'station', 'fn': 'nunique'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 379,"Plot the yearly average PM2.5 trends for Odisha, Delhi, and Assam from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Odisha', 'Delhi', 'Assam'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Odisha vs Delhi vs Assam', width=550, height=320) return chart " 380,"On January 5, 2020, which station recorded the minimum average PM10 level?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 381,"Plot the yearly average PM2.5 trends for Telangana, Kerala, and Sikkim from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Telangana', 'Kerala', 'Sikkim'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Telangana vs Kerala vs Sikkim', width=550, height=320) return chart " 382,Generate a dual-pollutant summary table (PM2.5 and PM10) by city for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 383,Tabulate the top 10 citys for PM2.5 in 2017 along with their corresponding PM10 values.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 384,Identify the station with the 2nd lowest 25th percentile of PM2.5 in December 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 385,Identify the station that recorded the lowest median PM2.5 value in October 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 386,Determine the city showing the highest 75th percentile of PM10 for October 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 387,Tabulate average PM2.5 for each city in Gujarat across all months of 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Gujarat'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Ahmedabad', 'Ankleshwar', 'Gandhinagar', 'Surat', 'Vapi', 'Vatva']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 388,Show the monthly average PM10 trend for Haldia from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Haldia'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Haldia (2017–2022)', width=600, height=300) return chart " 389,"Compare the monthly average PM2.5 of Ulhasnagar, Badlapur, and Panipat in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Ulhasnagar', 'Badlapur', 'Panipat'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Ulhasnagar vs Badlapur vs Panipat – 2019', width=550, height=320) return chart " 390,"Compare the monthly average PM2.5 of Hubballi, Darbhanga, and Ramanagara in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Hubballi', 'Darbhanga', 'Ramanagara'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Hubballi vs Darbhanga vs Ramanagara – 2019', width=550, height=320) return chart " 391,"Which union territory possesses the 2nd smallest land area among the top 4 most polluted union territories, based on median PM10 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 4, 'ret': 'state'}}] " 392,Tabulate the monthly mean PM10 levels for Gurugram during 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Gurugram'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 393,Tabulate days with PM10 > 100 µg/m³ and exceedance percentage per city in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 394,Generate a monthly average PM10 table for Telangana for the year 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Telangana'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 395,"Scatter plot PM2.5 vs PM10 for Rajasthan stations in 2024, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Rajasthan') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Rajasthan Stations 2024', width=450, height=350) " 396,"In 2023, which station ranked with the second smallest decrease in average PM2.5 levels from October to December?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 397,Show a monthly bar chart of the number of days Meghalaya exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Meghalaya') & (data['Timestamp'].dt.year == 2022)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Meghalaya Exceeded WHO PM2.5 Guideline per Month – 2022', width=500, height=300) return chart " 398,"Which union territory exhibits the 3rd lowest PM10 concentration per square kilometer, based on the variance of PM10 values?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'var', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_km2', 'numerator': 'PM10', 'denominator': 'area (km2)'}}, {'op': 'SORT', 'params': {'col': 'pm_per_km2', 'ascending': True}}] " 399,"Identify the state with the minimum median PM10 on March 31, 2021."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 400,"Plot the yearly average PM2.5 trends for Chhattisgarh, West Bengal, and Tamil Nadu from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chhattisgarh', 'West Bengal', 'Tamil Nadu'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Chhattisgarh vs West Bengal vs Tamil Nadu', width=550, height=320) return chart " 401,"Which city had the lowest PM10 readings on January 14, 2022?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 402,Plot the monthly average PM2.5 trend for Tripura from 2017 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Tripura'].copy() df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly Average PM2.5 Trend – Tripura (2017–2024)', width=600, height=300) return chart " 403,Tabulate the 5 worst states for average PM10 in 2018 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 404,Show the monthly average PM2.5 for Bihar across each year from 2017 to 2024 as small multiples (faceted by year).," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Bihar'].copy() df['Year'] = df['Timestamp'].dt.year df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5'), tooltip=['Year:O','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet( facet=alt.Facet('Year:O', title='Year'), columns=4 ).properties(title='Monthly PM2.5 in Bihar by Year (2017–2024)') return chart " 405,How many stations in Punjab surpassed the WHO guideline for PM2.5 in the year 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 15.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 406,Create a month-wise summary of average PM2.5 for Jodhpur in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Jodhpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 407,Generate a year-by-year summary table of PM10 readings for Assam.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Assam'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 408,Show PM2.5 exceedance count and rate (%) above 100 µg/m³ per state in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 409,Create a month-wise PM10 breakdown table across cities in Madhya Pradesh for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Bhopal', 'Damoh', 'Dewas', 'Gwalior', 'Indore', 'Jabalpur', 'Katni', 'Mandideep', 'Pithampur', 'Ratlam', 'Sagar', 'Satna', 'Singrauli', 'Ujjain']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 410,"Visualize the monthly average PM10 for Himachal Pradesh, Chhattisgarh, and Meghalaya in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Himachal Pradesh', 'Chhattisgarh', 'Meghalaya'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Himachal Pradesh, Chhattisgarh, UP – 2023', width=550, height=320) return chart " 411,Which city recorded the 2nd highest 25th percentile of PM10 in July 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 412,Report the city that had the 3rd lowest median PM10 in June 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 413,Determine the state with the 2nd highest median PM10 in October 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 414,"On August 15, 2018, which city showed the third-lowest PM2.5 concentrations?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 415,"Considering 2024, what day of the week had the highest 75th percentile of PM10 pollution levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'Timestamp'}}] " 416,"Show descriptive statistics of PM2.5 (mean, median, std, min, max) per state in 2021."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 417,"Scatter plot PM2.5 vs PM10 for Madhya Pradesh stations in 2021, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Madhya Pradesh') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Madhya Pradesh Stations 2021', width=450, height=350) " 418,"Show the variability of PM2.5 across citys in 2023 using mean, median, and standard deviation."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'q25', 'median', 'q75']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 419,"On March 31, 2018, which city had the second-highest 25th percentile for PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 420,Show PM10 exceedance count and rate (%) above 150 µg/m³ per state in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 150'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 421,What date within the previous five years showed Baddi's 2nd lowest PM2.5 reading?," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 5}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'Timestamp'}}] " 422,Create a table showing PM10 spread (min to max) and central tendency per city for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 423,Show a ranked table of the 15 most polluted states by average PM10 in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 424,"Plot the yearly average PM2.5 trends for Jammu and Kashmir, Meghalaya, and Rajasthan from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jammu and Kashmir', 'Meghalaya', 'Rajasthan'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Jammu and Kashmir vs Meghalaya vs Rajasthan', width=550, height=320) return chart " 425,"Scatter plot PM2.5 vs PM10 for Jharkhand stations in 2020, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Jharkhand') & (data['Timestamp'].dt.year == 2020)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Jharkhand Stations 2020', width=450, height=350) " 426,"In January 2023, report the city with the 2nd lowest average PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 427,Show the monthly average PM2.5 for Nandesari in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Nandesari') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Nandesari 2017', width=450, height=280) " 428,Tabulate the monthly mean PM10 levels for Thiruvananthapuram during 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Thiruvananthapuram'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 429,Which state experienced the least significant drop in its average PM2.5 levels between October and December 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 430,Generate a year-by-year summary table of PM2.5 readings for Guwahati.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Guwahati'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 431,Show a cumulative area chart of PM2.5 readings for Bihar Sharif across 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bihar Sharif') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Bihar Sharif 2022', width=600, height=300) return chart " 432,"Which union territory having a land area exceeding 1,000 km² registers the minimum PM10 level, according to its variance of PM10 level?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'var', 'col': 'PM10'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}] " 433,"Compare the monthly average PM2.5 of Karwar, Sirohi, and Gandhinagar in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Karwar', 'Sirohi', 'Gandhinagar'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Karwar vs Sirohi vs Gandhinagar – 2022', width=550, height=320) return chart " 434,"Which state (excluding Union Territories) has the 3rd minimum land area among the top 10 most polluted states, according to median PM10 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 10, 'ret': 'state'}}] " 435,"Visualize the monthly average PM10 for Assam, Madhya Pradesh, and Punjab in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Assam', 'Madhya Pradesh', 'Punjab'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Assam, Madhya Pradesh, UP – 2019', width=550, height=320) return chart " 436,Create a table with mean and standard deviation of PM10 by city in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 437,List the average PM2.5 for Ghaziabad broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Ghaziabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 438,Show the monthly average PM10 trend for Ballabgarh from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Ballabgarh'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Ballabgarh (2019–2024)', width=600, height=300) return chart " 439,"Visualize the monthly average PM10 for Meghalaya, Assam, and Rajasthan in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Meghalaya', 'Assam', 'Rajasthan'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Meghalaya, Assam, UP – 2022', width=550, height=320) return chart " 440,"In February 2023, report the station with the 3rd lowest 25th percentile of PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 441,"Plot the yearly average PM2.5 trends for Assam, Andhra Pradesh, and Mizoram from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Assam', 'Andhra Pradesh', 'Mizoram'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Assam vs Andhra Pradesh vs Mizoram', width=550, height=320) return chart " 442,"Show mean, median, minimum, and maximum PM10 for each city in 2024 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 443,Show a cumulative area chart of PM2.5 readings for Prayagraj across 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Prayagraj') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Prayagraj 2023', width=600, height=300) return chart " 444,Generate a monthly average PM2.5 table for Delhi for the year 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Delhi'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 445,"Scatter plot PM2.5 vs PM10 for Gujarat stations in 2021, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Gujarat') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Gujarat Stations 2021', width=450, height=350) " 446,Which station had the 3rd highest 25th percentile of PM2.5 in November 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 447,How many times did Faridabad city go above 45 µg/m³ of PM2.5 in 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 45.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 448,Show the monthly average PM2.5 for Guwahati in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Guwahati') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Guwahati 2019', width=450, height=280) " 449,Which city registered the minimum 75th percentile of PM10 during the Summer season of 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 450,"Compare the monthly average PM2.5 of Yadgir, Dhule, and Korba in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Yadgir', 'Dhule', 'Korba'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Yadgir vs Dhule vs Korba – 2019', width=550, height=320) return chart " 451,Tabulate the 10 citys with the least PM2.5 pollution in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 452,"Which state (excluding Union Territories) has the 2nd highest PM10 concentration per square kilometer, based on total PM10 values?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'sum', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_km2', 'numerator': 'PM10', 'denominator': 'area (km2)'}}, {'op': 'SORT', 'params': {'col': 'pm_per_km2', 'ascending': False}}] " 453,"Visualize the monthly average PM10 for Maharashtra, Odisha, and Jammu and Kashmir in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Maharashtra', 'Odisha', 'Jammu and Kashmir'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Maharashtra, Odisha, UP – 2017', width=550, height=320) return chart " 454,"Scatter plot PM2.5 vs PM10 for Meghalaya stations in 2023, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Meghalaya') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Meghalaya Stations 2023', width=450, height=350) " 455,"Plot the yearly average PM2.5 trends for Nagaland, West Bengal, and Rajasthan from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Nagaland', 'West Bengal', 'Rajasthan'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Nagaland vs West Bengal vs Rajasthan', width=550, height=320) return chart " 456,Create a statistical summary table of PM2.5 readings by city for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'q25', 'median', 'q75']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 457,"Plot the yearly average PM2.5 trends for Uttar Pradesh, Nagaland, and Himachal Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttar Pradesh', 'Nagaland', 'Himachal Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Uttar Pradesh vs Nagaland vs Himachal Pradesh', width=550, height=320) return chart " 458,"Create a faceted bar chart showing top 15 states by average PM2.5 per year for 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year.isin([2017,2018,2019,2020])].copy() df['Year'] = df['Timestamp'].dt.year agg = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() top = agg.groupby('Year').apply(lambda x: x.nlargest(15,'PM2.5')).reset_index(drop=True) chart = alt.Chart(top).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Avg PM2.5'), y=alt.Y('state:N', sort='-x'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet(facet='Year:O', columns=2).properties(title='Top 15 States by PM2.5 per Year') return chart " 459,Tabulate mean PM2.5 alongside state population figures for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 460,Show a monthly breakdown table of average PM2.5 for Meerut in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Meerut'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 461,"Create a grouped bar chart comparing the average PM2.5 for Uttar Pradesh, Rajasthan, and Haryana across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttar Pradesh', 'Rajasthan', 'Haryana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 462,Create a per-capita PM10 summary table by state for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM10 per million', 'numerator': 'PM10', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'PM10 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 463,Determine the city with the 3rd lowest median PM10 in July 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 464,"In 2023, which city will rank with the second largest reduction in average PM10 levels from October to December?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 465,"Over all years, which August experienced the maximum median PM10 concentration?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'Timestamp'}}] " 466,Determine the city exhibiting the 2nd most minimal average PM2.5 over the Post-Monsoon season of 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 467,How many times did Haryana exceed 75 µg/m³ of PM10 in 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 75.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 468,Show a monthly bar chart of the number of days Odisha exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Odisha') & (data['Timestamp'].dt.year == 2021)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Odisha Exceeded WHO PM2.5 Guideline per Month – 2021', width=500, height=300) return chart " 469,Create a month-wise PM2.5 breakdown table across cities in Assam for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Assam'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Byrnihat', 'Guwahati', 'Nalbari', 'Silchar', 'Sivasagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 470,Generate a table showing the 10 most polluted citys based on mean PM2.5 for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 471,Which station registered the highest 75th percentile of PM10 during May 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 472,"Show mean, median, minimum, and maximum PM2.5 for each city in 2020 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 473,Which 10 citys had the lowest mean PM10 in 2022? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 474,Which state experienced the second most significant drop in its 25th percentile PM2.5 levels between October and December 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 475,Generate a table showing the 10 most polluted citys based on mean PM2.5 for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 476,Tabulate the monthly mean PM10 levels for Kerala during 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 477,"Show the mean, median and standard deviation of PM2.5 per state in 2019 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 478,"Compare the monthly average PM2.5 of Nagaur, Bhopal, and Chhapra in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Nagaur', 'Bhopal', 'Chhapra'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Nagaur vs Bhopal vs Chhapra – 2023', width=550, height=320) return chart " 479,"Identify the state (excluding UTs) with the 2nd smallest population among the top 10 most polluted states, based on average PM2.5 levels."," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 10, 'ret': 'state'}}] " 480,"Plot the yearly average PM2.5 trends for Chandigarh, Punjab, and Tripura from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chandigarh', 'Punjab', 'Tripura'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Chandigarh vs Punjab vs Tripura', width=550, height=320) return chart " 481,Report the state that had the lowest 25th percentile of PM2.5 in May 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 482,Show a monthly breakdown table of average PM10 for Solapur in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Solapur'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 483,"Identify the station with the second-lowest 75th percentile for PM2.5 on March 31, 2024."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 484,Which station registered the 2nd lowest 25th percentile of PM2.5 during September 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 485,Show a table of the 5 cleanest states by average PM10 in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 486,Calculate the average PM2.5 level on Fridays in Andhra Pradesh.," [{'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}] " 487,Create a table showing annual mean PM10 levels for Chandigarh (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Chandigarh'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 488,"Show mean, median, minimum, and maximum PM10 for each state in 2021 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 489,"Plot the yearly average PM2.5 trends for Delhi, Chandigarh, and Jharkhand from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Delhi', 'Chandigarh', 'Jharkhand'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Delhi vs Chandigarh vs Jharkhand', width=550, height=320) return chart " 490,Which state possessed the highest 25th percentile for PM10 in the Post-Monsoon season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 491,Show a year-wise table of average PM2.5 for Bhopal from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Bhopal'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 492,Tabulate daily PM2.5 exceedances (above 100 µg/m³) per state for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 493,Show the monthly average PM2.5 for Visakhapatnam in 2024 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Visakhapatnam') & (data['Timestamp'].dt.year == 2024)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Visakhapatnam 2024', width=450, height=280) " 494,Plot the rolling 30-day average PM2.5 for Mizoram in 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Mizoram') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Mizoram 2022', width=600, height=300) " 495,"Report the union territory having the second largest population among the top 4 most polluted union territories, when pollution is measured by standard deviation of PM10 levels."," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'std', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 4, 'ret': 'state'}}] " 496,Which 15 states recorded the highest average PM10 levels in 2017? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 497,Determine the city exhibiting the highest 75th percentile of PM10 in January 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 498,Tabulate average PM2.5 for each city in Karnataka across all months of 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Bagalkot', 'Bengaluru', 'Chikkaballapur', 'Chikkamagaluru', 'Mysuru', 'Ramanagara', 'Shivamogga']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 499,Determine the station with the 3rd highest median PM2.5 in March 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 500,Which city experienced the 3rd highest 75th percentile for PM2.5 in the Post-Monsoon season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 501,Create a table with mean and standard deviation of PM10 by state in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 502,Tabulate daily PM10 exceedances (above 150 µg/m³) per city for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 503,Plot the weekly average PM2.5 for Ulhasnagar in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ulhasnagar') & (data['Timestamp'].dt.year == 2024)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Ulhasnagar 2024', width=600, height=300) return chart " 504,"Create a grouped bar chart comparing the average PM2.5 for Uttarakhand, Puducherry, and Uttarakhand across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttarakhand', 'Puducherry', 'Uttarakhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 505,Identify the station that recorded the highest 75th percentile of PM10 value in September 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 506,"Visualize the monthly average PM10 for Uttarakhand, Jammu and Kashmir, and Mizoram in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttarakhand', 'Jammu and Kashmir', 'Mizoram'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Uttarakhand, Jammu and Kashmir, UP – 2022', width=550, height=320) return chart " 507,Which station displayed the 2nd highest median PM2.5 in August 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 508,Which state registered the minimum 25th percentile of PM2.5 in the Summer season of 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 509,Show the monthly average PM2.5 for Mandikhera in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Mandikhera') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Mandikhera 2019', width=450, height=280) " 510,Show a monthly bar chart of the number of days Madhya Pradesh exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Madhya Pradesh') & (data['Timestamp'].dt.year == 2024)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Madhya Pradesh Exceeded WHO PM2.5 Guideline per Month – 2024', width=500, height=300) return chart " 511,"In November 2022, identify the city with the 2nd highest 75th percentile of PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 512,"Visualize the monthly average PM10 for Puducherry, Maharashtra, and Haryana in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'Maharashtra', 'Haryana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Puducherry, Maharashtra, UP – 2022', width=550, height=320) return chart " 513,"Plot the yearly average PM2.5 trends for Gujarat, Manipur, and Puducherry from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Gujarat', 'Manipur', 'Puducherry'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Gujarat vs Manipur vs Puducherry', width=550, height=320) return chart " 514,Report the station with the 2nd lowest average PM10 in July 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 515,Show a monthly breakdown table of average PM2.5 for Tamil Nadu in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 516,"Show the top 12 states by average PM10 in 2017 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2017] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(12, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 12 States by Average PM10 in 2017', width=500, height=300) return chart " 517,Show a pivot table of monthly average PM10 by city for Andhra Pradesh in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Amaravati', 'Anantapur', 'Chittoor', 'Kadapa', 'Rajamahendravaram', 'Tirupati', 'Vijayawada', 'Visakhapatnam']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 518,"Visualize the monthly average PM10 for Uttarakhand, Nagaland, and Mizoram in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttarakhand', 'Nagaland', 'Mizoram'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Uttarakhand, Nagaland, UP – 2023', width=550, height=320) return chart " 519,Show the monthly average PM10 trend for Moradabad from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Moradabad'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Moradabad (2019–2024)', width=600, height=300) return chart " 520,"Scatter plot PM2.5 vs PM10 for Assam stations in 2017, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Assam') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Assam Stations 2017', width=450, height=350) " 521,Tabulate average PM10 for each city in Andhra Pradesh across all months of 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Amaravati', 'Rajamahendravaram', 'Tirupati', 'Visakhapatnam']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 522,Which city had the 3rd lowest average PM2.5 in February 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 523,Show annual average PM2.5 for Ghaziabad as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Ghaziabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 524,Show the monthly average PM2.5 for Singrauli in 2024 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Singrauli') & (data['Timestamp'].dt.year == 2024)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Singrauli 2024', width=450, height=280) " 525,Create a table showing PM2.5 spread (min to max) and central tendency per city for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 526,Create a table of PM2.5 per unit area for all states in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, { 'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM2.5 per km²', 'numerator': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)', 'PM2.5 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 527,Identify the state showing the highest 75th percentile of PM10 concentration in relation to its population density.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_capita', 'numerator': 'PM10', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'pm_per_capita', 'ascending': False}}] " 528,Show a cumulative area chart of PM2.5 readings for Bathinda across 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bathinda') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Bathinda 2024', width=600, height=300) return chart " 529,"Identify the state with the second-highest PM10 measurements on January 14, 2021."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 530,Show the monthly average PM10 trend for Rajamahendravaram from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Rajamahendravaram'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Rajamahendravaram (2019–2024)', width=600, height=300) return chart " 531,"Scatter plot PM2.5 vs PM10 for Sikkim stations in 2024, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Sikkim') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Sikkim Stations 2024', width=450, height=350) " 532,"Visualize the monthly average PM10 for Tamil Nadu, Haryana, and Arunachal Pradesh in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Haryana', 'Arunachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Tamil Nadu, Haryana, UP – 2022', width=550, height=320) return chart " 533,"Visualize the monthly average PM10 for Jharkhand, Jharkhand, and Sikkim in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Jharkhand', 'Sikkim'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Jharkhand, Jharkhand, UP – 2019', width=550, height=320) return chart " 534,"Show a table of average PM10, population, and area for all states in 2019."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 535,Plot the top 13 states by average PM2.5 in 2017 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2017] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(13, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 13 States by Average PM2.5 in 2017', width=500, height=300) return chart " 536,Identify the city with the 2nd highest 25th percentile of PM2.5 for February 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 537,Which city registered the 2nd lowest 25th percentile of PM2.5 during June 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 538,Tabulate average and median PM10 for all citys in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 539,"In 2019, which season (Winter, Summer, Monsoon, Post-Monsoon) was associated with the second-lowest average PM10 concentrations?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'season'}}] " 540,Report which state experienced the 2nd most minimal median PM2.5 throughout the Post-Monsoon season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 541,"In May 2021, identify the state with the highest 25th percentile of PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 542,Show a cumulative area chart of PM2.5 readings for Kochi across 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Kochi') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Kochi 2021', width=600, height=300) return chart " 543,Which 20 citys recorded the highest average PM2.5 levels in 2021? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 544,List states by PM10 concentration per million inhabitants in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM10 per million', 'numerator': 'PM10', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'PM10 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 545,Which state noted the 2nd minimum average PM2.5 in the Summer season of 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 546,"Create a grouped bar chart comparing the average PM2.5 for Uttarakhand, Andhra Pradesh, and Rajasthan across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttarakhand', 'Andhra Pradesh', 'Rajasthan'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 547,Show the monthly average PM2.5 for Howrah in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Howrah') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Howrah 2020', width=450, height=280) " 548,"Plot average PM2.5 (2024) vs state population as a scatter plot, labeling each point with the state name."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): pm = data[data['Timestamp'].dt.year == 2024].groupby('state')['PM2.5'].mean().reset_index().dropna() df = pm.merge(states_data, on='state') points = alt.Chart(df).mark_point(filled=True, size=80).encode( x=alt.X('population:Q', title='Population', axis=alt.Axis(format='~s')), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('population:Q', format=',')] ) labels = alt.Chart(df).mark_text(align='left', dx=5, fontSize=9).encode( x='population:Q', y='PM2\.5:Q', text='state:N' ) return (points + labels).properties(title='PM2.5 vs Population by State – 2024', width=500, height=400) " 549,"Plot the yearly average PM2.5 trends for Odisha, Kerala, and Jharkhand from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Odisha', 'Kerala', 'Jharkhand'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Odisha vs Kerala vs Jharkhand', width=550, height=320) return chart " 550,Which city experienced the second most significant drop in its median PM10 levels between October and December 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 551,Identify the station that recorded the 2nd lowest average PM10 value in November 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 552,Plot the top 8 states by average PM2.5 in 2017 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2017] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(8, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 8 States by Average PM2.5 in 2017', width=500, height=300) return chart " 553,"Show mean, median, minimum, and maximum PM10 for each city in 2021 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 554,"For the period October to December 2021, which state had the third smallest decrease in 75th percentile PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 555,"Amidst the COVID-19 lockdown in April 2020, which city showed the second-lowest PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 556,"In December 2022, report the city with the highest median PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 557,Which city was second in terms of highest average PM10 for September 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 558,Show a table of the 10 cleanest citys by average PM2.5 in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 559,Plot the rolling 30-day average PM2.5 for Jammu and Kashmir in 2019 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Jammu and Kashmir') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Jammu and Kashmir 2019', width=600, height=300) " 560,Show PM2.5 exceedance count and rate (%) above 60 µg/m³ per state in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 561,Show a table of the 15 cleanest citys by average PM10 in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 562,Tabulate the 5 worst citys for average PM2.5 in 2023 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 563,"Visualize the monthly average PM10 for Jharkhand, Karnataka, and Arunachal Pradesh in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Karnataka', 'Arunachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Jharkhand, Karnataka, UP – 2023', width=550, height=320) return chart " 564,Identify the state showing the 4th highest average PM10 concentration adjusted for population density.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_capita', 'numerator': 'PM10', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'pm_per_capita', 'ascending': False}}] " 565,"Show the mean, median and standard deviation of PM10 per city in 2022 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 566,Tabulate the monthly mean PM10 levels for Tripura during 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tripura'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 567,What count of Puducherry stations went above the WHO guideline for PM10 in 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 15.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 568,"Compare the monthly average PM2.5 of Ooty, Rupnagar, and Visakhapatnam in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Ooty', 'Rupnagar', 'Visakhapatnam'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Ooty vs Rupnagar vs Visakhapatnam – 2023', width=550, height=320) return chart " 569,Which 10 states had the lowest mean PM2.5 in 2021? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 570,"Scatter plot PM2.5 vs PM10 for Arunachal Pradesh stations in 2021, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Arunachal Pradesh') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Arunachal Pradesh Stations 2021', width=450, height=350) " 571,Which state had the highest 75th percentile of PM10 in December 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 572,Determine the state that showed the 2nd lowest 75th percentile of PM2.5 over the Winter season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 573,"Show mean, median, minimum, and maximum PM2.5 for each city in 2021 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 574,Show the monthly average PM2.5 for Singrauli in 2023 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Singrauli') & (data['Timestamp'].dt.year == 2023)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Singrauli 2023', width=450, height=280) " 575,"On March 31, 2019, which station recorded the second-highest 25th percentile for PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 576,"Plot the yearly average PM2.5 trends for Rajasthan, Jharkhand, and Delhi from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Jharkhand', 'Delhi'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Rajasthan vs Jharkhand vs Delhi', width=550, height=320) return chart " 577,"In 2022, which week of the year was associated with the second-highest median PM10 concentrations?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'week'}}] " 578,Show a table of average PM2.5 and PM10 for all states in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 579,Create a table with mean and standard deviation of PM2.5 by state in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 580,Show the number of days each state exceeded a PM2.5 threshold of 60 µg/m³ in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 581,Plot the rolling 30-day average PM2.5 for Kerala in 2017 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Kerala') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Kerala 2017', width=600, height=300) " 582,"Create a grouped bar chart comparing the average PM2.5 for Puducherry, Punjab, and Tripura across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'Punjab', 'Tripura'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 583,"Which state (excluding UTs) possesses the 2nd smallest population within the top 10 most polluted states, determined by standard deviation of PM10 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'std', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 10, 'ret': 'state'}}] " 584,"Compare the monthly average PM2.5 of Kolkata, Hubballi, and Meerut in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Kolkata', 'Hubballi', 'Meerut'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Kolkata vs Hubballi vs Meerut – 2023', width=550, height=320) return chart " 585,"Compare the monthly average PM2.5 of Rajamahendravaram, Araria, and Jalgaon in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Rajamahendravaram', 'Araria', 'Jalgaon'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Rajamahendravaram vs Araria vs Jalgaon – 2017', width=550, height=320) return chart " 586,"In February 2023, report the state with the 3rd highest 75th percentile of PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 587,List states with their average PM10 and area for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 588,Determine the state exhibiting the 2nd most minimal 25th percentile of PM10 over the Winter season of 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 589,"Visualize the monthly average PM10 for Mizoram, Kerala, and Puducherry in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Mizoram', 'Kerala', 'Puducherry'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Mizoram, Kerala, UP – 2022', width=550, height=320) return chart " 590,"Plot the yearly average PM2.5 trends for Gujarat, Uttar Pradesh, and Telangana from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Gujarat', 'Uttar Pradesh', 'Telangana'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Gujarat vs Uttar Pradesh vs Telangana', width=550, height=320) return chart " 591,Create a statistical summary table of PM10 readings by state for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 592,"Plot the yearly average PM2.5 trends for Mizoram, Chandigarh, and Telangana from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Mizoram', 'Chandigarh', 'Telangana'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Mizoram vs Chandigarh vs Telangana', width=550, height=320) return chart " 593,"On March 31, 2024, which state recorded the lowest 25th percentile of PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 594,Identify the state that registered the third highest 25th percentile of PM2.5 during the Summer season of 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 595,List average PM2.5 by month for Bengaluru in 2017 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Bengaluru'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 596,"Plot the yearly average PM2.5 trends for Jharkhand, Odisha, and Haryana from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Odisha', 'Haryana'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Jharkhand vs Odisha vs Haryana', width=550, height=320) return chart " 597,Which 15 states recorded the highest average PM10 levels in 2019? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 598,Tabulate the monthly mean PM2.5 levels for Madhya Pradesh during 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 599,"Taking all years into account, which June experienced the third-highest median PM10 concentration?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'Timestamp'}}] " 600,Generate a city × month cross-tab of mean PM2.5 for Punjab in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Amritsar', 'Bathinda', 'Jalandhar', 'Khanna', 'Ludhiana', 'Mandi Gobindgarh', 'Patiala', 'Rupnagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 601,Tabulate the 20 worst states for average PM2.5 in 2017 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 602,Plot the weekly average PM2.5 for Manguraha in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Manguraha') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Manguraha 2023', width=600, height=300) return chart " 603,Generate a year-by-year summary table of PM10 readings for Meghalaya.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Meghalaya'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 604,Tabulate days with PM10 > 150 µg/m³ and exceedance percentage per state in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 150'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 605,Determine the state that showed the 3rd highest average PM2.5 over the Winter season of 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 606,Which 5 citys had the lowest mean PM10 in 2020? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 607,Show a monthly breakdown table of average PM2.5 for Bihar in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Bihar'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 608,List states by PM10 concentration per million inhabitants in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM10 per million', 'numerator': 'PM10', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'PM10 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 609,Report the station that had the lowest 75th percentile of PM10 in July 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 610,Create a month-wise summary of average PM2.5 for Telangana in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Telangana'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 611,Create a table showing annual mean PM10 levels for Muzaffarpur (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Muzaffarpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 612,Show a cumulative area chart of PM2.5 readings for Ramanagara across 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ramanagara') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Ramanagara 2021', width=600, height=300) return chart " 613,Tabulate the 5 worst citys for average PM10 in 2017 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 614,"Which state showed the second-lowest PM2.5 measurements on January 14, 2021?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 615,Show a cumulative area chart of PM2.5 readings for Darbhanga across 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Darbhanga') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Darbhanga 2021', width=600, height=300) return chart " 616,Which state received the 2nd lowest NCAP funding relative to the standard deviation of its PM10 concentration in 2020 (FY 2019-20)?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'std', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2020_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 617,Show a table of the 15 cleanest citys by average PM10 in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 618,Show a bar chart of the top 15 cities by median PM2.5 in 2019.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2019] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(15, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 15 Cities by Median PM2.5 in 2019', width=500, height=300) return chart " 619,Create a table of PM10 standard violations (>150 µg/m³) per state in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 620,"Create a grouped bar chart comparing the average PM2.5 for Chhattisgarh, Chhattisgarh, and Assam across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chhattisgarh', 'Chhattisgarh', 'Assam'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 621,List the average PM10 for Himachal Pradesh broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Himachal Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 622,Show the monthly average PM2.5 for Guwahati in 2022 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Guwahati') & (data['Timestamp'].dt.year == 2022)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Guwahati 2022', width=450, height=280) " 623,Show a table of the 5 cleanest citys by average PM10 in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 624,List average PM2.5 by month for Faridabad in 2017 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Faridabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 625,Which city registered the 2nd maximum 75th percentile of PM10 in the Summer season of 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 626,Name the station with the highest 75th percentile for PM2.5 in June 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 627,"Plot the yearly average PM2.5 trends for Jammu and Kashmir, Himachal Pradesh, and Telangana from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jammu and Kashmir', 'Himachal Pradesh', 'Telangana'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Jammu and Kashmir vs Himachal Pradesh vs Telangana', width=550, height=320) return chart " 628,Show a pivot table of monthly average PM10 by state for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Arunachal Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Chhattisgarh', 'Delhi', 'Gujarat', 'Haryana', 'Jammu and Kashmir', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Meghalaya', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 629,Which station showed the 2nd highest 75th percentile for PM2.5 in the Monsoon season of 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 630,Determine the city with the third highest PM2.5 level on 27 January 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 631,Show the monthly average PM10 trend for Udaipur from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Udaipur'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Udaipur (2017–2022)', width=600, height=300) return chart " 632,Create a table of state PM2.5 levels and geographic area for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 633,"Plot average PM2.5 (2023) vs state population as a scatter plot, labeling each point with the state name."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): pm = data[data['Timestamp'].dt.year == 2023].groupby('state')['PM2.5'].mean().reset_index().dropna() df = pm.merge(states_data, on='state') points = alt.Chart(df).mark_point(filled=True, size=80).encode( x=alt.X('population:Q', title='Population', axis=alt.Axis(format='~s')), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('population:Q', format=',')] ) labels = alt.Chart(df).mark_text(align='left', dx=5, fontSize=9).encode( x='population:Q', y='PM2\.5:Q', text='state:N' ) return (points + labels).properties(title='PM2.5 vs Population by State – 2023', width=500, height=400) " 634,Which state experienced the second most significant drop in its average PM2.5 levels between October and December 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 635,Create a month-wise PM10 breakdown table across cities in Tamil Nadu for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Chennai', 'Gummidipoondi', 'Thoothukudi']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 636,Show annual average PM10 for Gujarat as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Gujarat'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 637,Report which state registered the 3rd most minimal 25th percentile of PM10 throughout the Summer season of 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 638,Create a table of PM10 per unit area for all states in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM10 per km²', 'numerator': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)', 'PM10 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 639,Plot the weekly average PM2.5 for Jhunjhunu in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Jhunjhunu') & (data['Timestamp'].dt.year == 2024)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Jhunjhunu 2024', width=600, height=300) return chart " 640,How many times did Odisha exceed the Indian guideline for PM2.5 in the year 2017?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 60.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 641,Plot the monthly average PM2.5 trend for Chhattisgarh from 2017 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Chhattisgarh'].copy() df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly Average PM2.5 Trend – Chhattisgarh (2017–2024)', width=600, height=300) return chart " 642,On which date in the previous five years did Palwal record its 3rd minimum PM2.5 level?," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 5}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'Timestamp'}}] " 643,Create a summary table ranking the top 15 states by PM2.5 concentration in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 644,"Scatter plot PM2.5 vs PM10 for Madhya Pradesh stations in 2017, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Madhya Pradesh') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Madhya Pradesh Stations 2017', width=450, height=350) " 645,Which state registered the peak 25th percentile of PM10 in the Post-Monsoon season of 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 646,Identify the city with the third-lowest average PM2.5 value in February 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 647,Show a monthly bar chart of the number of days Gujarat exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Gujarat') & (data['Timestamp'].dt.year == 2023)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Gujarat Exceeded WHO PM2.5 Guideline per Month – 2023', width=500, height=300) return chart " 648,"Compare the monthly average PM2.5 of Madikeri, Pudukottai, and Nashik in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Madikeri', 'Pudukottai', 'Nashik'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Madikeri vs Pudukottai vs Nashik – 2019', width=550, height=320) return chart " 649,Generate a year-by-year summary table of PM10 readings for Telangana.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Telangana'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 650,"In October 2021, which state registered the 3rd highest median PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 651,Which 10 citys recorded the highest average PM10 levels in 2020? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 652,Create a summary table ranking the top 10 states by PM2.5 concentration in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 653,Create a table showing annual mean PM2.5 levels for Jaipur (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Jaipur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 654,Identify the station with the 2nd lowest 75th percentile of PM2.5 in December 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 655,"Plot the yearly average PM2.5 trends for Jharkhand, Kerala, and Karnataka from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Kerala', 'Karnataka'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Jharkhand vs Kerala vs Karnataka', width=550, height=320) return chart " 656,"Compare the monthly average PM2.5 of Mira-Bhayandar, Tumakuru, and Mandideep in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Mira-Bhayandar', 'Tumakuru', 'Mandideep'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Mira-Bhayandar vs Tumakuru vs Mandideep – 2018', width=550, height=320) return chart " 657,"Tabulate the distribution of PM10 per city in 2018 including mean, median, and std."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 658,Tabulate average PM10 for each state across all months in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Delhi', 'Haryana', 'Jharkhand', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Odisha', 'Punjab', 'Rajasthan', 'Telangana', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 659,What date during the past two years showed Jaisalmer's 2nd highest PM10 reading?," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 2}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'Timestamp'}}] " 660,Create a ranked table of the 10 best-performing states by PM10 in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 661,Which state experienced the highest 25th percentile for PM2.5 in the Winter season of 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 662,"Tabulate PM10 levels, population, and land area per state in 2020."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 663,"Create a grouped bar chart comparing the average PM2.5 for Gujarat, Tamil Nadu, and Tripura across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Gujarat', 'Tamil Nadu', 'Tripura'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 664,Show a heatmap of average PM2.5 for the top 6 most polluted states by month for 2017.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(6).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 6 Polluted States by Month (2017)', width=500, height=300) return chart " 665,Report the city with the 3rd lowest median PM2.5 in March 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 666,Tabulate the monthly mean PM10 levels for Varanasi during 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Varanasi'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 667,Show PM10 averages in a state × month matrix for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Arunachal Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Chhattisgarh', 'Delhi', 'Gujarat', 'Haryana', 'Himachal Pradesh', 'Jammu and Kashmir', 'Jharkhand', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Meghalaya', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Sikkim', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh', 'Uttarakhand', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 668,Tabulate average PM2.5 for each city in Maharashtra across all months of 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Kalyan', 'Mumbai', 'Nagpur', 'Nashik', 'Navi Mumbai', 'Pune', 'Solapur']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 669,"For Ramanagara, what date in the last two years showed the second-highest PM2.5 reading?"," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 2}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'Timestamp'}}] " 670,"Show the variability of PM10 across states in 2022 using mean, median, and standard deviation."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 671,Determine the state with the third-highest 75th percentile for PM10 in March 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 672,"Identify the city that experienced the lowest PM10 measurements on January 14, 2021."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 673,Plot the rolling 30-day average PM2.5 for Punjab in 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Punjab') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Punjab 2022', width=600, height=300) " 674,"Create a grouped bar chart comparing the average PM2.5 for Haryana, Puducherry, and Tripura across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Puducherry', 'Tripura'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 675,Create a table of PM2.5 exceedance frequency above 60 µg/m³ by state for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 676,Show the monthly average PM2.5 for Naharlagun in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Naharlagun') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Naharlagun 2020', width=450, height=280) " 677,Show the monthly average PM2.5 for Jorapokhar in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Jorapokhar') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Jorapokhar 2018', width=450, height=280) " 678,Report the city with the highest median PM10 in May 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 679,Tabulate the 10 worst states for average PM10 in 2022 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 680,Create a table of PM2.5 exceedance frequency above 100 µg/m³ by state for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 681,"Show the variability of PM10 across states in 2020 using mean, median, and standard deviation."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 682,Plot the weekly average PM2.5 for Muzaffarnagar in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Muzaffarnagar') & (data['Timestamp'].dt.year == 2024)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Muzaffarnagar 2024', width=600, height=300) return chart " 683,Show PM2.5 exceedances above the Indian standard (60 µg/m³) per year as a bar chart for Sikkim.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Sikkim'].dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 60].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby('Year')['Timestamp'].nunique().reset_index() df.columns = ['Year','Days Exceeded'] chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('Year:N', title='Year'), y=alt.Y('Days Exceeded:Q', title='Days PM2.5 > 60 µg/m³'), tooltip=['Year:N','Days Exceeded:Q'] ).properties(title='Days Sikkim Exceeded Indian PM2.5 Standard (60 µg/m³) per Year', width=450, height=300) return chart " 684,"Compare the monthly average PM2.5 of Ahmednagar, Siliguri, and Tiruchirappalli in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Ahmednagar', 'Siliguri', 'Tiruchirappalli'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Ahmednagar vs Siliguri vs Tiruchirappalli – 2019', width=550, height=320) return chart " 685,"Visualize the monthly average PM10 for Madhya Pradesh, Karnataka, and Maharashtra in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Madhya Pradesh', 'Karnataka', 'Maharashtra'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Madhya Pradesh, Karnataka, UP – 2022', width=550, height=320) return chart " 686,Which state ranked as the least polluted regarding per capita PM10 exposure in 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'per_capita_pm', 'numerator': 'PM10', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'per_capita_pm', 'ascending': True}}] " 687,Tabulate the monthly mean PM10 levels for Tripura during 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tripura'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 688,"Which state registered the third-most elevated PM2.5 levels on August 15, 2023?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 689,Identify the state with the 2nd lowest 25th percentile of PM10 for November 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 690,Which city showed the 2nd highest 25th percentile of PM10 in October 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 691,Identify the city that received the 2nd lowest NCAP funding relative to its 25th percentile of PM2.5 concentration in 2020 (FY 2019-20).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2020_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 692,Identify the city with the 3rd lowest median PM2.5 in August 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 693,Plot the weekly average PM2.5 for Jodhpur in 2018 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Jodhpur') & (data['Timestamp'].dt.year == 2018)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Jodhpur 2018', width=600, height=300) return chart " 694,"In February 2020, report the city with the lowest median PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 695,Report the state with the 3rd highest average PM2.5 in October 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 696,"Compare the monthly average PM2.5 of Mandi Gobindgarh, Ariyalur, and Araria in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Mandi Gobindgarh', 'Ariyalur', 'Araria'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Mandi Gobindgarh vs Ariyalur vs Araria – 2023', width=550, height=320) return chart " 697,Create a table showing PM10 levels and population for each state in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 698,Create a month-wise PM2.5 breakdown table across cities in Bihar for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Bihar'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Muzaffarpur', 'Patna']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 699,Determine the station exhibiting the 3rd highest 25th percentile of PM2.5 in November 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 700,Which station noted the 3rd maximum 25th percentile of PM10 in the Summer season of 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 701,"Scatter plot PM2.5 vs PM10 for Jharkhand stations in 2019, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Jharkhand') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Jharkhand Stations 2019', width=450, height=350) " 702,"In November 2023, report the city with the 3rd lowest 75th percentile of PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 703,"Which state showed the second-highest 25th percentile for PM10 on March 31, 2024?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 704,"Create a grouped bar chart comparing the average PM2.5 for Chhattisgarh, Arunachal Pradesh, and Karnataka across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chhattisgarh', 'Arunachal Pradesh', 'Karnataka'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 705,Which station showed the 2nd lowest 25th percentile for PM10 in the Summer season of 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 706,Create a table showing PM2.5 spread (min to max) and central tendency per state for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 707,Which state recorded the minimum median PM10 during the Summer season of 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 708,Generate a city × month cross-tab of mean PM2.5 for Odisha in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Odisha'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Talcher']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 709,Which 20 states recorded the highest average PM2.5 levels in 2024? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 710,Tabulate the 15 citys with the least PM2.5 pollution in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 711,Report the city with the 3rd lowest NCAP funding considering its 25th percentile of PM10 concentration in 2020 (FY 2019-20).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2020_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 712,Show a monthly breakdown table of average PM2.5 for Muzaffarpur in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Muzaffarpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 713,Show a cumulative area chart of PM2.5 readings for Muzaffarpur across 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Muzaffarpur') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Muzaffarpur 2022', width=600, height=300) return chart " 714,Create a table of PM10 standard violations (>150 µg/m³) per city in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 715,"Compare the monthly average PM2.5 of Sagar, Baghpat, and Nagpur in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Sagar', 'Baghpat', 'Nagpur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Sagar vs Baghpat vs Nagpur – 2018', width=550, height=320) return chart " 716,Generate a table showing the 15 most polluted states based on mean PM10 for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 717,Create a month-wise PM10 breakdown table across cities in Madhya Pradesh for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Bhopal', 'Damoh', 'Dewas', 'Gwalior', 'Indore', 'Jabalpur', 'Katni', 'Mandideep', 'Pithampur', 'Ratlam', 'Satna', 'Ujjain']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 718,Identify the state with the 3rd highest average PM2.5 for September 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 719,"In April 2022, report the state with the highest 25th percentile of PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 720,Show the monthly average PM10 trend for Pimpri-Chinchwad from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Pimpri-Chinchwad'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Pimpri-Chinchwad (2019–2024)', width=600, height=300) return chart " 721,"Compare the monthly average PM2.5 of Jalore, Bathinda, and Vijayawada in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Jalore', 'Bathinda', 'Vijayawada'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Jalore vs Bathinda vs Vijayawada – 2024', width=550, height=320) return chart " 722,Create a table showing PM10 levels and population for each state in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 723,"Determine which union territory has the second smallest population within the top 4 most polluted union territories, based on variance of PM10 levels."," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'var', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 4, 'ret': 'state'}}] " 724,"Identify the state (excluding UTs) with the 3rd smallest population among the top 3 most polluted states, based on median PM2.5 levels."," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 3, 'ret': 'state'}}] " 725,"Create a grouped bar chart comparing the average PM2.5 for West Bengal, Jammu and Kashmir, and Manipur across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['West Bengal', 'Jammu and Kashmir', 'Manipur'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 726,Report which state documented the third lowest median PM10 level ever.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 727,List average PM2.5 by month for Asansol in 2021 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Asansol'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 728,"Show the top 6 states by average PM10 in 2017 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2017] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(6, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 6 States by Average PM10 in 2017', width=500, height=300) return chart " 729,Which state recorded the 3rd highest 75th percentile of PM10 during the Post-Monsoon season of 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 730,"In 2018, which state will rank with the largest reduction in average PM2.5 levels from October to December?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 731,Tabulate mean PM2.5 and PM10 along with station coverage per state in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}, {'alias': 'Station Count', 'col': 'station', 'fn': 'nunique'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 732,"Create a grouped bar chart comparing the average PM2.5 for Himachal Pradesh, Maharashtra, and Rajasthan across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Himachal Pradesh', 'Maharashtra', 'Rajasthan'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 733,"For Cuttack, what date in the last two years had the third-highest PM2.5 reading?"," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 2}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'Timestamp'}}] " 734,Which station recorded the 3rd highest average PM10 in January 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 735,"For the period October to December 2020, which city had the second smallest decrease in average PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 736,"Identify the state, among those with a population below the average, that secures the 2nd highest per capita NCAP funding."," [{'op': 'COMPUTE', 'params': {'new_col': 'funding_per_capita', 'numerator': 'total_fund', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'funding_per_capita', 'ascending': False}}] " 737,Which station noted the 3rd highest 75th percentile of PM2.5 in the Monsoon season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 738,Generate a table showing the 5 most polluted citys based on mean PM10 for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 739,Show a year-wise table of average PM10 for Indore from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Indore'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 740,"For 2019, which season (Winter, Summer, Monsoon, Post-Monsoon) experienced the second-lowest average PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'season'}}] " 741,Show PM10 exceedance count and rate (%) above 100 µg/m³ per state in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 742,Show a monthly breakdown table of average PM2.5 for Pune in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Pune'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 743,Show the monthly average PM10 trend for Hajipur from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Hajipur'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Hajipur (2017–2022)', width=600, height=300) return chart " 744,"Visualize the monthly average PM10 for Karnataka, Chandigarh, and Nagaland in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Karnataka', 'Chandigarh', 'Nagaland'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Karnataka, Chandigarh, UP – 2017', width=550, height=320) return chart " 745,"Create a bubble chart of PM2.5 vs area for each state in 2022, sized by population."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): pm = data[data['Timestamp'].dt.year == 2022].groupby('state')['PM2.5'].mean().reset_index().dropna() df = pm.merge(states_data, on='state') chart = alt.Chart(df).mark_point(filled=True, opacity=0.7).encode( x=alt.X('area (km2):Q', title='Area (km²)', axis=alt.Axis(format='~s')), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), size=alt.Size('population:Q', title='Population', scale=alt.Scale(range=[50,1500])), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('population:Q', format=','), alt.Tooltip('area (km2):Q', format=',')] ).properties(title='PM2.5 vs Area (size=Population) – 2022', width=500, height=400) return chart " 746,Show a monthly bar chart of the number of days Tamil Nadu exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Tamil Nadu') & (data['Timestamp'].dt.year == 2022)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Tamil Nadu Exceeded WHO PM2.5 Guideline per Month – 2022', width=500, height=300) return chart " 747,"Which station recorded the highest PM2.5 readings on January 14, 2020?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 748,Which city registered the 3rd lowest median PM2.5 during January 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 749,Tabulate both PM2.5 and PM10 averages by city for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 750,Tabulate the yearly average PM2.5 trend for Kanpur across all years.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Kanpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 751,Which state recorded the 2nd lowest 25th percentile of PM2.5 in July 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 752,Plot the rolling 30-day average PM2.5 for Punjab in 2019 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Punjab') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Punjab 2019', width=600, height=300) " 753,Which 10 citys had the lowest mean PM2.5 in 2024? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 754,Which city noted the 2nd highest median PM10 in the Summer season of 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 755,Tabulate the 15 states with the least PM10 pollution in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 756,Report the city that had the 3rd lowest median PM10 in March 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 757,Identify the state with the 3rd highest 75th percentile of PM10 for November 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 758,"Show the top 10 states by average PM10 in 2021 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2021] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(10, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 10 States by Average PM10 in 2021', width=500, height=300) return chart " 759,Plot the weekly average PM2.5 for Sagar in 2021 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Sagar') & (data['Timestamp'].dt.year == 2021)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Sagar 2021', width=600, height=300) return chart " 760,Which city had the 2nd highest average PM2.5 in April 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 761,Plot the weekly average PM2.5 for Chhal in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Chhal') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Chhal 2023', width=600, height=300) return chart " 762,Which city experienced the third least significant drop in its average PM10 levels between October and December 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 763,Tabulate the 15 worst citys for average PM10 in 2018 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 764,Report the city with the 2nd highest average PM2.5 in February 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 765,"Create a table of PM2.5, PM10 and station counts by state for 2019."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}, {'alias': 'Station Count', 'col': 'station', 'fn': 'nunique'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 766,Which state noted the 2nd maximum median PM2.5 during the Post-Monsoon season of 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 767,"Plot the yearly average PM2.5 trends for Gujarat, Delhi, and Haryana from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Gujarat', 'Delhi', 'Haryana'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Gujarat vs Delhi vs Haryana', width=550, height=320) return chart " 768,Show a monthly breakdown table of average PM2.5 for West Bengal in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'West Bengal'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 769,"Visualize the monthly average PM10 for Delhi, Maharashtra, and Haryana in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Delhi', 'Maharashtra', 'Haryana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Delhi, Maharashtra, UP – 2024', width=550, height=320) return chart " 770,Plot the rolling 30-day average PM2.5 for Punjab in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Punjab') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Punjab 2023', width=600, height=300) " 771,Show a cumulative area chart of PM2.5 readings for Mandi Gobindgarh across 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Mandi Gobindgarh') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Mandi Gobindgarh 2021', width=600, height=300) return chart " 772,"Identify the union territory with the largest population among the top 2 most polluted union territories, based on 75th percentile of PM2.5 levels."," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 2, 'ret': 'state'}}] " 773,Show a heatmap of average PM2.5 for the top 10 most polluted states by month for 2019.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(10).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 10 Polluted States by Month (2019)', width=500, height=300) return chart " 774,Generate a dual-pollutant summary table (PM2.5 and PM10) by city for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 775,Show annual average PM10 for Punjab as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 776,Identify the state with the highest 25th percentile of PM2.5 in October 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 777,Which station exhibited the highest median PM10 during December 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 778,Tabulate the yearly average PM2.5 trend for Uttar Pradesh across all years.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 779,Identify the city that recorded the third highest 75th percentile of PM2.5 during the Summer season of 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 780,"Tabulate the distribution of PM10 per state in 2017 including mean, median, and std."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 781,Plot the weekly average PM2.5 for Gangtok in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Gangtok') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Gangtok 2023', width=600, height=300) return chart " 782,Tabulate population-adjusted PM2.5 levels for each state in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM2.5 per million', 'numerator': 'PM2.5', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'PM2.5 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 783,Report the state with the 3rd highest 25th percentile of PM10 in September 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 784,Create a month-by-state breakdown table of mean PM10 for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Arunachal Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Chhattisgarh', 'Delhi', 'Gujarat', 'Haryana', 'Himachal Pradesh', 'Jammu and Kashmir', 'Jharkhand', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Manipur', 'Meghalaya', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh', 'Uttarakhand', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 785,Tabulate daily PM10 exceedances (above 100 µg/m³) per state for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 786,Show PM10 density (µg/m³ per km²) by state for 2017 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM10 per km²', 'numerator': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)', 'PM10 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 787,How many stations in Bihar exceeded 30 µg/m³ of PM2.5 in the year 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 30.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 788,Find the station with the third-lowest 75th percentile for PM10 in August 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 789,Show annual average PM10 for Aurangabad as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Aurangabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 790,"Plot the yearly average PM2.5 trends for Mizoram, Puducherry, and Haryana from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Mizoram', 'Puducherry', 'Haryana'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Mizoram vs Puducherry vs Haryana', width=550, height=320) return chart " 791,Report the state with the highest NCAP funding considering its 75th percentile of PM10 concentration in 2021 (FY 2020-21).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 792,"Plot the yearly average PM2.5 trends for Meghalaya, Karnataka, and Assam from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Meghalaya', 'Karnataka', 'Assam'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Meghalaya vs Karnataka vs Assam', width=550, height=320) return chart " 793,Show the number of days each city exceeded a PM10 threshold of 150 µg/m³ in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 794,Report the city with the 3rd highest average PM2.5 in July 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 795,"Plot the yearly average PM2.5 trends for Rajasthan, Meghalaya, and Odisha from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Meghalaya', 'Odisha'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Rajasthan vs Meghalaya vs Odisha', width=550, height=320) return chart " 796,Which state noted the 3rd lowest average PM10 in the Winter season of 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 797,"Over all years, which December showed the highest 25th percentile for PM2.5 concentration?"," [{'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'Timestamp'}}] " 798,Determine the station that recorded the 3rd highest average PM10 over the Post-Monsoon season of 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 799,Identify the state that recorded the 2nd lowest median PM2.5 value in December 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 800,Show a monthly bar chart of the number of days Andhra Pradesh exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2017.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Andhra Pradesh') & (data['Timestamp'].dt.year == 2017)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Andhra Pradesh Exceeded WHO PM2.5 Guideline per Month – 2017', width=500, height=300) return chart " 801,Tabulate the 10 worst states for average PM2.5 in 2017 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 802,List all states with their average PM2.5 and population for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 803,"Create a grouped bar chart comparing the average PM2.5 for Telangana, Jammu and Kashmir, and Assam across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Telangana', 'Jammu and Kashmir', 'Assam'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 804,"Visualize the monthly average PM10 for Himachal Pradesh, Meghalaya, and Jammu and Kashmir in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Himachal Pradesh', 'Meghalaya', 'Jammu and Kashmir'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Himachal Pradesh, Meghalaya, UP – 2024', width=550, height=320) return chart " 805,Show the monthly average PM10 trend for Bagalkot from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Bagalkot'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Bagalkot (2019–2024)', width=600, height=300) return chart " 806,Show the monthly average PM10 trend for Tirupur from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Tirupur'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Tirupur (2019–2024)', width=600, height=300) return chart " 807,Show a table of the 15 cleanest citys by average PM2.5 in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 808,"Plot the yearly average PM2.5 trends for Karnataka, Maharashtra, and Manipur from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Karnataka', 'Maharashtra', 'Manipur'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Karnataka vs Maharashtra vs Manipur', width=550, height=320) return chart " 809,Show a table of average PM2.5 per state in 2020 along with population.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 810,"Show the top 7 states by average PM10 in 2017 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2017] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(7, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 7 States by Average PM10 in 2017', width=500, height=300) return chart " 811,"Identify the state that had the third-highest PM10 readings on January 14, 2023."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 812,Show a bar chart of the top 7 cities by median PM2.5 in 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2023] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(7, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 7 Cities by Median PM2.5 in 2023', width=500, height=300) return chart " 813,"Compare the monthly average PM2.5 of Maihar, Nashik, and Chennai in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Maihar', 'Nashik', 'Chennai'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Maihar vs Nashik vs Chennai – 2023', width=550, height=320) return chart " 814,"Comparing April 2019 with April 2020, which state experienced the largest increase in average PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 815,"On March 31, 2023, which state had the second-highest average PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 816,List the average PM2.5 for Bhopal broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Bhopal'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 817,Create a table of PM10 standard violations (>100 µg/m³) per state in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 818,"Compare the monthly average PM2.5 of Hassan, Barrackpore, and Silchar in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Hassan', 'Barrackpore', 'Silchar'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Hassan vs Barrackpore vs Silchar – 2023', width=550, height=320) return chart " 819,"Visualize the monthly average PM10 for Tripura, Kerala, and Karnataka in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tripura', 'Kerala', 'Karnataka'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Tripura, Kerala, UP – 2024', width=550, height=320) return chart " 820,Tabulate population-adjusted PM2.5 levels for each state in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM2.5 per million', 'numerator': 'PM2.5', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'PM2.5 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 821,"Scatter plot PM2.5 vs PM10 for Mizoram stations in 2024, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Mizoram') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Mizoram Stations 2024', width=450, height=350) " 822,Report the union territory with the 2nd lowest 25th percentile of PM2.5 concentration relative to its population density.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_capita', 'numerator': 'PM2.5', 'denominator': 'population'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'pm_per_capita', 'ascending': True}}] " 823,Show a heatmap of average PM2.5 for the top 6 most polluted states by month for 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(6).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 6 Polluted States by Month (2023)', width=500, height=300) return chart " 824,"Compare the monthly average PM2.5 of Rajsamand, Sikar, and Pithampur in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Rajsamand', 'Sikar', 'Pithampur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Rajsamand vs Sikar vs Pithampur – 2019', width=550, height=320) return chart " 825,"Report the state (excluding UTs) having the smallest population among the top 5 most polluted states, when pollution is measured by average PM10 levels."," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 5, 'ret': 'state'}}] " 826,Which station recorded the 2nd lowest 75th percentile of PM2.5 in March 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 827,Show a heatmap of average PM2.5 for the top 10 most polluted states by month for 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(10).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 10 Polluted States by Month (2022)', width=500, height=300) return chart " 828,Show the monthly average PM10 trend for Noida from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Noida'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Noida (2017–2022)', width=600, height=300) return chart " 829,"Plot the yearly average PM2.5 trends for Delhi, Karnataka, and Himachal Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Delhi', 'Karnataka', 'Himachal Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Delhi vs Karnataka vs Himachal Pradesh', width=550, height=320) return chart " 830,"Create a grouped bar chart comparing the average PM2.5 for Puducherry, Delhi, and Kerala across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'Delhi', 'Kerala'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 831,Visualize the bottom 15 states with the lowest average PM2.5 in 2019 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2019] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(15, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 15 States by Average PM2.5 in 2019', width=500, height=300) return chart " 832,Which station experienced the 3rd highest average for PM2.5 in the Summer season of 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 833,Create a table showing annual mean PM2.5 levels for Karnataka (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 834,What date over the last four years showed Kolkata's 3rd lowest PM2.5 reading?," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 4}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'Timestamp'}}] " 835,Plot the rolling 30-day average PM2.5 for Meghalaya in 2018 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Meghalaya') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Meghalaya 2018', width=600, height=300) " 836,Which state exhibited the second-highest 25th percentile for PM2.5 during July 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 837,Show a heatmap of average PM2.5 for the top 5 most polluted states by month for 2017.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(5).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 5 Polluted States by Month (2017)', width=500, height=300) return chart " 838,Which state possessed the 3rd highest median for PM10 in the Summer season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 839,Generate a cross-tab of state vs month for average PM10 in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Delhi', 'Jharkhand', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Punjab', 'Rajasthan', 'Telangana', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 840,"Create a faceted bar chart showing top 10 states by average PM2.5 per year for 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year.isin([2019,2020,2021,2022])].copy() df['Year'] = df['Timestamp'].dt.year agg = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() top = agg.groupby('Year').apply(lambda x: x.nlargest(10,'PM2.5')).reset_index(drop=True) chart = alt.Chart(top).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Avg PM2.5'), y=alt.Y('state:N', sort='-x'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet(facet='Year:O', columns=2).properties(title='Top 10 States by PM2.5 per Year') return chart " 841,On which date in the past three years did Dharuhera register its 3rd minimum PM2.5 level?," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 3}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'Timestamp'}}] " 842,Generate a year-by-year summary table of PM10 readings for Gaya.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Gaya'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 843,Determine the third-highest PM2.5 value recorded in 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}] " 844,"Compare the monthly average PM2.5 of Bhopal, Tensa, and Chittorgarh in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Bhopal', 'Tensa', 'Chittorgarh'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Bhopal vs Tensa vs Chittorgarh – 2024', width=550, height=320) return chart " 845,Show a table of the 5 cleanest citys by average PM10 in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 846,Show a heatmap of average PM2.5 for the top 8 most polluted states by month for 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(8).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 8 Polluted States by Month (2018)', width=500, height=300) return chart " 847,Determine the state with the 2nd highest average PM10 in July 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 848,"Visualize the monthly average PM10 for Karnataka, Mizoram, and Punjab in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Karnataka', 'Mizoram', 'Punjab'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Karnataka, Mizoram, UP – 2023', width=550, height=320) return chart " 849,"Show the variability of PM2.5 across citys in 2022 using mean, median, and standard deviation."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 850,"Visualize the monthly average PM10 for Telangana, Telangana, and Uttar Pradesh in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Telangana', 'Telangana', 'Uttar Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Telangana, Telangana, UP – 2024', width=550, height=320) return chart " 851,Show a table of the top 20 citys by average PM2.5 in 2020 including their PM10 levels too.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 852,"Identify the state that registered the second-lowest PM10 readings on January 14, 2020."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 853,Tabulate mean PM2.5 and PM10 along with station coverage per state in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}, {'alias': 'Station Count', 'col': 'station', 'fn': 'nunique'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 854,"Plot the yearly average PM2.5 trends for Delhi, Uttarakhand, and Assam from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Delhi', 'Uttarakhand', 'Assam'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Delhi vs Uttarakhand vs Assam', width=550, height=320) return chart " 855,"During April 2020's COVID-19 lockdown, which station documented the third-lowest PM2.5 concentrations?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 856,Identify the station with the minimum average PM10 reading for March 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 857,Create a table of PM2.5 standard violations (>60 µg/m³) per state in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 858,Create a summary table ranking the top 20 states by PM10 concentration in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 859,Tabulate days with PM2.5 > 100 µg/m³ and exceedance percentage per city in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 860,"In July 2020, identify the station with the highest average PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 861,Generate a city × month cross-tab of mean PM2.5 for Karnataka in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Bagalkot', 'Bengaluru', 'Chamarajanagar', 'Chikkaballapur', 'Chikkamagaluru', 'Davanagere', 'Gadag', 'Hassan', 'Hubballi', 'Kalaburagi', 'Koppal', 'Madikeri', 'Mangalore', 'Mysuru', 'Raichur', 'Ramanagara', 'Shivamogga', 'Vijayapura', 'Yadgir']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 862,"Identify the state (excluding UTs) with the largest population among the top 10 most polluted states, based on total PM10 levels."," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'sum', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 10, 'ret': 'state'}}] " 863,Which station had the 3rd highest 75th percentile of PM10 in April 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 864,Plot the rolling 30-day average PM2.5 for Rajasthan in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Rajasthan') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Rajasthan 2023', width=600, height=300) " 865,Which city possessed the 3rd highest average for PM10 in the Monsoon season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 866,Create a table of PM2.5 standard violations (>60 µg/m³) per city in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 867,"Which station showed the highest 75th percentile for PM10 on March 31, 2020?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 868,Show a pivot table of monthly average PM10 by city for Odisha in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Odisha'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Baripada', 'Bileipada', 'Brajrajnagar', 'Keonjhar', 'Nayagarh', 'Rourkela', 'Suakati', 'Talcher', 'Tensa']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 869,"Visualize the monthly average PM10 for Kerala, Sikkim, and Jammu and Kashmir in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Kerala', 'Sikkim', 'Jammu and Kashmir'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Kerala, Sikkim, UP – 2017', width=550, height=320) return chart " 870,Which state possessed the 3rd highest median for PM10 in the Monsoon season of 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 871,Which state registered the lowest 25th percentile of PM2.5 during June 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 872,"Visualize the monthly average PM10 for Madhya Pradesh, Kerala, and Tripura in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Madhya Pradesh', 'Kerala', 'Tripura'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Madhya Pradesh, Kerala, UP – 2024', width=550, height=320) return chart " 873,Tabulate average PM10 for each city in Uttar Pradesh across all months of 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Baghpat', 'Bulandshahr', 'Ghaziabad', 'Greater Noida', 'Hapur', 'Lucknow', 'Meerut', 'Moradabad', 'Muzaffarnagar', 'Noida']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 874,"Visualize the monthly average PM10 for Uttarakhand, Assam, and Bihar in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttarakhand', 'Assam', 'Bihar'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Uttarakhand, Assam, UP – 2021', width=550, height=320) return chart " 875,Report the city that had the 2nd highest median PM2.5 in May 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 876,"Compare the monthly average PM2.5 of Nalbari, Raichur, and Asansol in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Nalbari', 'Raichur', 'Asansol'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Nalbari vs Raichur vs Asansol – 2022', width=550, height=320) return chart " 877,Show PM2.5 exceedances above the Indian standard (60 µg/m³) per year as a bar chart for Assam.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Assam'].dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 60].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby('Year')['Timestamp'].nunique().reset_index() df.columns = ['Year','Days Exceeded'] chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('Year:N', title='Year'), y=alt.Y('Days Exceeded:Q', title='Days PM2.5 > 60 µg/m³'), tooltip=['Year:N','Days Exceeded:Q'] ).properties(title='Days Assam Exceeded Indian PM2.5 Standard (60 µg/m³) per Year', width=450, height=300) return chart " 878,"Compare the monthly average PM2.5 of Thiruvananthapuram, Anantapur, and Karwar in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Thiruvananthapuram', 'Anantapur', 'Karwar'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Thiruvananthapuram vs Anantapur vs Karwar – 2022', width=550, height=320) return chart " 879,Determine the station exhibiting the 3rd highest median PM10 over the Monsoon season of 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 880,"In May 2019, identify the state with the 2nd highest median PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 881,"Which season in 2024 (Winter, Summer, Monsoon, Post-Monsoon) was linked to the third-lowest median PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'season'}}] " 882,"Which union territory presents the lowest PM2.5 concentration per square kilometer, according to 25th percentile PM2.5 values?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_km2', 'numerator': 'PM2.5', 'denominator': 'area (km2)'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'pm_per_km2', 'ascending': True}}] " 883,"Compare the monthly average PM2.5 of Bundi, Hisar, and Nagpur in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Bundi', 'Hisar', 'Nagpur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Bundi vs Hisar vs Nagpur – 2019', width=550, height=320) return chart " 884,Which 15 citys had the lowest mean PM10 in 2017? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 885,"Plot the yearly average PM2.5 trends for Tripura, Nagaland, and Assam from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tripura', 'Nagaland', 'Assam'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Tripura vs Nagaland vs Assam', width=550, height=320) return chart " 886,Report which state documented the second highest average PM2.5 of all time.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 887,Create a month-wise PM10 breakdown table across cities in West Bengal for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'West Bengal'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Durgapur']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 888,"Plot the yearly average PM2.5 trends for Telangana, Odisha, and Mizoram from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Telangana', 'Odisha', 'Mizoram'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Telangana vs Odisha vs Mizoram', width=550, height=320) return chart " 889,List the top 10 states by average PM2.5 in 2021 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 890,Create a month-wise PM2.5 breakdown table across cities in Maharashtra for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Aurangabad', 'Chandrapur', 'Kalyan', 'Mumbai', 'Nagpur', 'Nashik', 'Navi Mumbai', 'Pune', 'Solapur']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 891,How many times did Sikar city go above 30 µg/m³ of PM10 in 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 30.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 892,"Visualize the monthly average PM10 for Chandigarh, Nagaland, and Tripura in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chandigarh', 'Nagaland', 'Tripura'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Chandigarh, Nagaland, UP – 2024', width=550, height=320) return chart " 893,Show PM10 density (µg/m³ per km²) by state for 2020 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM10 per km²', 'numerator': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)', 'PM10 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 894,Generate a city × month cross-tab of mean PM10 for Andhra Pradesh in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Amaravati', 'Rajamahendravaram', 'Tirupati', 'Visakhapatnam']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 895,Show the monthly average PM2.5 for Rupnagar in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Rupnagar') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Rupnagar 2018', width=450, height=280) " 896,"Visualize the monthly average PM10 for Madhya Pradesh, Karnataka, and Uttar Pradesh in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Madhya Pradesh', 'Karnataka', 'Uttar Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Madhya Pradesh, Karnataka, UP – 2023', width=550, height=320) return chart " 897,Show a cumulative area chart of PM2.5 readings for Palkalaiperur across 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Palkalaiperur') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Palkalaiperur 2024', width=600, height=300) return chart " 898,Show the monthly average PM10 trend for Kalaburagi from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Kalaburagi'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Kalaburagi (2019–2024)', width=600, height=300) return chart " 899,"Plot the yearly average PM2.5 trends for Assam, Haryana, and Madhya Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Assam', 'Haryana', 'Madhya Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Assam vs Haryana vs Madhya Pradesh', width=550, height=320) return chart " 900,List all states with their average PM10 and population for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 901,Tabulate average PM2.5 for each city in Gujarat across all months of 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Gujarat'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Ahmedabad']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 902,"Create a grouped bar chart comparing the average PM2.5 for Chhattisgarh, Puducherry, and West Bengal across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chhattisgarh', 'Puducherry', 'West Bengal'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 903,Generate a monthly average PM2.5 table for Kerala for the year 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 904,Tabulate the 5 states with the least PM2.5 pollution in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 905,"Show the variability of PM2.5 across states in 2020 using mean, median, and standard deviation."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 906,Show PM10 exceedance count and rate (%) above 100 µg/m³ per state in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 907,Tabulate the monthly mean PM2.5 levels for Nagpur during 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Nagpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 908,"Considering all years, which December had the third-highest 75th percentile for PM10 levels?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'Timestamp'}}] " 909,List the average PM2.5 for Chennai broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Chennai'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 910,How many stations in Telangana went above the WHO guideline for PM2.5 in the year 2017?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 15.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 911,How many times did Himachal Pradesh exceed the WHO guideline for PM10 in 2017?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 15.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 912,Identify the state that showed the third highest 75th percentile of PM10 during the Post-Monsoon season of 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 913,Identify the state with the 2nd lowest average PM2.5 in March 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 914,Which Indian city noted the maximum PM10 levels for a single day over the last decade?," [{'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'eq_rank', 'rank': -1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'count'}}, {'op': 'SORT', 'params': {'col': 'count', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 915,Which city recorded the highest 75th percentile for PM2.5 in the Monsoon season of 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 916,Plot the weekly average PM2.5 for Thane in 2017 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Thane') & (data['Timestamp'].dt.year == 2017)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Thane 2017', width=600, height=300) return chart " 917,Tabulate daily PM2.5 exceedances (above 100 µg/m³) per state for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 918,Which station noted the 2nd minimum 25th percentile of PM2.5 during the Monsoon season of 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 919,"In January 2021, report the station with the 3rd highest 75th percentile of PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 920,"Create a faceted bar chart showing top 9 states by average PM2.5 per year for 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year.isin([2021,2022,2023,2024])].copy() df['Year'] = df['Timestamp'].dt.year agg = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() top = agg.groupby('Year').apply(lambda x: x.nlargest(9,'PM2.5')).reset_index(drop=True) chart = alt.Chart(top).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Avg PM2.5'), y=alt.Y('state:N', sort='-x'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet(facet='Year:O', columns=2).properties(title='Top 9 States by PM2.5 per Year') return chart " 921,Report which station experienced the 2nd highest 25th percentile of PM10 throughout the Post-Monsoon season of 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 922,Create a table of state PM10 levels and geographic area for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 923,Create a summary table ranking the top 15 citys by PM2.5 concentration in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 924,"Visualize the monthly average PM10 for Maharashtra, Nagaland, and Arunachal Pradesh in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Maharashtra', 'Nagaland', 'Arunachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Maharashtra, Nagaland, UP – 2021', width=550, height=320) return chart " 925,"Create a grouped bar chart comparing the average PM2.5 for Haryana, Meghalaya, and Tripura across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Meghalaya', 'Tripura'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 926,Which state recorded the 2nd highest median PM10 in September 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 927,Show a heatmap of average PM2.5 for the top 14 most polluted states by month for 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(14).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 14 Polluted States by Month (2023)', width=500, height=300) return chart " 928,Show annual average PM2.5 for Gujarat as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Gujarat'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 929,Tabulate the 15 worst states for average PM10 in 2024 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 930,"Visualize the monthly average PM10 for Maharashtra, Jharkhand, and Rajasthan in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Maharashtra', 'Jharkhand', 'Rajasthan'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Maharashtra, Jharkhand, UP – 2017', width=550, height=320) return chart " 931,"Which state (excluding UTs) possesses the largest population among the top 5 most polluted states, determined by average PM2.5 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 5, 'ret': 'state'}}] " 932,"Create a grouped bar chart comparing the average PM2.5 for Odisha, Delhi, and Manipur across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Odisha', 'Delhi', 'Manipur'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 933,Show a table of the 15 cleanest states by average PM10 in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 934,Which 10 citys recorded the highest average PM10 levels in 2023? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 935,Tabulate the yearly average PM10 trend for Bihar across all years.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Bihar'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 936,"Which city recorded the second-lowest average PM2.5 reading on January 5, 2020?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 937,Show annual average PM2.5 for Durgapur as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Durgapur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 938,Show average PM10 per state in 2017 with area in km².," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 939,"Plot the yearly average PM2.5 trends for Puducherry, Sikkim, and Delhi from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'Sikkim', 'Delhi'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Puducherry vs Sikkim vs Delhi', width=550, height=320) return chart " 940,"Compare the monthly average PM2.5 of Muzaffarpur, Ujjain, and Latur in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Muzaffarpur', 'Ujjain', 'Latur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Muzaffarpur vs Ujjain vs Latur – 2018', width=550, height=320) return chart " 941,"Identify the state that recorded the third most minimal PM10 level on January 27, 2024."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 942,"Create a faceted bar chart showing top 14 states by average PM2.5 per year for 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year.isin([2020,2021,2022,2023])].copy() df['Year'] = df['Timestamp'].dt.year agg = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() top = agg.groupby('Year').apply(lambda x: x.nlargest(14,'PM2.5')).reset_index(drop=True) chart = alt.Chart(top).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Avg PM2.5'), y=alt.Y('state:N', sort='-x'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet(facet='Year:O', columns=2).properties(title='Top 14 States by PM2.5 per Year') return chart " 943,Determine the station with the lowest median PM2.5 in March 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 944,Which station experienced the least significant drop in its median PM10 levels between October and December 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 945,"Visualize the monthly average PM10 for Chhattisgarh, Tamil Nadu, and Odisha in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chhattisgarh', 'Tamil Nadu', 'Odisha'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Chhattisgarh, Tamil Nadu, UP – 2021', width=550, height=320) return chart " 946,Tabulate the monthly mean PM10 levels for Ghaziabad during 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Ghaziabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 947,Plot the rolling 30-day average PM2.5 for Kerala in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Kerala') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Kerala 2023', width=600, height=300) " 948,Show how many times PM10 exceeded 100 µg/m³ per day across states in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 949,Tabulate average PM2.5 for each city in Madhya Pradesh across all months of 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Bhopal', 'Damoh', 'Dewas', 'Gwalior', 'Indore', 'Jabalpur', 'Katni', 'Maihar', 'Mandideep', 'Pithampur', 'Ratlam', 'Sagar', 'Satna', 'Singrauli', 'Ujjain']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 950,Show the monthly average PM2.5 for Karauli in 2023 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Karauli') & (data['Timestamp'].dt.year == 2023)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Karauli 2023', width=450, height=280) " 951,"Tabulate PM10 levels, population, and land area per state in 2021."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 952,"Identify the city with the highest average PM2.5 on March 31, 2020."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 953,"Which city showed the lowest median PM2.5 on March 31, 2019?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 954,"Over the past four years in Damoh, on which date was the PM2.5 level the third lowest?"," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 4}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'Timestamp'}}] " 955,"Plot the yearly average PM2.5 trends for Nagaland, Assam, and Punjab from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Nagaland', 'Assam', 'Punjab'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Nagaland vs Assam vs Punjab', width=550, height=320) return chart " 956,Which state exhibited the 2nd lowest median PM10 in November 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 957,"Scatter plot PM2.5 vs PM10 for Tamil Nadu stations in 2017, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Tamil Nadu') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Tamil Nadu Stations 2017', width=450, height=350) " 958,Show a table of the 10 cleanest states by average PM10 in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 959,List how many days each city breached the PM10 limit of 150 µg/m³ in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 960,Show a year-wise table of average PM2.5 for Thiruvananthapuram from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Thiruvananthapuram'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 961,Which city showed the 2nd highest 25th percentile of PM10 in October 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 962,"Visualize the monthly average PM10 for Meghalaya, Kerala, and Manipur in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Meghalaya', 'Kerala', 'Manipur'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Meghalaya, Kerala, UP – 2024', width=550, height=320) return chart " 963,"Create a grouped bar chart comparing the average PM2.5 for Puducherry, Odisha, and Nagaland across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'Odisha', 'Nagaland'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 964,Create a month-wise PM10 breakdown table across cities in Maharashtra for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Aurangabad', 'Chandrapur', 'Kalyan', 'Mumbai', 'Nagpur', 'Nashik', 'Navi Mumbai', 'Pune', 'Solapur', 'Thane']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 965,"During 2023, determine the weekday that showed the second-lowest 25th percentile of PM2.5 pollution levels."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'Timestamp'}}] " 966,Report the station that had the 3rd lowest 25th percentile of PM10 in June 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 967,"Considering all years, which November registered the minimum median PM10 concentration?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'Timestamp'}}] " 968,Show PM2.5 exceedance count and rate (%) above 60 µg/m³ per state in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 969,Determine the state exhibiting the 3rd most minimal average PM2.5 over the Monsoon season of 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 970,"Which state experienced the third-highest average PM2.5 level on January 5, 2021?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 971,"For the period October to December 2020, which city had the third smallest decrease in 25th percentile PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 972,Report the station that had the highest 75th percentile of PM2.5 in July 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 973,Show a year-wise table of average PM10 for Nagaland from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Nagaland'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 974,"On January 27, 2021, which city had the second most minimal PM2.5 level?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 975,Report the union territory with the highest median PM2.5 concentration when considering population density.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_capita', 'numerator': 'PM2.5', 'denominator': 'population'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'pm_per_capita', 'ascending': False}}] " 976,"Scatter plot PM2.5 vs PM10 for Puducherry stations in 2019, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Puducherry') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Puducherry Stations 2019', width=450, height=350) " 977,List the average PM10 for Bhopal broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Bhopal'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 978,Find a week exhibiting Kunjemura's minimum PM10 levels for all specified years.," [{'op': 'FILTER', 'params': {'field': 'city', 'value': 'Kunjemura'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'week'}}] " 979,"Tabulate the distribution of PM10 per city in 2021 including mean, median, and std."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 980,"Show a table of average PM10, population, and area for all states in 2023."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 981,Create a table of PM10 standard violations (>100 µg/m³) per city in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 982,"Visualize the monthly average PM10 for Punjab, Chhattisgarh, and Bihar in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Punjab', 'Chhattisgarh', 'Bihar'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Punjab, Chhattisgarh, UP – 2021', width=550, height=320) return chart " 983,Show the monthly average PM2.5 for Sangli in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Sangli') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Sangli 2019', width=450, height=280) " 984,"Across all recorded years, which June experienced the second-highest 25th percentile for PM2.5 levels?"," [{'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'Timestamp'}}] " 985,"In March 2024, which station recorded the 2nd highest 75th percentile of PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 986,Identify the state that saw the third least significant fall in 75th percentile PM10 levels when comparing December 2022 to October 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 987,Tabulate average PM10 for each state across all months in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Delhi', 'Jharkhand', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Punjab', 'Rajasthan', 'Telangana', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 988,"For 2018, identify the season (Winter, Summer, Monsoon, Post-Monsoon) with the highest 25th percentile of PM10 levels."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'season'}}] " 989,Show PM2.5 exceedance count and rate (%) above 100 µg/m³ per city in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 990,Which 5 states had the lowest mean PM2.5 in 2024? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 991,"Plot the yearly average PM2.5 trends for Rajasthan, Punjab, and Puducherry from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Punjab', 'Puducherry'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Rajasthan vs Punjab vs Puducherry', width=550, height=320) return chart " 992,Show a heatmap of average PM2.5 for the top 12 most polluted states by month for 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(12).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 12 Polluted States by Month (2023)', width=500, height=300) return chart " 993,"In July 2023, identify the station with the 3rd highest average PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 994,Which station had the 3rd lowest average PM2.5 in August 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 995,"On January 14, 2023, which state showed the third-lowest PM10 readings?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 996,How many times did Bangalore city exceed 30 µg/m³ of PM2.5 in the year 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 30.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 997,Show a cumulative area chart of PM2.5 readings for Kannur across 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Kannur') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Kannur 2022', width=600, height=300) return chart " 998,"Create a grouped bar chart comparing the average PM2.5 for Jharkhand, Chhattisgarh, and Nagaland across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Chhattisgarh', 'Nagaland'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 999,Identify the station that recorded the lowest 25th percentile of PM10 value in May 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 1000,Visualize the bottom 12 states with the lowest average PM2.5 in 2017 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2017] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(12, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 12 States by Average PM2.5 in 2017', width=500, height=300) return chart " 1001,"Create a comprehensive state summary with PM10, population, and area for 2021."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1002,Show the monthly average PM2.5 for Ambala in 2022 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ambala') & (data['Timestamp'].dt.year == 2022)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Ambala 2022', width=450, height=280) " 1003,Show PM10 averages in a state × month matrix for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Arunachal Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Chhattisgarh', 'Delhi', 'Gujarat', 'Haryana', 'Himachal Pradesh', 'Jammu and Kashmir', 'Jharkhand', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Manipur', 'Meghalaya', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh', 'Uttarakhand', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1004,Determine the station with the third-lowest median PM2.5 in July 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 1005,Report the city that had the 3rd highest average PM2.5 in April 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 1006,Plot the weekly average PM2.5 for Vatva in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Vatva') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Vatva 2023', width=600, height=300) return chart " 1007,"On March 31, 2022, which station recorded the third-highest 25th percentile of PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 1008,Show how many times PM2.5 exceeded 100 µg/m³ per day across citys in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1009,Tabulate the top 10 citys for PM2.5 in 2022 along with their corresponding PM10 values.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 1010,Which station showed the second-highest median PM2.5 in July 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 1011,Show the monthly average PM10 trend for Gangtok from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Gangtok'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Gangtok (2019–2024)', width=600, height=300) return chart " 1012,Show the monthly average PM2.5 for Silchar in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Silchar') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Silchar 2018', width=450, height=280) " 1013,Determine the station exhibiting the 3rd lowest 75th percentile of PM2.5 in September 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 1014,Tabulate average and median PM2.5 for all citys in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1015,Which city had the 2nd lowest 75th percentile of PM10 in January 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 1016,Show the monthly average PM2.5 for Mizoram across each year from 2017 to 2024 as small multiples (faceted by year).," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Mizoram'].copy() df['Year'] = df['Timestamp'].dt.year df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5'), tooltip=['Year:O','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet( facet=alt.Facet('Year:O', title='Year'), columns=4 ).properties(title='Monthly PM2.5 in Mizoram by Year (2017–2024)') return chart " 1017,"Visualize the monthly average PM10 for Gujarat, Gujarat, and Jharkhand in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Gujarat', 'Gujarat', 'Jharkhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Gujarat, Gujarat, UP – 2019', width=550, height=320) return chart " 1018,Plot the rolling 30-day average PM2.5 for Madhya Pradesh in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Madhya Pradesh') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Madhya Pradesh 2024', width=600, height=300) " 1019,Visualize the bottom 11 states with the lowest average PM2.5 in 2020 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2020] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(11, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 11 States by Average PM2.5 in 2020', width=500, height=300) return chart " 1020,List all states with their average PM2.5 and population for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1021,"Visualize the monthly average PM10 for Uttarakhand, Madhya Pradesh, and Gujarat in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttarakhand', 'Madhya Pradesh', 'Gujarat'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Uttarakhand, Madhya Pradesh, UP – 2022', width=550, height=320) return chart " 1022,Show a cumulative area chart of PM2.5 readings for Gurugram across 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Gurugram') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Gurugram 2018', width=600, height=300) return chart " 1023,Show a cumulative area chart of PM2.5 readings for Bhagalpur across 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bhagalpur') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Bhagalpur 2023', width=600, height=300) return chart " 1024,How many times did Haryana exceed the WHO guideline for PM10 in the year 2017?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 15.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 1025,"Tabulate the distribution of PM10 per state in 2021 including mean, median, and std."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1026,Identify the city with the 2nd highest 75th percentile of PM2.5 for June 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 1027,Create a ranked table of the 15 best-performing citys by PM10 in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 1028,Which station had the 3rd lowest 25th percentile of PM2.5 in February 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 1029,"Plot the yearly average PM2.5 trends for Jammu and Kashmir, Kerala, and Assam from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jammu and Kashmir', 'Kerala', 'Assam'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Jammu and Kashmir vs Kerala vs Assam', width=550, height=320) return chart " 1030,Generate a year-by-year summary table of PM2.5 readings for Madhya Pradesh.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1031,Determine the station exhibiting the peak 25th percentile of PM2.5 over the Winter season of 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 1032,Determine the city exhibiting the 3rd highest median PM10 over the Winter season of 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 1033,Show the monthly average PM2.5 for Bilaspur in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bilaspur') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Bilaspur 2019', width=450, height=280) " 1034,Show how average PM10 varied month by month for Lucknow in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Lucknow'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1035,Which state recorded the 3rd highest 75th percentile of PM10 in August 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 1036,Tabulate mean PM2.5 and PM10 along with station coverage per state in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}, {'alias': 'Station Count', 'col': 'station', 'fn': 'nunique'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1037,Show average PM10 per state in 2021 with area in km².," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1038,"Create a grouped bar chart comparing the average PM2.5 for Puducherry, Arunachal Pradesh, and Sikkim across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'Arunachal Pradesh', 'Sikkim'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 1039,Which 10 citys recorded the highest average PM2.5 levels in 2020? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 1040,Show the monthly average PM2.5 for Charkhi Dadri in 2022 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Charkhi Dadri') & (data['Timestamp'].dt.year == 2022)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Charkhi Dadri 2022', width=450, height=280) " 1041,"Create a faceted bar chart showing top 10 states by average PM2.5 per year for 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year.isin([2017,2018,2019,2020])].copy() df['Year'] = df['Timestamp'].dt.year agg = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() top = agg.groupby('Year').apply(lambda x: x.nlargest(10,'PM2.5')).reset_index(drop=True) chart = alt.Chart(top).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Avg PM2.5'), y=alt.Y('state:N', sort='-x'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet(facet='Year:O', columns=2).properties(title='Top 10 States by PM2.5 per Year') return chart " 1042,Show PM2.5 exceedance count and rate (%) above 60 µg/m³ per state in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1043,"Considering all years, which January registered the minimum 25th percentile for PM2.5 levels?"," [{'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'Timestamp'}}] " 1044,Show a cumulative area chart of PM2.5 readings for Ooty across 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ooty') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Ooty 2023', width=600, height=300) return chart " 1045,Which station recorded the peak 75th percentile of PM2.5 during the Winter season of 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 1046,List the bottom 10 states with the lowest average PM2.5 in 2020 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 1047,"Compare the monthly average PM2.5 of Ahmednagar, Chamarajanagar, and Ludhiana in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Ahmednagar', 'Chamarajanagar', 'Ludhiana'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Ahmednagar vs Chamarajanagar vs Ludhiana – 2019', width=550, height=320) return chart " 1048,"Plot the yearly average PM2.5 trends for Meghalaya, Puducherry, and Jharkhand from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Meghalaya', 'Puducherry', 'Jharkhand'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Meghalaya vs Puducherry vs Jharkhand', width=550, height=320) return chart " 1049,Generate a city × month cross-tab of mean PM2.5 for Rajasthan in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Ajmer', 'Alwar', 'Bhiwadi', 'Jaipur', 'Jodhpur', 'Kota', 'Pali', 'Udaipur']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1050,Report which state experienced the 2nd most minimal average PM2.5 throughout the Winter season of 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 1051,Show the monthly average PM2.5 for Chamarajanagar in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Chamarajanagar') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Chamarajanagar 2018', width=450, height=280) " 1052,Show a table of the top 5 states by average PM2.5 in 2022 including their PM10 levels too.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 1053,Show a pivot table of monthly average PM2.5 by city for Uttar Pradesh in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Agra', 'Ghaziabad', 'Kanpur', 'Lucknow', 'Moradabad', 'Noida', 'Varanasi']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1054,Create a table showing annual mean PM2.5 levels for Nashik (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Nashik'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1055,Report the city that had the lowest average PM10 in July 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 1056,"In July 2020, which station exhibited the 2nd highest 25th percentile of PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 1057,Plot the distribution of PM2.5 values in Arunachal Pradesh across all years using a histogram.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Arunachal Pradesh'].dropna(subset=['PM2.5']) df = df[['PM2.5']] chart = alt.Chart(df).mark_bar(color='steelblue', opacity=0.75).encode( x=alt.X('PM2\.5:Q', bin=alt.Bin(maxbins=40), title='PM2.5 (µg/m³)'), y=alt.Y('count()', title='Number of Observations'), tooltip=[alt.Tooltip('PM2\.5:Q', bin=True), 'count()'] ).properties(title='PM2.5 Distribution – Arunachal Pradesh (All Years)', width=500, height=300) return chart " 1058,"Compare the monthly average PM2.5 of Mumbai, Davanagere, and Samastipur in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Mumbai', 'Davanagere', 'Samastipur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Mumbai vs Davanagere vs Samastipur – 2017', width=550, height=320) return chart " 1059,Show a pivot table of monthly average PM10 by city for Gujarat in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Gujarat'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Ahmedabad', 'Ankleshwar', 'Gandhinagar', 'Nandesari', 'Vapi', 'Vatva']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1060,"Create a grouped bar chart comparing the average PM2.5 for Andhra Pradesh, Puducherry, and Karnataka across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Puducherry', 'Karnataka'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 1061,Show annual average PM10 for Meghalaya as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Meghalaya'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1062,Create a month-wise summary of average PM10 for West Bengal in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'West Bengal'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1063,Identify the state with the highest 25th percentile PM10 value in July 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 1064,Tabulate the 5 citys with the least PM2.5 pollution in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 1065,Tabulate the monthly mean PM2.5 levels for Meerut during 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Meerut'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1066,Show the monthly average PM10 trend for Thiruvananthapuram from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Thiruvananthapuram'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Thiruvananthapuram (2019–2024)', width=600, height=300) return chart " 1067,Show a year-wise table of average PM2.5 for Chandigarh from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Chandigarh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1068,"Create a grouped bar chart comparing the average PM2.5 for Haryana, Maharashtra, and Karnataka across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Maharashtra', 'Karnataka'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 1069,Generate a descriptive stats table for PM10 grouped by city in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1070,"For April 2020 compared to April 2019, which station registered the highest increase in its 25th percentile PM10 level?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 1071,How many times did Anantapur city go above the WHO guideline for PM2.5 in 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 15.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 1072,Show the monthly average PM2.5 for Katihar in 2024 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Katihar') & (data['Timestamp'].dt.year == 2024)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Katihar 2024', width=450, height=280) " 1073,Show a scatter plot of total NCAP funding vs average PM2.5 (2020) per state.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): pm = data[data['Timestamp'].dt.year == 2020].groupby('state')['PM2.5'].mean().reset_index() funding = ncap_funding_data.groupby('state')['Total fund released'].sum().reset_index() df = pm.merge(funding, on='state').dropna() chart = alt.Chart(df).mark_point(filled=True, size=100).encode( x=alt.X('Total fund released:Q', title='Total NCAP Funding (Cr)'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 – 2020 (µg/m³)'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('Total fund released:Q', format='.1f')] ).properties(title='NCAP Funding vs Average PM2.5 by State (2020)', width=450, height=350) return chart " 1074,Identify the state with the lowest 25th percentile for PM2.5 in August 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 1075,Show annual average PM2.5 for Andhra Pradesh as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1076,Determine the city with the 3rd highest median PM10 in February 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 1077,Create a ranked table of the 10 best-performing citys by PM2.5 in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 1078,Which city registered the 3rd lowest 25th percentile of PM10 during January 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 1079,Tabulate average PM10 for each city in Gujarat across all months of 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Gujarat'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Ahmedabad', 'Ankleshwar', 'Gandhinagar', 'Surat', 'Vatva']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1080,Tabulate the yearly average PM2.5 trend for Prayagraj across all years.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Prayagraj'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1081,What number of Maharashtra stations surpassed 75 µg/m³ of PM10 in 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 75.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 1082,"In September 2024, which station exhibited the highest median PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 1083,Tabulate the 15 states with the least PM2.5 pollution in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 1084,Which city had the highest median PM10 in January 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 1085,"In May 2023, identify the city with the 2nd lowest average PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 1086,Create a table showing annual mean PM2.5 levels for Jodhpur (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Jodhpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1087,Visualize the bottom 10 states with the lowest average PM2.5 in 2017 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2017] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(10, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 10 States by Average PM2.5 in 2017', width=500, height=300) return chart " 1088,"Visualize the monthly average PM10 for Nagaland, Odisha, and Manipur in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Nagaland', 'Odisha', 'Manipur'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Nagaland, Odisha, UP – 2023', width=550, height=320) return chart " 1089,Which station possessed the 2nd lowest 75th percentile for PM2.5 in the Summer season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 1090,List states ranked by PM2.5 concentration relative to their area in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, { 'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM2.5 per km²', 'numerator': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)', 'PM2.5 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1091,Generate a city × month cross-tab of mean PM10 for Haryana in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Haryana'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Ambala', 'Bahadurgarh', 'Ballabgarh', 'Bhiwani', 'Charkhi Dadri', 'Dharuhera', 'Faridabad', 'Fatehabad', 'Gurugram', 'Hisar', 'Jind', 'Kaithal', 'Karnal', 'Kurukshetra ', 'Mandikhera', 'Manesar', 'Narnaul', 'Palwal ', 'Panipat', 'Sirsa', 'Sonipat', 'Yamuna Nagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1092,"Plot the yearly average PM2.5 trends for Tamil Nadu, Tripura, and Kerala from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Tripura', 'Kerala'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Tamil Nadu vs Tripura vs Kerala', width=550, height=320) return chart " 1093,Identify the city where median PM2.5 levels rose most significantly from July 2019 to July 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 1094,Bar chart of PM2.5 per capita (average PM2.5 × 1000 / population) for each state in 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): pm = data[data['Timestamp'].dt.year == 2021].groupby('state')['PM2.5'].mean().reset_index().dropna() df = pm.merge(states_data[['state','population']], on='state') df['PM2.5 per Capita (×1000)'] = df['PM2.5'] / df['population'] * 1e6 df = df.sort_values('PM2.5 per Capita (×1000)', ascending=False) chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5 per Capita (×1000):Q', title='PM2.5 per Million Population'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5 per Capita (×1000):Q', scale=alt.Scale(scheme='purples'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5 per Capita (×1000):Q', format='.4f')] ).properties(title='PM2.5 Per-Capita Pollution Index by State – 2021', width=500, height=400) return chart " 1095,"Identify the state with the third-lowest average PM2.5 on March 31, 2024."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 1096,Which city possessed the 2nd lowest average for PM2.5 in the Winter season of 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 1097,Show a table of the top 5 states by average PM2.5 in 2018 including their PM10 levels too.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 1098,List states with their total NCAP funds received and utilisation percentage.," [ {'op': 'SOURCE', 'params': {'table': 'ncap'}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Total Fund (Cr)', 'col': 'Total fund released', 'fn': 'sum'}, {'alias': 'Utilised (Cr)', 'col': 'Utilisation as on June 2022', 'fn': 'sum'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': {'denominator': 'Total Fund (Cr)', 'new_col': 'Utilisation %', 'numerator': 'Utilised (Cr)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Total Fund (Cr)'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1099,Generate a dual-pollutant summary table (PM2.5 and PM10) by city for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1100,"Plot the yearly average PM2.5 trends for Puducherry, Haryana, and Delhi from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'Haryana', 'Delhi'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Puducherry vs Haryana vs Delhi', width=550, height=320) return chart " 1101,"For 2024, which season (Winter, Summer, Monsoon, Post-Monsoon) experienced the second-highest median PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'season'}}] " 1102,Plot a grouped bar chart of average PM10 by season and year (2020–2023) for all of India.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): def season(m): if m in [12,1,2]: return 'Winter' elif m in [3,4,5]: return 'Summer' elif m in [6,7,8,9]: return 'Monsoon' else: return 'Post-Monsoon' df = data[data['Timestamp'].dt.year.isin([2020,2021,2022,2023])].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df['Season'] = df['Timestamp'].dt.month.apply(season) df = df.groupby(['Season','Year'])['PM10'].mean().reset_index().dropna() order = ['Winter','Summer','Post-Monsoon','Monsoon'] chart = alt.Chart(df).mark_bar().encode( x=alt.X('Season:N', sort=order, title='Season'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('Year:N', title='Year'), xOffset='Year:N', tooltip=['Season:N','Year:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Average PM10 by Season and Year (2020–2023)', width=500, height=320) return chart " 1103,Determine the station with the 3rd lowest median PM2.5 in October 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 1104,Create a heatmap showing the average PM2.5 by month (x-axis) and year (y-axis) for Manipur.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Manipur'].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Year:N', title='Year'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='Avg PM2.5'), tooltip=['Year:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Manipur (Month × Year)', width=500, height=280) return chart " 1105,Which city registered the 2nd lowest 75th percentile of PM10 during November 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 1106,Which state showed the 2nd highest 25th percentile for PM2.5 in the Monsoon season of 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 1107,Name the station with the third-lowest 25th percentile for PM2.5 in May 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 1108,Report the state showing the 3rd lowest total PM10 concentration adjusted for population density.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'sum', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_capita', 'numerator': 'PM10', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'pm_per_capita', 'ascending': True}}] " 1109,Generate a monthly average PM10 table for Gurugram for the year 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Gurugram'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1110,"Compare the monthly average PM2.5 of Jhalawar, Madurai, and Bulandshahr in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Jhalawar', 'Madurai', 'Bulandshahr'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Jhalawar vs Madurai vs Bulandshahr – 2022', width=550, height=320) return chart " 1111,Show PM2.5 exceedance count and rate (%) above 60 µg/m³ per city in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1112,Show a monthly bar chart of the number of days Haryana exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Haryana') & (data['Timestamp'].dt.year == 2018)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Haryana Exceeded WHO PM2.5 Guideline per Month – 2018', width=500, height=300) return chart " 1113,Create a table showing annual mean PM2.5 levels for Assam (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Assam'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1114,Which station had the 2nd lowest 25th percentile of PM10 in February 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 1115,Show a year-wise table of average PM10 for Raipur from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Raipur'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1116,Identify the city that recorded the absolute highest PM2.5 levels on any New Year's Eve.," [{'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 1117,"Determine the station showing the third lowest PM2.5 level on January 27, 2024."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 1118,Show the monthly average PM2.5 for Gwalior in 2024 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Gwalior') & (data['Timestamp'].dt.year == 2024)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Gwalior 2024', width=450, height=280) " 1119,"Create a grouped bar chart comparing the average PM2.5 for Chandigarh, Himachal Pradesh, and Delhi across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chandigarh', 'Himachal Pradesh', 'Delhi'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 1120,"Plot the yearly average PM2.5 trends for Delhi, Jammu and Kashmir, and Meghalaya from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Delhi', 'Jammu and Kashmir', 'Meghalaya'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Delhi vs Jammu and Kashmir vs Meghalaya', width=550, height=320) return chart " 1121,Show the monthly average PM10 trend for Saharsa from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Saharsa'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Saharsa (2019–2024)', width=600, height=300) return chart " 1122,Generate a city × month cross-tab of mean PM2.5 for Tamil Nadu in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Chennai']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1123,Create a table showing annual mean PM10 levels for Bengaluru (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Bengaluru'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1124,Identify the state that recorded the 3rd lowest median PM10 value in April 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 1125,Show the monthly average PM2.5 for Ooty in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ooty') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Ooty 2020', width=450, height=280) " 1126,Create a month-wise PM10 breakdown table across cities in Odisha for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Odisha'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Brajrajnagar', 'Talcher']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1127,Create a table showing PM2.5 levels and population for each state in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1128,Which state showed the 2nd lowest 75th percentile for PM10 in the Summer season of 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 1129,Show a ranked table of the 10 most polluted states by average PM2.5 in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 1130,Create a month-wise PM2.5 breakdown table across cities in Punjab for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Amritsar', 'Bathinda', 'Jalandhar', 'Khanna', 'Ludhiana', 'Mandi Gobindgarh', 'Patiala']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1131,Plot the rolling 30-day average PM2.5 for Haryana in 2019 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Haryana') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Haryana 2019', width=600, height=300) " 1132,Show the monthly average PM10 trend for Siwan from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Siwan'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Siwan (2019–2024)', width=600, height=300) return chart " 1133,Show a pivot table of monthly average PM2.5 by city for Rajasthan in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Ajmer', 'Alwar', 'Bhiwadi', 'Jaipur', 'Jodhpur', 'Kota', 'Pali', 'Udaipur']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1134,Which city got the 5th highest NCAP funding considering its average PM10 concentration in 2021 (FY 2020-21)?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 1135,Identify the 3rd least polluted union territory regarding per capita PM10 exposure for 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'COMPUTE', 'params': {'new_col': 'per_capita_pm', 'numerator': 'PM10', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'per_capita_pm', 'ascending': True}}] " 1136,Show a cumulative area chart of PM2.5 readings for Yamuna Nagar across 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Yamuna Nagar') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Yamuna Nagar 2021', width=600, height=300) return chart " 1137,Report the state with the highest 75th percentile PM10 reading for June 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 1138,"Create a faceted bar chart showing top 13 states by average PM2.5 per year for 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year.isin([2020,2021,2022,2023])].copy() df['Year'] = df['Timestamp'].dt.year agg = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() top = agg.groupby('Year').apply(lambda x: x.nlargest(13,'PM2.5')).reset_index(drop=True) chart = alt.Chart(top).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Avg PM2.5'), y=alt.Y('state:N', sort='-x'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet(facet='Year:O', columns=2).properties(title='Top 13 States by PM2.5 per Year') return chart " 1139,Report which city registered the 2nd most minimal median for PM2.5 throughout the Summer season of 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 1140,Show a year-wise table of average PM10 for Faridabad from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Faridabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1141,"Compare the monthly average PM2.5 of Rishikesh, Kolkata, and Saharsa in 2020 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Rishikesh', 'Kolkata', 'Saharsa'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2020)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Rishikesh vs Kolkata vs Saharsa – 2020', width=550, height=320) return chart " 1142,During which financial year was the total NCAP funding release the 2nd smallest among cities?," [] " 1143,Tabulate the monthly mean PM10 levels for Durgapur during 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Durgapur'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1144,Show annual average PM10 for Gwalior as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Gwalior'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1145,"Visualize the monthly average PM10 for Nagaland, Maharashtra, and Tripura in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Nagaland', 'Maharashtra', 'Tripura'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Nagaland, Maharashtra, UP – 2017', width=550, height=320) return chart " 1146,"In October 2018, report the state with the highest average PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 1147,Show the monthly average PM10 trend for Sirsa from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Sirsa'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Sirsa (2017–2022)', width=600, height=300) return chart " 1148,"Create a grouped bar chart comparing the average PM2.5 for Assam, Nagaland, and Madhya Pradesh across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Assam', 'Nagaland', 'Madhya Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 1149,Plot the weekly average PM2.5 for Palwal in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Palwal') & (data['Timestamp'].dt.year == 2020)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Palwal 2020', width=600, height=300) return chart " 1150,"Visualize the monthly average PM10 for Puducherry, Mizoram, and Punjab in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'Mizoram', 'Punjab'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Puducherry, Mizoram, UP – 2019', width=550, height=320) return chart " 1151,"Show the top 15 states by average PM10 in 2017 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2017] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(15, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 15 States by Average PM10 in 2017', width=500, height=300) return chart " 1152,Name the city showing the highest median PM2.5 for February 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 1153,"Which state showed the third-lowest median PM10 on March 31, 2024?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 1154,"Create a grouped bar chart comparing the average PM2.5 for Chandigarh, Manipur, and Puducherry across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chandigarh', 'Manipur', 'Puducherry'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 1155,Show a monthly bar chart of the number of days Puducherry exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Puducherry') & (data['Timestamp'].dt.year == 2022)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Puducherry Exceeded WHO PM2.5 Guideline per Month – 2022', width=500, height=300) return chart " 1156,Show the monthly average PM2.5 for Nanded in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Nanded') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Nanded 2019', width=450, height=280) " 1157,List citys with their PM10 violation count and rate (>150 µg/m³) in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 150'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1158,Report the state that had the 3rd lowest average PM2.5 in July 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 1159,Determine the state exhibiting the 3rd highest average PM10 in April 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 1160,Visualize the bottom 11 states with the lowest average PM2.5 in 2024 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2024] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(11, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 11 States by Average PM2.5 in 2024', width=500, height=300) return chart " 1161,Which city had the second-lowest mean PM10 reading for November 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 1162,Determine the state exhibiting the 2nd highest 25th percentile of PM10 in July 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 1163,Show the monthly average PM10 trend for Kanpur from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Kanpur'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Kanpur (2019–2024)', width=600, height=300) return chart " 1164,"In March 2018, which city recorded the 3rd highest average PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 1165,Which 20 states had the lowest mean PM10 in 2020? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 1166,"For 2018, which weekday experienced the second-lowest 75th percentile of PM10 pollution levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'Timestamp'}}] " 1167,"Create a grouped bar chart comparing the average PM2.5 for Arunachal Pradesh, Mizoram, and Kerala across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Arunachal Pradesh', 'Mizoram', 'Kerala'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 1168,Show a monthly breakdown table of average PM10 for West Bengal in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'West Bengal'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1169,Show a pivot table of monthly average PM10 by city for Karnataka in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Bengaluru']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1170,Show a monthly breakdown table of average PM10 for Bhopal in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Bhopal'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1171,Show annual average PM2.5 for Nagaland as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Nagaland'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1172,Create a month-wise PM10 breakdown table across cities in Kerala for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Eloor', 'Kollam', 'Thiruvananthapuram', 'Thrissur']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1173,"For Agartala, what date in the last five years registered the second-lowest PM10 reading?"," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 5}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'Timestamp'}}] " 1174,"Show descriptive statistics of PM10 (mean, median, std, min, max) per city in 2022."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1175,Report the station with the 2nd highest 25th percentile of PM2.5 in December 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 1176,"In November 2023, which state registered the 3rd lowest median PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 1177,"In September 2021, identify the state with the highest 75th percentile of PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 1178,Which city had the highest median PM2.5 in November 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 1179,How many times did Jammu and Kashmir Sharif city surpass 75 µg/m³ of PM2.5 in 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 75.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 1180,Show a heatmap of average PM2.5 for the top 10 most polluted states by month for 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(10).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 10 Polluted States by Month (2021)', width=500, height=300) return chart " 1181,Report the station with the lowest median PM2.5 in May 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 1182,"Create a grouped bar chart comparing the average PM2.5 for Nagaland, Puducherry, and Chhattisgarh across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Nagaland', 'Puducherry', 'Chhattisgarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 1183,Which state recorded the peak 75th percentile of PM10 during the Monsoon season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 1184,"Compare the monthly average PM2.5 of Mumbai, Ghaziabad, and Kochi in 2020 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Mumbai', 'Ghaziabad', 'Kochi'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2020)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Mumbai vs Ghaziabad vs Kochi – 2020', width=550, height=320) return chart " 1185,"Compare the monthly average PM2.5 of Belgaum, Hapur, and Agra in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Belgaum', 'Hapur', 'Agra'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Belgaum vs Hapur vs Agra – 2024', width=550, height=320) return chart " 1186,Report the station with the 2nd lowest median PM2.5 in April 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 1187,Tabulate mean PM10 alongside state population figures for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1188,"Plot the yearly average PM2.5 trends for Telangana, Uttar Pradesh, and Bihar from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Telangana', 'Uttar Pradesh', 'Bihar'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Telangana vs Uttar Pradesh vs Bihar', width=550, height=320) return chart " 1189,"Report the union territory having the second smallest population among the top 4 most polluted union territories, when pollution is measured by standard deviation of PM10 levels."," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'std', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 4, 'ret': 'state'}}] " 1190,"Create a grouped bar chart comparing the average PM2.5 for Uttarakhand, Assam, and Chandigarh across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttarakhand', 'Assam', 'Chandigarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 1191,"Create a grouped bar chart comparing the average PM2.5 for Gujarat, Nagaland, and Telangana across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Gujarat', 'Nagaland', 'Telangana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 1192,"Plot the yearly average PM2.5 trends for Bihar, Jammu and Kashmir, and Madhya Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Bihar', 'Jammu and Kashmir', 'Madhya Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Bihar vs Jammu and Kashmir vs Madhya Pradesh', width=550, height=320) return chart " 1193,"Compare the monthly average PM2.5 of Chittoor, Bharatpur, and Thanjavur in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Chittoor', 'Bharatpur', 'Thanjavur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Chittoor vs Bharatpur vs Thanjavur – 2024', width=550, height=320) return chart " 1194,Determine the station with the 2nd lowest average PM2.5 in December 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 1195,"Which union territory exhibits the 3rd maximum PM2.5 concentration per square kilometer, based on average PM2.5 values?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_km2', 'numerator': 'PM2.5', 'denominator': 'area (km2)'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'pm_per_km2', 'ascending': False}}] " 1196,Show the monthly average PM10 trend for Chikkamagaluru from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Chikkamagaluru'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Chikkamagaluru (2017–2022)', width=600, height=300) return chart " 1197,Identify the weekday in 2019 that registered the third-lowest average PM2.5 pollution levels.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'Timestamp'}}] " 1198,Show a bar chart of the top 5 cities by median PM2.5 in 2017.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2017] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(5, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 5 Cities by Median PM2.5 in 2017', width=500, height=300) return chart " 1199,Tabulate the 5 worst states for average PM2.5 in 2021 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 1200,How many times did Ahmedabad exceed 75 µg/m³ of PM2.5 in the year 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 75.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 1201,Identify the state exhibiting the third highest 25th percentile of PM10 during the Summer season of 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 1202,Show the number of days each city exceeded a PM2.5 threshold of 60 µg/m³ in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1203,"Create a table showing top 20 citys ranked by PM2.5 in 2017, also showing PM10."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 1204,Show a monthly breakdown table of average PM10 for Bengaluru in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Bengaluru'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1205,Show the monthly average PM2.5 for Mahad in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Mahad') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Mahad 2019', width=450, height=280) " 1206,"List each state's average PM2.5, PM10, and how many stations it has in 2020."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}, {'alias': 'Station Count', 'col': 'station', 'fn': 'nunique'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1207,"In July 2018, identify the station with the 3rd highest 25th percentile of PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 1208,Which station registered the 3rd maximum 75th percentile of PM10 in the Summer season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 1209,Show the number of days each state exceeded a PM2.5 threshold of 60 µg/m³ in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1210,Report the state with the 2nd lowest 25th percentile of PM10 concentration in relation to its population density.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_capita', 'numerator': 'PM10', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'pm_per_capita', 'ascending': True}}] " 1211,Report the state that had the 2nd highest 25th percentile of PM2.5 in April 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 1212,Determine the station exhibiting the lowest median PM2.5 in May 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 1213,"In September 2019, identify the station with the lowest 75th percentile of PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 1214,Find the station with the highest median PM10 value in February 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 1215,Report which state possessed the lowest 25th percentile of PM10 throughout the Winter season of 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 1216,Tabulate mean PM10 alongside state population figures for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1217,List the top 10 states by average PM10 in 2024 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 1218,"Tabulate PM10 statistics (mean, std, min, max) for each state in 2019."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1219,Show a table of the top 10 states by average PM2.5 in 2024 including their PM10 levels too.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 1220,"Show the mean, median and standard deviation of PM10 per state in 2023 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1221,"Plot the yearly average PM2.5 trends for Telangana, Assam, and Jharkhand from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Telangana', 'Assam', 'Jharkhand'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Telangana vs Assam vs Jharkhand', width=550, height=320) return chart " 1222,Create a table showing annual mean PM2.5 levels for Thiruvananthapuram (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Thiruvananthapuram'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1223,"Show the variability of PM2.5 across citys in 2021 using mean, median, and standard deviation."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1224,"Over all years, which March was associated with the third-highest 25th percentile of PM10 levels?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'Timestamp'}}] " 1225,List the average PM10 for Madhya Pradesh broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1226,"Create a grouped bar chart comparing the average PM2.5 for Mizoram, Meghalaya, and Mizoram across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Mizoram', 'Meghalaya', 'Mizoram'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 1227,Show a monthly breakdown table of average PM2.5 for Jaipur in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Jaipur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1228,Report which state possessed the third highest 25th percentile of PM2.5 throughout the Monsoon season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 1229,List all states with their average PM2.5 and PM10 levels in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1230,Which station showed the 2nd highest 25th percentile for PM10 in the Monsoon season of 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 1231,Show a year-wise table of average PM10 for Kerala from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1232,"Create a grouped bar chart comparing the average PM2.5 for Tamil Nadu, Punjab, and Gujarat across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Punjab', 'Gujarat'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 1233,"Show a stacked bar chart of total NCAP funding per state broken down by fiscal year (FY19-20, FY20-21, FY21-22)."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = ncap_funding_data.groupby('state')[ ['Amount released during FY 2019-20', 'Amount released during FY 2020-21', 'Amount released during FY 2021-22'] ].sum().reset_index() df = df.melt(id_vars='state', var_name='FY', value_name='Amount (Cr)') df['FY'] = df['FY'].str.replace('Amount released during ', '') chart = alt.Chart(df).mark_bar().encode( x=alt.X('Amount (Cr):Q', title='Amount Released (Cr)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('FY:N', title='Fiscal Year'), tooltip=['state:N','FY:N', alt.Tooltip('Amount (Cr):Q', format='.1f')] ).properties(title='NCAP Funding by State and Fiscal Year', width=500, height=350) return chart " 1234,Identify the union territory possessing the 3rd lowest 75th percentile of PM10 concentration when considering population density.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_capita', 'numerator': 'PM10', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'pm_per_capita', 'ascending': True}}] " 1235,Create a month-by-state breakdown table of mean PM2.5 for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Delhi', 'Gujarat', 'Haryana', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Meghalaya', 'Odisha', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1236,Which station showed the 2nd lowest median PM10 in the Post-Monsoon season of 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 1237,Show a cumulative area chart of PM2.5 readings for Mandideep across 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Mandideep') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Mandideep 2022', width=600, height=300) return chart " 1238,Show the monthly average PM2.5 for Pimpri-Chinchwad in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Pimpri-Chinchwad') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Pimpri-Chinchwad 2019', width=450, height=280) " 1239,Which city was second in terms of highest 75th percentile for PM10 in November 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 1240,Show the monthly average PM2.5 for Jodhpur in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Jodhpur') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Jodhpur 2020', width=450, height=280) " 1241,Which city had the 3rd highest median PM2.5 in October 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 1242,Report which station registered the peak median for PM10 throughout the Monsoon season of 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 1243,Show a cumulative area chart of PM2.5 readings for Surat across 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Surat') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Surat 2024', width=600, height=300) return chart " 1244,"Identify the city with the third-highest PM2.5 levels on August 15, 2024."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 1245,"Create a grouped bar chart comparing the average PM2.5 for West Bengal, Maharashtra, and Puducherry across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['West Bengal', 'Maharashtra', 'Puducherry'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 1246,"Create a table of PM2.5, PM10 and station counts by state for 2020."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}, {'alias': 'Station Count', 'col': 'station', 'fn': 'nunique'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1247,How many times did Thane city exceed 30 µg/m³ of PM2.5 in the year 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 30.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 1248,Show annual average PM10 for Guwahati as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Guwahati'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1249,Identify the city that recorded the 3rd lowest average PM10 value in December 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 1250,Which city recorded the 2nd lowest median PM2.5 in the Winter season of 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 1251,Identify the city with the 2nd lowest 75th percentile of PM10 in February 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 1252,"Compare the monthly average PM2.5 of Patna, Jind, and Khanna in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Patna', 'Jind', 'Khanna'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Patna vs Jind vs Khanna – 2018', width=550, height=320) return chart " 1253,Determine the city exhibiting the highest 75th percentile of PM10 over the Post-Monsoon season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 1254,"Plot a scatter chart of state-level average PM2.5 versus population for 2024, with point size representing area."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): pm = data[data['Timestamp'].dt.year == 2024].groupby('state')['PM2.5'].mean().reset_index().dropna() df = pm.merge(states_data, on='state') chart = alt.Chart(df).mark_point(filled=True, opacity=0.7).encode( x=alt.X('population:Q', title='Population', axis=alt.Axis(format='~s')), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), size=alt.Size('area (km2):Q', title='Area (km²)', scale=alt.Scale(range=[50,1000])), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('population:Q', format=','), 'area (km2):Q'] ).properties(title='PM2.5 vs Population (size=Area) – 2024', width=500, height=400) return chart " 1255,Which year corresponds to the third-lowest average PM2.5 concentration?," [{'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'Timestamp'}}] " 1256,List the average PM2.5 for Muzaffarpur broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Muzaffarpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1257,Show a table of the 10 cleanest citys by average PM2.5 in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 1258,Show the monthly average PM10 trend for Singrauli from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Singrauli'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Singrauli (2017–2022)', width=600, height=300) return chart " 1259,"Show descriptive statistics of PM10 (mean, median, std, min, max) per state in 2017."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'q25', 'median', 'q75']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1260,Which union territory exhibits the 2nd lowest median PM10 concentration when considering population density?," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_capita', 'numerator': 'PM10', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'pm_per_capita', 'ascending': True}}] " 1261,Which 15 states recorded the highest average PM2.5 levels in 2024? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 1262,Which city showed the second highest 75th percentile of PM2.5 of all time?," [{'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 1263,Create a month-wise PM10 breakdown table across cities in Rajasthan for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Ajmer', 'Alwar', 'Bhiwadi', 'Jaipur', 'Jodhpur', 'Kota', 'Pali', 'Udaipur']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1264,"Create a grouped bar chart comparing the average PM2.5 for Bihar, Meghalaya, and Haryana across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Bihar', 'Meghalaya', 'Haryana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 1265,"On March 31, 2024, which station had the second-highest 25th percentile for PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 1266,Show the monthly average PM10 trend for Gadag from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Gadag'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Gadag (2019–2024)', width=600, height=300) return chart " 1267,"Visualize the monthly average PM10 for Sikkim, Mizoram, and Delhi in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Sikkim', 'Mizoram', 'Delhi'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Sikkim, Mizoram, UP – 2021', width=550, height=320) return chart " 1268,"On March 31, 2024, which state had the second-lowest median PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 1269,What number of Rajasthan stations exceeded 45 µg/m³ of PM2.5 in 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 45.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 1270,Plot the weekly average PM2.5 for Dausa in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Dausa') & (data['Timestamp'].dt.year == 2024)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Dausa 2024', width=600, height=300) return chart " 1271,"Compare the monthly average PM2.5 of Bihar Sharif, Mangalore, and Ambala in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Bihar Sharif', 'Mangalore', 'Ambala'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Bihar Sharif vs Mangalore vs Ambala – 2024', width=550, height=320) return chart " 1272,Show a monthly bar chart of the number of days Punjab exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Punjab') & (data['Timestamp'].dt.year == 2022)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Punjab Exceeded WHO PM2.5 Guideline per Month – 2022', width=500, height=300) return chart " 1273,"Scatter plot PM2.5 vs PM10 for Rajasthan stations in 2023, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Rajasthan') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Rajasthan Stations 2023', width=450, height=350) " 1274,"In 2019, which day of the week corresponded to the highest median PM10 pollution levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'Timestamp'}}] " 1275,Generate a table showing the 10 most polluted citys based on mean PM2.5 for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 1276,Generate a year-by-year summary table of PM2.5 readings for Andhra Pradesh.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1277,Show the monthly average PM2.5 for Ahmednagar in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ahmednagar') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Ahmednagar 2019', width=450, height=280) " 1278,Show a ranked table of the 5 most polluted citys by average PM10 in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 1279,Generate a table showing the 15 most polluted states based on mean PM10 for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 1280,Which city showed the lowest median PM10 in July 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 1281,Which city recorded the 2nd lowest average PM2.5 in January 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 1282,Tabulate mean PM10 alongside state population figures for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1283,Plot the rolling 30-day average PM2.5 for Nagaland in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Nagaland') & (data['Timestamp'].dt.year == 2020)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Nagaland 2020', width=600, height=300) " 1284,Identify the state with the 4th highest NCAP funding considering its 75th percentile of PM2.5 concentration in 2020 (FY 2019-20).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2020_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 1285,Plot the monthly average PM2.5 trend for Telangana from 2017 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Telangana'].copy() df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly Average PM2.5 Trend – Telangana (2017–2024)', width=600, height=300) return chart " 1286,"Over the past four years in Aurangabad, on which date was the PM10 level the third highest?"," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 4}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'Timestamp'}}] " 1287,Determine the city exhibiting the 2nd highest 25th percentile of PM2.5 over the Winter season of 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 1288,List the top 10 citys by average PM10 in 2018 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 1289,"Compare the monthly average PM2.5 of Chandrapur, Bhilwara, and Arrah in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Chandrapur', 'Bhilwara', 'Arrah'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Chandrapur vs Bhilwara vs Arrah – 2024', width=550, height=320) return chart " 1290,Which state recorded the 2nd highest median PM2.5 in September 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 1291,Show a monthly bar chart of the number of days Tripura exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Tripura') & (data['Timestamp'].dt.year == 2024)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Tripura Exceeded WHO PM2.5 Guideline per Month – 2024', width=500, height=300) return chart " 1292,Report the city that saw the second smallest reduction in funding from FY 2019-20 to FY 2020-21.," [{'op': 'AGG', 'params': {'by': 'city', 'fn': 'sum', 'col': 'change'}}, {'op': 'SORT', 'params': {'col': 'change', 'ascending': False}}] " 1293,"Plot the yearly average PM2.5 trends for Odisha, Himachal Pradesh, and Puducherry from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Odisha', 'Himachal Pradesh', 'Puducherry'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Odisha vs Himachal Pradesh vs Puducherry', width=550, height=320) return chart " 1294,Tabulate average PM10 for each city in Karnataka across all months of 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Bagalkot', 'Bengaluru', 'Bidar', 'Chamarajanagar', 'Chikkaballapur', 'Chikkamagaluru', 'Davanagere', 'Gadag', 'Hubballi', 'Kalaburagi', 'Kolar', 'Koppal', 'Madikeri', 'Mysuru', 'Raichur', 'Ramanagara', 'Shivamogga', 'Vijayapura', 'Yadgir']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1295,Report the state that had the lowest average PM2.5 in February 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 1296,Generate a monthly average PM2.5 table for Assam for the year 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Assam'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1297,Show a heatmap of average PM2.5 for the top 14 most polluted states by month for 2017.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(14).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 14 Polluted States by Month (2017)', width=500, height=300) return chart " 1298,"Visualize the monthly average PM10 for Gujarat, Himachal Pradesh, and Himachal Pradesh in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Gujarat', 'Himachal Pradesh', 'Himachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Gujarat, Himachal Pradesh, UP – 2023', width=550, height=320) return chart " 1299,Show a monthly bar chart of the number of days Nagaland exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Nagaland') & (data['Timestamp'].dt.year == 2022)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Nagaland Exceeded WHO PM2.5 Guideline per Month – 2022', width=500, height=300) return chart " 1300,Determine the state exhibiting the lowest 25th percentile of PM10 in June 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 1301,Show a year-wise table of average PM10 for Mumbai from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Mumbai'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1302,"Create a grouped bar chart comparing the average PM2.5 for Gujarat, Chhattisgarh, and Puducherry across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Gujarat', 'Chhattisgarh', 'Puducherry'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 1303,Which station showed the lowest 75th percentile of PM10 in June 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 1304,Identify the state with the third highest PM2.5 level on 27 January 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 1305,Tabulate average PM2.5 for each city in Kerala across all months of 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Thiruvananthapuram']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1306,"Create a grouped bar chart comparing the average PM2.5 for Kerala, Himachal Pradesh, and Himachal Pradesh across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Kerala', 'Himachal Pradesh', 'Himachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 1307,"Plot the yearly average PM2.5 trends for Haryana, Bihar, and Andhra Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Bihar', 'Andhra Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Haryana vs Bihar vs Andhra Pradesh', width=550, height=320) return chart " 1308,Which state had the highest average PM2.5 in July 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 1309,Which city had the 2nd lowest 25th percentile of PM10 in September 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 1310,Which state experienced the third least significant drop in its average PM10 levels between October and December 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 1311,"Visualize the monthly average PM10 for Puducherry, Telangana, and Odisha in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'Telangana', 'Odisha'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Puducherry, Telangana, UP – 2019', width=550, height=320) return chart " 1312,Show the monthly average PM2.5 for Thanjavur in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Thanjavur') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Thanjavur 2019', width=450, height=280) " 1313,What date during the last four years showed Baghpat's 2nd highest PM10 reading?," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 4}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'Timestamp'}}] " 1314,Show the number of days each city exceeded a PM2.5 threshold of 60 µg/m³ in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1315,Plot the weekly average PM2.5 for Dhule in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Dhule') & (data['Timestamp'].dt.year == 2024)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Dhule 2024', width=600, height=300) return chart " 1316,"Scatter plot PM2.5 vs PM10 for Chhattisgarh stations in 2019, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Chhattisgarh') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Chhattisgarh Stations 2019', width=450, height=350) " 1317,Which station registered the 3rd maximum median PM10 in the Post-Monsoon season of 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 1318,"Visualize the monthly average PM10 for Meghalaya, Jharkhand, and Jammu and Kashmir in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Meghalaya', 'Jharkhand', 'Jammu and Kashmir'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Meghalaya, Jharkhand, UP – 2022', width=550, height=320) return chart " 1319,"Plot the yearly average PM2.5 trends for Jammu and Kashmir, Karnataka, and Rajasthan from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jammu and Kashmir', 'Karnataka', 'Rajasthan'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Jammu and Kashmir vs Karnataka vs Rajasthan', width=550, height=320) return chart " 1320,"Visualize the monthly average PM10 for Jharkhand, Bihar, and Chandigarh in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Bihar', 'Chandigarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Jharkhand, Bihar, UP – 2022', width=550, height=320) return chart " 1321,"Plot the yearly average PM2.5 trends for Madhya Pradesh, Haryana, and Sikkim from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Madhya Pradesh', 'Haryana', 'Sikkim'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Madhya Pradesh vs Haryana vs Sikkim', width=550, height=320) return chart " 1322,"Create a grouped bar chart comparing the average PM2.5 for Puducherry, West Bengal, and Gujarat across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'West Bengal', 'Gujarat'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 1323,Identify the state that saw the least significant fall in 75th percentile PM10 levels when comparing December 2018 to October 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 1324,Tabulate the monthly mean PM2.5 levels for Jammu and Kashmir during 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Jammu and Kashmir'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1325,Show PM2.5 averages in a state × month matrix for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Bihar', 'Delhi', 'Gujarat', 'Haryana', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1326,"Scatter plot PM2.5 vs PM10 for Kerala stations in 2018, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Kerala') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Kerala Stations 2018', width=450, height=350) " 1327,"Scatter plot PM2.5 vs PM10 for Telangana stations in 2019, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Telangana') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Telangana Stations 2019', width=450, height=350) " 1328,Which station displayed the lowest 75th percentile of PM10 in May 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 1329,"Within the last three years in Kishanganj, on what date was the PM10 level the second lowest?"," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 3}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'Timestamp'}}] " 1330,"Scatter plot PM2.5 vs PM10 for Odisha stations in 2017, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Odisha') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Odisha Stations 2017', width=450, height=350) " 1331,"Considering all years, which February registered the minimum median PM10 concentration?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'Timestamp'}}] " 1332,Generate a city × month cross-tab of mean PM2.5 for Punjab in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Amritsar', 'Bathinda', 'Jalandhar', 'Khanna', 'Ludhiana', 'Mandi Gobindgarh', 'Patiala', 'Rupnagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1333,Report which station possessed the lowest median PM2.5 throughout the Post-Monsoon season of 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 1334,"Plot the yearly average PM2.5 trends for Uttar Pradesh, Bihar, and Haryana from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttar Pradesh', 'Bihar', 'Haryana'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Uttar Pradesh vs Bihar vs Haryana', width=550, height=320) return chart " 1335,Create a month-wise summary of average PM10 for Asansol in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Asansol'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1336,"Visualize the monthly average PM10 for Bihar, Tamil Nadu, and Chandigarh in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Bihar', 'Tamil Nadu', 'Chandigarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Bihar, Tamil Nadu, UP – 2022', width=550, height=320) return chart " 1337,Tabulate average PM10 for each city in Haryana across all months of 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Haryana'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Ambala', 'Bahadurgarh', 'Ballabgarh', 'Bhiwani', 'Charkhi Dadri', 'Dharuhera', 'Faridabad', 'Fatehabad', 'Gurugram', 'Hisar', 'Jind', 'Kaithal', 'Karnal', 'Kurukshetra ', 'Mandikhera', 'Manesar', 'Narnaul', 'Palwal ', 'Panipat', 'Sirsa', 'Sonipat', 'Yamuna Nagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1338,"Show the variability of PM2.5 across states in 2024 using mean, median, and standard deviation."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1339,List states by PM2.5 concentration per million inhabitants in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM2.5 per million', 'numerator': 'PM2.5', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'PM2.5 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1340,Determine the station exhibiting the highest 25th percentile of PM10 in June 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 1341,Plot a grouped bar chart of average PM10 by season and year (2018–2021) for all of India.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): def season(m): if m in [12,1,2]: return 'Winter' elif m in [3,4,5]: return 'Summer' elif m in [6,7,8,9]: return 'Monsoon' else: return 'Post-Monsoon' df = data[data['Timestamp'].dt.year.isin([2018,2019,2020,2021])].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df['Season'] = df['Timestamp'].dt.month.apply(season) df = df.groupby(['Season','Year'])['PM10'].mean().reset_index().dropna() order = ['Winter','Summer','Post-Monsoon','Monsoon'] chart = alt.Chart(df).mark_bar().encode( x=alt.X('Season:N', sort=order, title='Season'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('Year:N', title='Year'), xOffset='Year:N', tooltip=['Season:N','Year:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Average PM10 by Season and Year (2018–2021)', width=500, height=320) return chart " 1342,Show a monthly breakdown table of average PM10 for Telangana in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Telangana'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1343,How many times did Manipur exceed 45 µg/m³ of PM2.5 in 2017?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 45.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 1344,"Considering all years, which July was associated with the highest average PM10 levels?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'Timestamp'}}] " 1345,Tabulate the 20 citys with the least PM2.5 pollution in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 1346,Show a monthly bar chart of the number of days Odisha exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Odisha') & (data['Timestamp'].dt.year == 2018)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Odisha Exceeded WHO PM2.5 Guideline per Month – 2018', width=500, height=300) return chart " 1347,Generate a city × month cross-tab of mean PM2.5 for Kerala in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Eloor', 'Kannur', 'Kochi', 'Kollam', 'Thiruvananthapuram', 'Thrissur']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1348,List average PM2.5 by month for Agra in 2017 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Agra'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1349,Which station had the third-lowest 75th percentile for PM2.5 in November 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 1350,Determine the station with the 2nd lowest 75th percentile of PM2.5 in June 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 1351,Show a bar chart of the top 8 cities by median PM2.5 in 2017.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2017] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(8, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 8 Cities by Median PM2.5 in 2017', width=500, height=300) return chart " 1352,Visualize the bottom 11 states with the lowest average PM2.5 in 2019 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2019] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(11, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 11 States by Average PM2.5 in 2019', width=500, height=300) return chart " 1353,List average PM2.5 by month for Moradabad in 2018 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Moradabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1354,Show a monthly breakdown table of average PM10 for Indore in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Indore'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1355,"Compare the monthly average PM2.5 of Anantapur, Ramanathapuram, and Baran in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Anantapur', 'Ramanathapuram', 'Baran'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Anantapur vs Ramanathapuram vs Baran – 2024', width=550, height=320) return chart " 1356,Generate a city × month cross-tab of mean PM2.5 for Andhra Pradesh in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Amaravati', 'Rajamahendravaram', 'Tirupati', 'Visakhapatnam']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1357,Create a table showing annual mean PM2.5 levels for Rajasthan (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1358,Show a year-wise table of average PM10 for Uttar Pradesh from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1359,Show the monthly average PM2.5 for Sawai Madhopur in 2024 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Sawai Madhopur') & (data['Timestamp'].dt.year == 2024)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Sawai Madhopur 2024', width=450, height=280) " 1360,Generate a year-by-year summary table of PM2.5 readings for Telangana.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Telangana'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1361,Show a cumulative area chart of PM2.5 readings for Raipur across 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Raipur') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Raipur 2023', width=600, height=300) return chart " 1362,Plot the weekly average PM2.5 for Sawai Madhopur in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Sawai Madhopur') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Sawai Madhopur 2023', width=600, height=300) return chart " 1363,"Compare the monthly average PM2.5 of Chamarajanagar, Chittoor, and Amritsar in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Chamarajanagar', 'Chittoor', 'Amritsar'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Chamarajanagar vs Chittoor vs Amritsar – 2022', width=550, height=320) return chart " 1364,Determine the state that showed the 2nd highest average PM10 over the Post-Monsoon season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 1365,Report which city experienced the 2nd highest average PM2.5 throughout the Summer season of 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 1366,Tabulate both PM2.5 and PM10 averages by city for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1367,"Plot the yearly average PM2.5 trends for Karnataka, Arunachal Pradesh, and Rajasthan from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Karnataka', 'Arunachal Pradesh', 'Rajasthan'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Karnataka vs Arunachal Pradesh vs Rajasthan', width=550, height=320) return chart " 1368,Which station registered the 3rd lowest 75th percentile of PM10 during April 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 1369,Plot the distribution of PM2.5 values in Uttarakhand across all years using a histogram.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Uttarakhand'].dropna(subset=['PM2.5']) df = df[['PM2.5']] chart = alt.Chart(df).mark_bar(color='steelblue', opacity=0.75).encode( x=alt.X('PM2\.5:Q', bin=alt.Bin(maxbins=40), title='PM2.5 (µg/m³)'), y=alt.Y('count()', title='Number of Observations'), tooltip=[alt.Tooltip('PM2\.5:Q', bin=True), 'count()'] ).properties(title='PM2.5 Distribution – Uttarakhand (All Years)', width=500, height=300) return chart " 1370,Which state showed the 2nd lowest 75th percentile for PM2.5 in the Summer season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 1371,Identify the state exhibiting the third most minimal 25th percentile of PM2.5 during the Summer season of 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 1372,"In August 2023, identify the state with the 3rd highest median PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 1373,"Visualize the monthly average PM10 for Bihar, Tamil Nadu, and Andhra Pradesh in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Bihar', 'Tamil Nadu', 'Andhra Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Bihar, Tamil Nadu, UP – 2021', width=550, height=320) return chart " 1374,"Visualize the monthly average PM10 for Tamil Nadu, Sikkim, and West Bengal in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Sikkim', 'West Bengal'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Tamil Nadu, Sikkim, UP – 2021', width=550, height=320) return chart " 1375,"Show the top 15 states by average PM10 in 2018 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2018] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(15, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 15 States by Average PM10 in 2018', width=500, height=300) return chart " 1376,"Considering all years, which May experienced the third-lowest median PM10 levels?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'Timestamp'}}] " 1377,Tabulate average PM10 for each state across all months in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Delhi', 'Karnataka', 'Maharashtra', 'Telangana', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1378,Show a table of the 15 cleanest citys by average PM2.5 in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 1379,Plot the top 10 states by average PM2.5 in 2019 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2019] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(10, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 10 States by Average PM2.5 in 2019', width=500, height=300) return chart " 1380,Create a month-wise PM10 breakdown table across cities in Tamil Nadu for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Ariyalur', 'Chengalpattu', 'Chennai', 'Cuddalore', 'Gummidipoondi', 'Ooty', 'Palkalaiperur', 'Ramanathapuram', 'Thoothukudi', 'Tirupur', 'Vellore', 'Virudhunagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1381,Report the city with the 3rd lowest average PM2.5 in December 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 1382,Show the monthly average PM10 trend for Sasaram from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Sasaram'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Sasaram (2019–2024)', width=600, height=300) return chart " 1383,"Create a grouped bar chart comparing the average PM2.5 for Rajasthan, Tamil Nadu, and Jharkhand across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Tamil Nadu', 'Jharkhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 1384,Name the city with the lowest 25th percentile for PM2.5 in May 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 1385,"Plot the yearly average PM2.5 trends for Jammu and Kashmir, Uttarakhand, and Assam from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jammu and Kashmir', 'Uttarakhand', 'Assam'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Jammu and Kashmir vs Uttarakhand vs Assam', width=550, height=320) return chart " 1386,"Compare the monthly average PM2.5 of Thrissur, Karauli, and Jalna in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Thrissur', 'Karauli', 'Jalna'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Thrissur vs Karauli vs Jalna – 2024', width=550, height=320) return chart " 1387,Show the monthly average PM2.5 for Sikkim across each year from 2017 to 2024 as small multiples (faceted by year).," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Sikkim'].copy() df['Year'] = df['Timestamp'].dt.year df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5'), tooltip=['Year:O','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet( facet=alt.Facet('Year:O', title='Year'), columns=4 ).properties(title='Monthly PM2.5 in Sikkim by Year (2017–2024)') return chart " 1388,Tabulate daily PM10 exceedances (above 150 µg/m³) per city for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1389,Which 15 citys had the lowest mean PM10 in 2018? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 1390,Show a bar chart of the top 6 cities by median PM2.5 in 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2021] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(6, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 6 Cities by Median PM2.5 in 2021', width=500, height=300) return chart " 1391,Plot the rolling 30-day average PM2.5 for Maharashtra in 2019 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Maharashtra') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Maharashtra 2019', width=600, height=300) " 1392,Generate a table showing the 5 most polluted citys based on mean PM2.5 for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 1393,"Visualize the monthly average PM10 for Karnataka, Bihar, and Arunachal Pradesh in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Karnataka', 'Bihar', 'Arunachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Karnataka, Bihar, UP – 2023', width=550, height=320) return chart " 1394,Generate a city × month cross-tab of mean PM2.5 for West Bengal in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'West Bengal'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Asansol', 'Durgapur', 'Howrah', 'Kolkata', 'Siliguri']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1395,"Show the variability of PM10 across states in 2024 using mean, median, and standard deviation."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1396,Identify the state with the second-lowest average PM2.5 reading for July 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 1397,Which station experienced the highest 25th percentile for PM10 in the Winter season of 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 1398,Show the monthly average PM2.5 for Chikkamagaluru in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Chikkamagaluru') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Chikkamagaluru 2018', width=450, height=280) " 1399,Show a pivot table of monthly average PM2.5 by city for Karnataka in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Bagalkot', 'Bengaluru', 'Chamarajanagar', 'Chikkaballapur', 'Chikkamagaluru', 'Davanagere', 'Gadag', 'Hassan', 'Hubballi', 'Kalaburagi', 'Koppal', 'Madikeri', 'Mangalore', 'Mysuru', 'Raichur', 'Ramanagara', 'Shivamogga', 'Vijayapura', 'Yadgir']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1400,Determine the city with the highest median PM2.5 in March 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 1401,Which city had the 3rd lowest median PM2.5 in January 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 1402,Show the monthly average PM2.5 for Pimpri-Chinchwad in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Pimpri-Chinchwad') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Pimpri-Chinchwad 2017', width=450, height=280) " 1403,Show a monthly bar chart of the number of days Uttarakhand exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Uttarakhand') & (data['Timestamp'].dt.year == 2023)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Uttarakhand Exceeded WHO PM2.5 Guideline per Month – 2023', width=500, height=300) return chart " 1404,How many times did Bangalore city go above the Indian guideline for PM10 in 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 60.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 1405,Generate a year-by-year summary table of PM2.5 readings for Jodhpur.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Jodhpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1406,Show the monthly average PM2.5 for Jabalpur in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Jabalpur') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Jabalpur 2018', width=450, height=280) " 1407,"In July 2023, identify the station with the lowest 75th percentile of PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 1408,Identify the state that registered the third highest 25th percentile for PM2.5 during the Winter season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 1409,List the top 5 citys by average PM10 in 2019 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 1410,"Plot the yearly average PM2.5 trends for Tamil Nadu, Chandigarh, and Odisha from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Chandigarh', 'Odisha'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Tamil Nadu vs Chandigarh vs Odisha', width=550, height=320) return chart " 1411,Create a grouped bar chart comparing the average PM2.5 in Winter vs Summer for the top 11 most polluted states.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top6 = data.groupby('state')['PM2.5'].mean().nlargest(11).index.tolist() df = data[data['state'].isin(top6)].copy() df['Season'] = df['Timestamp'].dt.month.apply( lambda m: 'Winter' if m in [12,1,2] else ('Summer' if m in [3,4,5] else None)) df = df.dropna(subset=['Season']) df = df.groupby(['state','Season'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('state:N', title='State'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('Season:N', title='Season'), xOffset='Season:N', tooltip=['state:N','Season:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Winter vs Summer PM2.5 – Top 11 Polluted States', width=550, height=320) return chart " 1412,Create a table with mean and standard deviation of PM10 by city in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1413,"Visualize the monthly average PM10 for Puducherry, Mizoram, and Assam in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'Mizoram', 'Assam'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Puducherry, Mizoram, UP – 2022', width=550, height=320) return chart " 1414,"Visualize the monthly average PM10 for Arunachal Pradesh, Rajasthan, and Delhi in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Arunachal Pradesh', 'Rajasthan', 'Delhi'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Arunachal Pradesh, Rajasthan, UP – 2024', width=550, height=320) return chart " 1415,Which city exhibited the 3rd lowest average PM2.5 in September 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 1416,Identify the station with the highest 25th percentile of PM10 for April 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 1417,Determine the state exhibiting the peak median PM10 over the Post-Monsoon season of 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 1418,"Scatter plot PM2.5 vs PM10 for Assam stations in 2020, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Assam') & (data['Timestamp'].dt.year == 2020)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Assam Stations 2020', width=450, height=350) " 1419,Identify the city with the 5th highest NCAP funding considering the standard deviation of its PM10 concentration in 2022 (FY 2021-22).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'std', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2022_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 1420,"Create a grouped bar chart comparing the average PM2.5 for Rajasthan, Gujarat, and West Bengal across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Gujarat', 'West Bengal'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 1421,Show a cumulative area chart of PM2.5 readings for Damoh across 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Damoh') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Damoh 2023', width=600, height=300) return chart " 1422,Which city registered the 2nd minimum 25th percentile of PM10 during the Summer season of 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 1423,Create a ranked table of the 5 best-performing citys by PM2.5 in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 1424,Which city had the 2nd lowest median PM10 in June 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 1425,"In August 2022, identify the station with the 2nd highest 75th percentile of PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 1426,"On March 31, 2021, which city had the third-lowest 75th percentile of PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 1427,Which station registered the 3rd lowest 75th percentile of PM10 during April 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 1428,Which union territory exhibits the 4th highest total PM10 concentration when considering population density?," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'sum', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_capita', 'numerator': 'PM10', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'pm_per_capita', 'ascending': False}}] " 1429,Determine the state with the peak median PM2.5 concentration for June 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 1430,Which city possessed the highest average for PM2.5 in the Summer season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 1431,"Compare the monthly average PM2.5 of Bhilwara, Kalyan, and Ratlam in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Bhilwara', 'Kalyan', 'Ratlam'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Bhilwara vs Kalyan vs Ratlam – 2023', width=550, height=320) return chart " 1432,Identify the state with the 2nd highest 25th percentile of PM10 for August 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 1433,Identify the state that registered the peak 75th percentile of PM10 during the Monsoon season of 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 1434,Show PM2.5 exceedance count and rate (%) above 60 µg/m³ per state in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1435,"Which state, from those with populations exceeding the average, is allocated the highest per capita NCAP funding?"," [{'op': 'COMPUTE', 'params': {'new_col': 'funding_per_capita', 'numerator': 'total_fund', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'funding_per_capita', 'ascending': False}}] " 1436,Identify the state that registered the peak median PM10 during the Post-Monsoon season of 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 1437,List states by PM2.5 concentration per million inhabitants in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM2.5 per million', 'numerator': 'PM2.5', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'PM2.5 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1438,Plot the weekly average PM2.5 for Kaithal in 2019 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Kaithal') & (data['Timestamp'].dt.year == 2019)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Kaithal 2019', width=600, height=300) return chart " 1439,Which station recorded the 3rd highest average PM2.5 in November 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 1440,"Which state with a land area greater than 50,000 km² shows the maximum PM10 level, according to its standard deviation of PM10 level?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'std', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}] " 1441,"Create a grouped bar chart comparing the average PM2.5 for Odisha, Telangana, and Karnataka across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Odisha', 'Telangana', 'Karnataka'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 1442,Show a cumulative area chart of PM2.5 readings for Jabalpur across 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Jabalpur') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Jabalpur 2022', width=600, height=300) return chart " 1443,Show the monthly average PM2.5 for Muzaffarpur in 2023 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Muzaffarpur') & (data['Timestamp'].dt.year == 2023)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Muzaffarpur 2023', width=450, height=280) " 1444,Show the monthly average PM2.5 for Tirupur in 2022 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Tirupur') & (data['Timestamp'].dt.year == 2022)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Tirupur 2022', width=450, height=280) " 1445,Identify the station that recorded the 3rd highest average PM2.5 value in August 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 1446,List the average PM10 for Muzaffarpur broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Muzaffarpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1447,"Create a grouped bar chart comparing the average PM2.5 for Gujarat, Uttar Pradesh, and Rajasthan across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Gujarat', 'Uttar Pradesh', 'Rajasthan'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 1448,Show the monthly average PM2.5 for Damoh in 2023 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Damoh') & (data['Timestamp'].dt.year == 2023)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Damoh 2023', width=450, height=280) " 1449,Show the monthly average PM2.5 for Kerala across each year from 2017 to 2024 as small multiples (faceted by year).," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Kerala'].copy() df['Year'] = df['Timestamp'].dt.year df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5'), tooltip=['Year:O','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet( facet=alt.Facet('Year:O', title='Year'), columns=4 ).properties(title='Monthly PM2.5 in Kerala by Year (2017–2024)') return chart " 1450,Show the monthly average PM2.5 for Kunjemura in 2023 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Kunjemura') & (data['Timestamp'].dt.year == 2023)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Kunjemura 2023', width=450, height=280) " 1451,Show a table of the 15 cleanest citys by average PM2.5 in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 1452,"Create a grouped bar chart comparing the average PM2.5 for Mizoram, Bihar, and Tripura across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Mizoram', 'Bihar', 'Tripura'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 1453,Which state recorded the second-lowest average PM10 reading for September 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 1454,Show a pivot table of monthly average PM2.5 by city for Assam in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Assam'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Byrnihat', 'Guwahati', 'Nagaon', 'Nalbari', 'Silchar', 'Sivasagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1455,Show a cumulative area chart of PM2.5 readings for Pali across 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Pali') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Pali 2024', width=600, height=300) return chart " 1456,Show PM2.5 density (µg/m³ per km²) by state for 2024 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, { 'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM2.5 per km²', 'numerator': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)', 'PM2.5 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1457,Create a month-wise PM2.5 breakdown table across cities in Haryana for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Haryana'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Ambala', 'Bahadurgarh', 'Ballabgarh', 'Bhiwani', 'Charkhi Dadri', 'Dharuhera', 'Faridabad', 'Fatehabad', 'Gurugram', 'Hisar', 'Jind', 'Kaithal', 'Karnal', 'Kurukshetra', 'Mandikhera', 'Manesar', 'Narnaul', 'Palwal', 'Panchkula', 'Rohtak', 'Sirsa', 'Sonipat', 'Yamuna Nagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1458,Create a month-wise summary of average PM10 for West Bengal in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'West Bengal'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1459,Determine the city with the 2nd highest median PM10 in September 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 1460,Determine a week with Jhalawar's 3rd highest PM10 levels over all these years.," [{'op': 'FILTER', 'params': {'field': 'city', 'value': 'Jhalawar'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'week'}}] " 1461,Which 15 states recorded the highest average PM2.5 levels in 2021? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 1462,Tabulate the 15 citys with the least PM2.5 pollution in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 1463,"Comparing December 2019 to October 2019, which state showed the most significant drop in median PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 1464,Identify the station that recorded the 3rd lowest 75th percentile of PM2.5 value in March 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 1465,Create a summary table ranking the top 10 states by PM10 concentration in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 1466,Create a table showing annual mean PM10 levels for Gandhinagar (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Gandhinagar'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1467,"Show the top 13 states by average PM10 in 2021 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2021] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(13, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 13 States by Average PM10 in 2021', width=500, height=300) return chart " 1468,Create a summary table ranking the top 10 states by PM10 concentration in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 1469,List the bottom 20 citys with the lowest average PM10 in 2020 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 1470,Generate a city × month cross-tab of mean PM2.5 for Punjab in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Amritsar', 'Bathinda', 'Jalandhar', 'Khanna', 'Ludhiana', 'Mandi Gobindgarh', 'Patiala', 'Rupnagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1471,Which state had the 2nd lowest median PM2.5 in March 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 1472,Show the monthly average PM10 trend for Pathardih from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Pathardih'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Pathardih (2019–2024)', width=600, height=300) return chart " 1473,Show a monthly bar chart of the number of days Gujarat exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2020.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Gujarat') & (data['Timestamp'].dt.year == 2020)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Gujarat Exceeded WHO PM2.5 Guideline per Month – 2020', width=500, height=300) return chart " 1474,Show a ranked table of the 5 most polluted states by average PM10 in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 1475,"In February 2018, report the station with the 2nd lowest average PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 1476,Create a month-wise PM10 breakdown table across cities in Punjab for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Amritsar', 'Ludhiana', 'Mandi Gobindgarh']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1477,Tabulate the 5 states with the least PM2.5 pollution in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 1478,List average PM10 by month for Telangana in 2022 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Telangana'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1479,Show how many times PM2.5 exceeded 100 µg/m³ per day across citys in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1480,"On January 27, 2018, which city had the second most minimal PM10 level?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 1481,Name the state with the second-highest 75th percentile for PM2.5 in May 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 1482,Report the station with the lowest average PM10 in December 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 1483,Tabulate the yearly average PM10 trend for Kerala across all years.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1484,Show a pivot table of monthly average PM10 by city for Bihar in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Bihar'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Gaya', 'Hajipur', 'Muzaffarpur', 'Patna']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1485,"Considering all years, which November registered the third-highest median PM10 levels?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'Timestamp'}}] " 1486,Identify the station that saw the second most significant fall in average PM2.5 levels when comparing December 2019 to October 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 1487,Report which city registered the second highest PM2.5 level on 27 January 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 1488,"On January 27, 2019, which station registered the third lowest PM10 level?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 1489,"Scatter plot PM2.5 vs PM10 for Chhattisgarh stations in 2018, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Chhattisgarh') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Chhattisgarh Stations 2018', width=450, height=350) " 1490,Identify the city that registered the second highest 25th percentile for PM2.5 across all time.," [{'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 1491,Identify the station with the 3rd lowest average PM2.5 in May 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 1492,"Create a grouped bar chart comparing the average PM2.5 for Nagaland, Mizoram, and Gujarat across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Nagaland', 'Mizoram', 'Gujarat'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 1493,Tabulate the top 20 states for PM2.5 in 2020 along with their corresponding PM10 values.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 1494,"Create a grouped bar chart comparing the average PM2.5 for Puducherry, Assam, and Nagaland across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'Assam', 'Nagaland'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 1495,Show annual average PM2.5 for Patna as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Patna'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1496,Show a year-wise table of average PM2.5 for Chennai from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Chennai'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1497,Tabulate the top 10 states for PM2.5 in 2020 along with their corresponding PM10 values.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 1498,Which city had the 3rd lowest NCAP funding with respect to its median PM2.5 concentration in 2020 (FY 2019-20)?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2020_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 1499,Create a table of PM10 exceedance frequency above 150 µg/m³ by state for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 150'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1500,Which city showed the 3rd lowest 25th percentile for PM10 in the Summer season of 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 1501,Show a cumulative area chart of PM2.5 readings for Ratlam across 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ratlam') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Ratlam 2022', width=600, height=300) return chart " 1502,Create a table of PM2.5 exceedance frequency above 60 µg/m³ by state for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1503,Tabulate both PM2.5 and PM10 averages by city for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1504,How many times did Tripura surpass the Indian guideline for PM2.5 in the year 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 60.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 1505,"Create a grouped bar chart comparing the average PM2.5 for Madhya Pradesh, Arunachal Pradesh, and Chandigarh across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Madhya Pradesh', 'Arunachal Pradesh', 'Chandigarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 1506,Create a month-wise summary of average PM10 for Uttar Pradesh in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1507,Plot the rolling 30-day average PM2.5 for Arunachal Pradesh in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Arunachal Pradesh') & (data['Timestamp'].dt.year == 2020)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Arunachal Pradesh 2020', width=600, height=300) " 1508,List the top 20 states by average PM2.5 in 2022 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 1509,Create a month-wise summary of average PM2.5 for Telangana in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Telangana'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1510,"Scatter plot PM2.5 vs PM10 for Maharashtra stations in 2021, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Maharashtra') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Maharashtra Stations 2021', width=450, height=350) " 1511,Plot the average PM2.5 across all states in February 2019 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['Timestamp'].dt.year == 2019) & (data['Timestamp'].dt.month == 2)] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('PM2.5', ascending=False) chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='plasma'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Average PM2.5 by State – February 2019', width=500, height=400) return chart " 1512,Tabulate the monthly mean PM2.5 levels for Agra during 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Agra'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1513,"Visualize the monthly average PM10 for Rajasthan, Jammu and Kashmir, and Maharashtra in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Jammu and Kashmir', 'Maharashtra'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Rajasthan, Jammu and Kashmir, UP – 2018', width=550, height=320) return chart " 1514,Show a monthly bar chart of the number of days Rajasthan exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Rajasthan') & (data['Timestamp'].dt.year == 2018)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Rajasthan Exceeded WHO PM2.5 Guideline per Month – 2018', width=500, height=300) return chart " 1515,Show a pivot table of monthly average PM2.5 by city for Maharashtra in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Aurangabad', 'Chandrapur', 'Kalyan', 'Mumbai', 'Nagpur', 'Nashik', 'Navi Mumbai', 'Pune', 'Solapur']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1516,"Create a grouped bar chart comparing the average PM2.5 for Nagaland, Maharashtra, and Haryana across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Nagaland', 'Maharashtra', 'Haryana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 1517,"In February 2019, identify the station with the 3rd lowest 25th percentile of PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 1518,Determine the city exhibiting the 2nd highest median PM10 in December 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 1519,"Create a grouped bar chart comparing the average PM2.5 for Himachal Pradesh, Karnataka, and Punjab across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Himachal Pradesh', 'Karnataka', 'Punjab'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 1520,"Plot the yearly average PM2.5 trends for Haryana, Kerala, and Jharkhand from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Kerala', 'Jharkhand'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Haryana vs Kerala vs Jharkhand', width=550, height=320) return chart " 1521,Which 5 citys had the lowest mean PM2.5 in 2024? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 1522,"Create a grouped bar chart comparing the average PM2.5 for West Bengal, Tripura, and Madhya Pradesh across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['West Bengal', 'Tripura', 'Madhya Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 1523,Show how many times PM10 exceeded 100 µg/m³ per day across citys in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1524,Show a bar chart comparing the 75th percentile PM2.5 of all states in winter 2022 (November–February).," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.month.isin([11,12,1,2])] df = df[df['Timestamp'].dt.year.isin([2022,2023])] df = df.groupby('state')['PM2.5'].quantile(0.75).reset_index().dropna() df.columns = ['state','PM2.5_p75'] df = df.sort_values('PM2.5_p75', ascending=False) chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5_p75:Q', title='75th Percentile PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5_p75:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5_p75:Q', format='.1f', title='P75 PM2.5')] ).properties(title='75th Percentile PM2.5 by State – Winter 2022', width=500, height=400) return chart " 1525,"On March 31, 2024, which state had the second-lowest 25th percentile for PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 1526,"Compare the monthly average PM2.5 of Chengalpattu, Bagalkot, and Kota in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Chengalpattu', 'Bagalkot', 'Kota'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Chengalpattu vs Bagalkot vs Kota – 2017', width=550, height=320) return chart " 1527,Show average PM2.5 per capita by state in 2024 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM2.5 per million', 'numerator': 'PM2.5', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'PM2.5 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1528,Report the city with the 2nd lowest median PM10 in July 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 1529,"Compare the monthly average PM2.5 of Jind, Gadag, and Kishanganj in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Jind', 'Gadag', 'Kishanganj'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Jind vs Gadag vs Kishanganj – 2022', width=550, height=320) return chart " 1530,Tabulate average PM10 for each city in Kerala across all months of 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Thiruvananthapuram']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1531,Which station registered the 2nd highest 25th percentile of PM10 during October 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 1532,Find the station that registered the second-highest average PM10 in January 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 1533,How many times did Mandideep city go above 30 µg/m³ of PM2.5 in 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 30.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 1534,"Comparing December 2023 to October 2023, which city showed the second least significant drop in average PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 1535,"Show the top 12 states by average PM10 in 2022 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2022] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(12, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 12 States by Average PM10 in 2022', width=500, height=300) return chart " 1536,Identify the city with the 2nd lowest median PM2.5 in July 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 1537,"Create a grouped bar chart comparing the average PM2.5 for Andhra Pradesh, Haryana, and Bihar across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Haryana', 'Bihar'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 1538,Which station registered the 2nd highest 25th percentile of PM10 during December 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 1539,Show a monthly bar chart of the number of days Punjab exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Punjab') & (data['Timestamp'].dt.year == 2023)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Punjab Exceeded WHO PM2.5 Guideline per Month – 2023', width=500, height=300) return chart " 1540,List the top 10 states by average PM2.5 in 2022 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 1541,"Which state having a land area less than 50,000 km² registers the minimum PM2.5 level, based on its 75th percentile PM2.5 level?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}] " 1542,Show the monthly average PM10 trend for Pithampur from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Pithampur'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Pithampur (2019–2024)', width=600, height=300) return chart " 1543,"Considering 2020, what week number displayed the lowest average PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'week'}}] " 1544,Show the monthly average PM10 trend for Muzaffarpur from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Muzaffarpur'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Muzaffarpur (2019–2024)', width=600, height=300) return chart " 1545,Report the state receiving NCAP funding that shows the 2nd lowest PM10 levels.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}] " 1546,Visualize the bottom 13 states with the lowest average PM2.5 in 2022 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2022] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(13, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 13 States by Average PM2.5 in 2022', width=500, height=300) return chart " 1547,Plot the top 9 states by average PM2.5 in 2022 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2022] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(9, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 9 States by Average PM2.5 in 2022', width=500, height=300) return chart " 1548,"Show the variability of PM10 across states in 2018 using mean, median, and standard deviation."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1549,Which state had the highest median PM10 in December 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 1550,"Tabulate PM2.5 statistics (mean, std, min, max) for each state in 2017."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1551,Show a monthly breakdown table of average PM10 for Karnataka in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1552,Show how average PM10 varied month by month for Asansol in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Asansol'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1553,Identify the state with the lowest median PM2.5 for April 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 1554,Show a monthly bar chart of the number of days Tamil Nadu exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Tamil Nadu') & (data['Timestamp'].dt.year == 2018)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Tamil Nadu Exceeded WHO PM2.5 Guideline per Month – 2018', width=500, height=300) return chart " 1555,"In July 2019, which city registered the highest median PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 1556,"In December 2022, report the city with the 3rd lowest 75th percentile of PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 1557,List states with their PM2.5 violation count and rate (>100 µg/m³) in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1558,Which city noted the peak 25th percentile of PM10 during the Monsoon season of 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 1559,List the top 15 states by average PM2.5 in 2018 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 1560,"In August 2018, report the city with the 2nd highest 75th percentile of PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 1561,"Create a grouped bar chart comparing the average PM2.5 for West Bengal, Assam, and Assam across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['West Bengal', 'Assam', 'Assam'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 1562,Which 5 citys recorded the highest average PM10 levels in 2017? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 1563,Tabulate the 10 worst states for average PM2.5 in 2019 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 1564,Show a bar chart of the top 13 cities by median PM2.5 in 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2018] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(13, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 13 Cities by Median PM2.5 in 2018', width=500, height=300) return chart " 1565,"In 2019, which week experienced the maximum median PM2.5 concentrations?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'week'}}] " 1566,Tabulate the yearly average PM10 trend for Gurugram across all years.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Gurugram'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1567,Create a summary table ranking the top 15 states by PM2.5 concentration in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 1568,Tabulate the 20 states with the least PM10 pollution in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 1569,"Create a grouped bar chart comparing the average PM2.5 for Manipur, Manipur, and Manipur across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Manipur', 'Manipur', 'Manipur'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 1570,Show PM2.5 exceedance count and rate (%) above 100 µg/m³ per city in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1571,Generate a city × month cross-tab of mean PM2.5 for Maharashtra in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Aurangabad', 'Chandrapur', 'Kalyan', 'Mumbai', 'Nagpur', 'Nashik', 'Navi Mumbai', 'Pune', 'Solapur']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1572,Show a box plot of PM2.5 distribution for each state in 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2021].dropna(subset=['PM2.5']) df = df[['state','PM2.5']] state_order = df.groupby('state')['PM2.5'].median().sort_values(ascending=False).index.tolist() chart = alt.Chart(df).mark_boxplot(extent='min-max').encode( x=alt.X('PM2\.5:Q', title='PM2.5 (µg/m³)'), y=alt.Y('state:N', sort=state_order, title='State'), color=alt.Color('state:N', legend=None) ).properties(title='PM2.5 Distribution by State – 2021', width=500, height=450) return chart " 1573,Show the monthly average PM10 trend for Coimbatore from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Coimbatore'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Coimbatore (2019–2024)', width=600, height=300) return chart " 1574,"Which state experienced the third-lowest average PM10 concentration on January 5, 2024?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 1575,"Which state experienced the highest average PM10 concentration on January 5, 2020?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 1576,Show a table of the 20 cleanest states by average PM2.5 in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 1577,Tabulate the yearly average PM2.5 trend for Howrah across all years.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Howrah'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1578,Report the station with the highest 25th percentile of PM10 in January 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 1579,Which city noted the minimum 75th percentile of PM10 in the Monsoon season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 1580,Determine the city exhibiting the 3rd lowest average PM2.5 in March 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 1581,Plot the rolling 30-day average PM2.5 for Assam in 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Assam') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Assam 2022', width=600, height=300) " 1582,List the average PM2.5 for Gurugram broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Gurugram'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1583,Report the station that had the highest 75th percentile of PM2.5 in February 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 1584,Show the monthly average PM2.5 for Ooty in 2024 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ooty') & (data['Timestamp'].dt.year == 2024)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Ooty 2024', width=450, height=280) " 1585,Tabulate average PM2.5 for each city in Tamil Nadu across all months of 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Chennai']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1586,Report the station with the lowest 25th percentile of PM10 in November 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 1587,List all states with their average PM2.5 and population for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1588,"Visualize the monthly average PM10 for Meghalaya, Andhra Pradesh, and Mizoram in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Meghalaya', 'Andhra Pradesh', 'Mizoram'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Meghalaya, Andhra Pradesh, UP – 2018', width=550, height=320) return chart " 1589,"Visualize the monthly average PM10 for Manipur, Meghalaya, and Uttar Pradesh in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Manipur', 'Meghalaya', 'Uttar Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Manipur, Meghalaya, UP – 2021', width=550, height=320) return chart " 1590,Show the monthly average PM2.5 for Anantapur in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Anantapur') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Anantapur 2017', width=450, height=280) " 1591,Tabulate average and median PM10 for all states in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1592,Create a month-wise PM10 breakdown table across cities in Kerala for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Thiruvananthapuram']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1593,Generate a monthly average PM2.5 table for Jammu and Kashmir for the year 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Jammu and Kashmir'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1594,Determine the city that showed the 3rd highest 75th percentile of PM10 over the Monsoon season of 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 1595,Plot the monthly average PM2.5 trend for Arunachal Pradesh from 2017 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Arunachal Pradesh'].copy() df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly Average PM2.5 Trend – Arunachal Pradesh (2017–2024)', width=600, height=300) return chart " 1596,"Create a grouped bar chart comparing the average PM2.5 for Tamil Nadu, Bihar, and Punjab across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Bihar', 'Punjab'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 1597,"Plot the yearly average PM2.5 trends for Uttar Pradesh, Rajasthan, and Manipur from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttar Pradesh', 'Rajasthan', 'Manipur'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Uttar Pradesh vs Rajasthan vs Manipur', width=550, height=320) return chart " 1598,"Show the top 10 states by average PM10 in 2023 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2023] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(10, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 10 States by Average PM10 in 2023', width=500, height=300) return chart " 1599,"Compare the monthly average PM2.5 of Rajamahendravaram, Durgapur, and Kaithal in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Rajamahendravaram', 'Durgapur', 'Kaithal'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Rajamahendravaram vs Durgapur vs Kaithal – 2024', width=550, height=320) return chart " 1600,Plot the rolling 30-day average PM2.5 for Punjab in 2018 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Punjab') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Punjab 2018', width=600, height=300) " 1601,"On January 27, 2018, which state showed the third highest PM2.5 level?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 1602,Show a ranked table of the 5 most polluted states by average PM2.5 in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 1603,Generate a city × month cross-tab of mean PM2.5 for Karnataka in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Bengaluru', 'Chikkaballapur', 'Hubballi', 'Kalaburagi']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1604,Plot the weekly average PM2.5 for Haveri in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Haveri') & (data['Timestamp'].dt.year == 2024)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Haveri 2024', width=600, height=300) return chart " 1605,Tabulate daily PM10 exceedances (above 100 µg/m³) per city for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1606,Show annual average PM2.5 for Jammu and Kashmir as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Jammu and Kashmir'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1607,Create a table with mean and standard deviation of PM2.5 by city in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1608,"Visualize the monthly average PM10 for Himachal Pradesh, Odisha, and Mizoram in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Himachal Pradesh', 'Odisha', 'Mizoram'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Himachal Pradesh, Odisha, UP – 2022', width=550, height=320) return chart " 1609,Determine the station exhibiting the 2nd highest average PM10 in February 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 1610,Report the state with the 2nd lowest 75th percentile of PM2.5 in June 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 1611,Determine the city exhibiting the lowest 25th percentile of PM10 in November 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 1612,"Show the top 5 states by average PM10 in 2024 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2024] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(5, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 5 States by Average PM10 in 2024', width=500, height=300) return chart " 1613,Tabulate area-adjusted PM2.5 (per km²) for each state in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, { 'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM2.5 per km²', 'numerator': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)', 'PM2.5 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1614,Create a table of PM10 standard violations (>100 µg/m³) per state in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1615,Show a table of average PM2.5 per state in 2021 along with population.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1616,Which 20 states had the lowest mean PM2.5 in 2023? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 1617,Generate a monthly average PM10 table for Rajasthan for the year 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1618,Show how average PM10 varied month by month for Nagpur in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Nagpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1619,Identify the city that recorded the 2nd highest average PM10 value in November 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 1620,Show a pivot table of monthly average PM10 by city for Punjab in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Amritsar', 'Ludhiana', 'Mandi Gobindgarh']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1621,Show a cumulative area chart of PM2.5 readings for Chandigarh across 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Chandigarh') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Chandigarh 2021', width=600, height=300) return chart " 1622,"Plot the yearly average PM2.5 trends for Chhattisgarh, Sikkim, and Kerala from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chhattisgarh', 'Sikkim', 'Kerala'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Chhattisgarh vs Sikkim vs Kerala', width=550, height=320) return chart " 1623,List how many days each city breached the PM10 limit of 100 µg/m³ in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1624,Show a ranked table of the 5 most polluted states by average PM2.5 in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 1625,"Plot the yearly average PM2.5 trends for Assam, Bihar, and Kerala from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Assam', 'Bihar', 'Kerala'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Assam vs Bihar vs Kerala', width=550, height=320) return chart " 1626,Create a month-by-state breakdown table of mean PM10 for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Delhi', 'Gujarat', 'Haryana', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Meghalaya', 'Odisha', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1627,"Compare the monthly average PM2.5 of Ooty, Chandigarh, and Kozhikode in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Ooty', 'Chandigarh', 'Kozhikode'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Ooty vs Chandigarh vs Kozhikode – 2022', width=550, height=320) return chart " 1628,Tabulate average PM2.5 for each city in Tamil Nadu across all months of 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Ariyalur', 'Chennai', 'Coimbatore', 'Gummidipoondi', 'Hosur', 'Kanchipuram', 'Ooty', 'Ramanathapuram', 'Salem', 'Vellore']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1629,Show the monthly average PM2.5 for Churu in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Churu') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Churu 2020', width=450, height=280) " 1630,Identify the city that saw the most significant fall in median PM10 levels when comparing December 2022 to October 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 1631,"Create a grouped bar chart comparing the average PM2.5 for Sikkim, Jharkhand, and Sikkim across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Sikkim', 'Jharkhand', 'Sikkim'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 1632,Show a pivot table of monthly average PM2.5 by city for Madhya Pradesh in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Bhopal', 'Dewas', 'Gwalior', 'Indore', 'Jabalpur', 'Katni', 'Maihar', 'Mandideep', 'Pithampur', 'Ratlam', 'Sagar', 'Satna', 'Singrauli', 'Ujjain']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1633,Determine the state which was granted the 4th lowest NCAP funding considering the standard deviation of its PM10 concentration in 2020 (FY 2019-20).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'std', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2020_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 1634,Show a monthly bar chart of the number of days Rajasthan exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Rajasthan') & (data['Timestamp'].dt.year == 2021)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Rajasthan Exceeded WHO PM2.5 Guideline per Month – 2021', width=500, height=300) return chart " 1635,Show PM10 density (µg/m³ per km²) by state for 2019 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM10 per km²', 'numerator': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)', 'PM10 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1636,Report the station with the 2nd lowest 75th percentile of PM2.5 in May 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 1637,Which state showed the 2nd lowest 25th percentile of PM10 in February 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 1638,"Plot the yearly average PM2.5 trends for Tamil Nadu, Jammu and Kashmir, and Tamil Nadu from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Jammu and Kashmir', 'Tamil Nadu'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Tamil Nadu vs Jammu and Kashmir vs Tamil Nadu', width=550, height=320) return chart " 1639,Generate a year-by-year summary table of PM10 readings for Mizoram.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Mizoram'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1640,Plot the weekly average PM2.5 for Gadag in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Gadag') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Gadag 2023', width=600, height=300) return chart " 1641,Show the monthly average PM2.5 for Tirupur in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Tirupur') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Tirupur 2017', width=450, height=280) " 1642,What is the median PM2.5 value on Wednesdays in Tripura?," [{'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tripura'}}] " 1643,"Over the past five years in Ahmedabad, on which date was the PM2.5 level the third lowest?"," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 5}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'Timestamp'}}] " 1644,Identify the city that received the 5th highest NCAP funding with respect to its average PM2.5 concentration in 2021 (FY 2020-21).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 1645,Determine the union territory that has the 4th lowest average PM10 concentration relative to its population density.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_capita', 'numerator': 'PM10', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'pm_per_capita', 'ascending': True}}] " 1646,Determine the city exhibiting the 2nd highest 75th percentile of PM10 over the Winter season of 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 1647,Determine the state with the 3rd highest 25th percentile of PM2.5 in June 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 1648,Identify the station that recorded the highest median PM2.5 value in November 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 1649,"Show the top 9 states by average PM10 in 2024 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2024] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(9, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 9 States by Average PM10 in 2024', width=500, height=300) return chart " 1650,Tabulate both PM2.5 and PM10 averages by city for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1651,Show a pivot table of monthly average PM10 by city for Rajasthan in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Ajmer', 'Alwar', 'Bhiwadi', 'Jaipur', 'Jodhpur', 'Kota', 'Pali', 'Udaipur']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1652,"Visualize the monthly average PM10 for Telangana, Assam, and Uttar Pradesh in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Telangana', 'Assam', 'Uttar Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Telangana, Assam, UP – 2023', width=550, height=320) return chart " 1653,"Visualize the monthly average PM10 for Chandigarh, Andhra Pradesh, and Jharkhand in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chandigarh', 'Andhra Pradesh', 'Jharkhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Chandigarh, Andhra Pradesh, UP – 2023', width=550, height=320) return chart " 1654,Generate a city × month cross-tab of mean PM10 for Madhya Pradesh in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Damoh', 'Dewas', 'Mandideep', 'Pithampur', 'Ratlam', 'Satna', 'Singrauli', 'Ujjain']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1655,"For the year 2022, which weekday had the third-highest 25th percentile of PM10 pollution levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'Timestamp'}}] " 1656,"Plot the yearly average PM2.5 trends for Bihar, Gujarat, and Meghalaya from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Bihar', 'Gujarat', 'Meghalaya'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Bihar vs Gujarat vs Meghalaya', width=550, height=320) return chart " 1657,Which city registered the 3rd minimum 25th percentile of PM10 in the Post-Monsoon season of 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 1658,"Visualize the monthly average PM10 for Chandigarh, Telangana, and Bihar in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chandigarh', 'Telangana', 'Bihar'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Chandigarh, Telangana, UP – 2019', width=550, height=320) return chart " 1659,"Visualize the monthly average PM10 for Manipur, Telangana, and Punjab in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Manipur', 'Telangana', 'Punjab'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Manipur, Telangana, UP – 2019', width=550, height=320) return chart " 1660,"Compare the monthly average PM2.5 of Pimpri-Chinchwad, Dhule, and Haldia in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Pimpri-Chinchwad', 'Dhule', 'Haldia'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Pimpri-Chinchwad vs Dhule vs Haldia – 2024', width=550, height=320) return chart " 1661,"Which city showed the second-lowest 25th percentile for PM10 on March 31, 2020?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 1662,Which station exhibited the second smallest decrease in its average PM10 levels between October and December of 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 1663,Show the monthly average PM2.5 for Delhi in 2024 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Delhi') & (data['Timestamp'].dt.year == 2024)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Delhi 2024', width=450, height=280) " 1664,Plot the median PM10 for each state in summer 2024 (April–June) as a sorted bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['Timestamp'].dt.year == 2024) & (data['Timestamp'].dt.month.isin([4,5,6]))] df = df.groupby('state')['PM10'].median().reset_index().dropna() df = df.sort_values('PM10', ascending=False) chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Median PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='yelloworangered'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Median PM10 by State – Summer 2024 (Apr–Jun)', width=500, height=400) return chart " 1665,Generate a city × month cross-tab of mean PM2.5 for Maharashtra in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Aurangabad', 'Chandrapur', 'Nagpur', 'Nashik', 'Thane']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1666,"Create a faceted bar chart showing top 11 states by average PM2.5 per year for 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year.isin([2021,2022,2023,2024])].copy() df['Year'] = df['Timestamp'].dt.year agg = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() top = agg.groupby('Year').apply(lambda x: x.nlargest(11,'PM2.5')).reset_index(drop=True) chart = alt.Chart(top).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Avg PM2.5'), y=alt.Y('state:N', sort='-x'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet(facet='Year:O', columns=2).properties(title='Top 11 States by PM2.5 per Year') return chart " 1667,Tabulate the yearly average PM2.5 trend for Andhra Pradesh across all years.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1668,How many times did Udaipur city go above the Indian guideline for PM10 in 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 60.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 1669,"Plot the yearly average PM2.5 trends for Odisha, Sikkim, and Meghalaya from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Odisha', 'Sikkim', 'Meghalaya'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Odisha vs Sikkim vs Meghalaya', width=550, height=320) return chart " 1670,Create a grouped bar chart comparing the average PM2.5 in Winter vs Summer for the top 7 most polluted states.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top6 = data.groupby('state')['PM2.5'].mean().nlargest(7).index.tolist() df = data[data['state'].isin(top6)].copy() df['Season'] = df['Timestamp'].dt.month.apply( lambda m: 'Winter' if m in [12,1,2] else ('Summer' if m in [3,4,5] else None)) df = df.dropna(subset=['Season']) df = df.groupby(['state','Season'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('state:N', title='State'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('Season:N', title='Season'), xOffset='Season:N', tooltip=['state:N','Season:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Winter vs Summer PM2.5 – Top 7 Polluted States', width=550, height=320) return chart " 1671,"Comparing December 2021 to October 2021, which state showed the most significant drop in median PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 1672,Tabulate the monthly mean PM10 levels for West Bengal during 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'West Bengal'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1673,"In December 2020, which city registered the lowest 25th percentile of PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 1674,"Create a grouped bar chart comparing the average PM2.5 for Nagaland, Arunachal Pradesh, and Delhi across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Nagaland', 'Arunachal Pradesh', 'Delhi'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 1675,"In April 2019, report the city with the 2nd highest 25th percentile of PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 1676,"Plot the yearly average PM2.5 trends for Sikkim, Puducherry, and Jharkhand from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Sikkim', 'Puducherry', 'Jharkhand'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Sikkim vs Puducherry vs Jharkhand', width=550, height=320) return chart " 1677,Which city recorded the 3rd highest 25th percentile of PM10 in August 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 1678,Report which state registered the most minimal 25th percentile of PM2.5 throughout the Post-Monsoon season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 1679,Tabulate average PM10 for each state across all months in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Arunachal Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Chhattisgarh', 'Delhi', 'Gujarat', 'Haryana', 'Jammu and Kashmir', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Meghalaya', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1680,"Across all recorded years, which May experienced the third-lowest average PM2.5 levels?"," [{'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'Timestamp'}}] " 1681,Plot the monthly average PM2.5 trend for Haryana from 2017 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Haryana'].copy() df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly Average PM2.5 Trend – Haryana (2017–2024)', width=600, height=300) return chart " 1682,Tabulate average PM2.5 for each city in Rajasthan across all months of 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Ajmer', 'Alwar', 'Bhiwadi', 'Jaipur', 'Jodhpur', 'Kota', 'Pali', 'Sirohi', 'Udaipur']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1683,"On March 31, 2018, which station had the third-lowest 25th percentile for PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 1684,Tabulate average PM2.5 for each city in Bihar across all months of 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Bihar'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Gaya', 'Hajipur', 'Muzaffarpur', 'Patna']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1685,"For the year 2020, what was the second-highest PM2.5 level noted?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}] " 1686,"Plot the yearly average PM2.5 trends for Andhra Pradesh, Telangana, and Rajasthan from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Telangana', 'Rajasthan'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Andhra Pradesh vs Telangana vs Rajasthan', width=550, height=320) return chart " 1687,List the average PM2.5 for Jammu and Kashmir broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Jammu and Kashmir'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1688,Which state registered the peak median PM10 during the Post-Monsoon season of 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 1689,Show how average PM2.5 varied month by month for Gandhinagar in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Gandhinagar'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1690,What date over the last four years noted Kota's highest PM10 reading?," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 4}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'Timestamp'}}] " 1691,Generate a descriptive stats table for PM2.5 grouped by state in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1692,Plot the top 8 states by average PM2.5 in 2023 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2023] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(8, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 8 States by Average PM2.5 in 2023', width=500, height=300) return chart " 1693,Tabulate the yearly average PM2.5 trend for Haryana across all years.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Haryana'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1694,Create a table of PM2.5 exceedance frequency above 100 µg/m³ by state for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1695,"Compare the monthly average PM2.5 of Hassan, Raipur, and Rohtak in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Hassan', 'Raipur', 'Rohtak'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Hassan vs Raipur vs Rohtak – 2018', width=550, height=320) return chart " 1696,Find the station with the third-highest average PM10 in February 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 1697,Identify the state that registered the third highest 25th percentile for PM10 during the Winter season of 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 1698,"Considering 2018, what season (Winter, Summer, Monsoon, Post-Monsoon) displayed the third-highest 25th percentile for PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'season'}}] " 1699,Show a table of the 20 cleanest states by average PM10 in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 1700,"Visualize the monthly average PM10 for Tripura, Madhya Pradesh, and Haryana in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tripura', 'Madhya Pradesh', 'Haryana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Tripura, Madhya Pradesh, UP – 2017', width=550, height=320) return chart " 1701,Which station recorded the minimum median PM2.5 in the Summer season of 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 1702,Create a table of PM10 standard violations (>100 µg/m³) per state in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1703,"Visualize the monthly average PM10 for Puducherry, Delhi, and Jharkhand in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'Delhi', 'Jharkhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Puducherry, Delhi, UP – 2017', width=550, height=320) return chart " 1704,Create a heatmap showing the average PM2.5 by month (x-axis) and year (y-axis) for Sikkim.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Sikkim'].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Year:N', title='Year'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='Avg PM2.5'), tooltip=['Year:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Sikkim (Month × Year)', width=500, height=280) return chart " 1705,"Tabulate the distribution of PM10 per state in 2024 including mean, median, and std."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1706,Determine the station exhibiting the lowest 25th percentile of PM10 in May 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 1707,Which state recorded the 2nd highest 75th percentile of PM10 in June 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 1708,Determine which city was granted the 4th lowest NCAP funding considering its average PM10 concentration in 2021 (FY 2020-21).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 1709,Name the station with the absolute lowest average PM10 in August 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 1710,"Compare the monthly average PM2.5 of Ajmer, Kolar, and Barrackpore in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Ajmer', 'Kolar', 'Barrackpore'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Ajmer vs Kolar vs Barrackpore – 2017', width=550, height=320) return chart " 1711,Show a bar chart of the top 11 cities by median PM2.5 in 2019.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2019] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(11, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 11 Cities by Median PM2.5 in 2019', width=500, height=300) return chart " 1712,"Plot the yearly average PM2.5 trends for Nagaland, Jharkhand, and Tamil Nadu from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Nagaland', 'Jharkhand', 'Tamil Nadu'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Nagaland vs Jharkhand vs Tamil Nadu', width=550, height=320) return chart " 1713,Show a monthly bar chart of the number of days Jharkhand exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2020.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Jharkhand') & (data['Timestamp'].dt.year == 2020)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Jharkhand Exceeded WHO PM2.5 Guideline per Month – 2020', width=500, height=300) return chart " 1714,List states ranked by PM10 concentration relative to their area in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM10 per km²', 'numerator': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)', 'PM10 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1715,"Report which state, from those with populations above the 75th percentile, secures the 3rd lowest per capita NCAP funding."," [{'op': 'COMPUTE', 'params': {'new_col': 'funding_per_capita', 'numerator': 'total_fund', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'funding_per_capita', 'ascending': True}}] " 1716,"In December 2023, which state registered the highest average PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 1717,Show the monthly average PM2.5 for Pathardih in 2024 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Pathardih') & (data['Timestamp'].dt.year == 2024)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Pathardih 2024', width=450, height=280) " 1718,"Scatter plot PM2.5 vs PM10 for Madhya Pradesh stations in 2023, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Madhya Pradesh') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Madhya Pradesh Stations 2023', width=450, height=350) " 1719,"Compare the monthly average PM2.5 of Faridabad, Nashik, and Vapi in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Faridabad', 'Nashik', 'Vapi'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Faridabad vs Nashik vs Vapi – 2017', width=550, height=320) return chart " 1720,Show a heatmap of average PM2.5 for the top 14 most polluted states by month for 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(14).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 14 Polluted States by Month (2021)', width=500, height=300) return chart " 1721,"Comparing December 2018 to October 2018, which state showed the third least significant drop in median PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 1722,Tabulate the 10 worst citys for average PM2.5 in 2020 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 1723,"Create a grouped bar chart comparing the average PM2.5 for Arunachal Pradesh, Jharkhand, and Himachal Pradesh across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Arunachal Pradesh', 'Jharkhand', 'Himachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 1724,"Determine which state (excluding UTs) has the smallest population within the top 5 most polluted states, based on median PM2.5 levels."," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 5, 'ret': 'state'}}] " 1725,Identify the state with the 2nd highest 25th percentile of PM2.5 for April 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 1726,Show a table of the 20 cleanest states by average PM10 in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 1727,"Show descriptive statistics of PM10 (mean, median, std, min, max) per state in 2021."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'q25', 'median', 'q75']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1728,Plot the weekly average PM2.5 for Malegaon in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Malegaon') & (data['Timestamp'].dt.year == 2024)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Malegaon 2024', width=600, height=300) return chart " 1729,Show a cumulative area chart of PM2.5 readings for Bareilly across 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bareilly') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Bareilly 2024', width=600, height=300) return chart " 1730,"Create a grouped bar chart comparing the average PM2.5 for Chandigarh, Madhya Pradesh, and Delhi across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chandigarh', 'Madhya Pradesh', 'Delhi'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 1731,Show a pivot table of monthly average PM2.5 by city for Uttar Pradesh in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Agra', 'Bulandshahr', 'Ghaziabad', 'Greater Noida', 'Hapur', 'Kanpur', 'Lucknow', 'Meerut', 'Moradabad', 'Muzaffarnagar', 'Noida', 'Varanasi']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1732,"Report which state documented the second highest PM2.5 level on January 27, 2023."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 1733,How many times did Bangalore city go above 45 µg/m³ of PM10 in 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 45.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 1734,Create a summary table ranking the top 5 citys by PM10 concentration in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 1735,Visualize the bottom 12 states with the lowest average PM2.5 in 2023 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2023] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(12, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 12 States by Average PM2.5 in 2023', width=500, height=300) return chart " 1736,"In December 2023, report the state with the lowest 75th percentile of PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 1737,"Identify the city with the second-highest median PM10 on March 31, 2021."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 1738,How many times did Chandigarh surpass 45 µg/m³ of PM2.5 in 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 45.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 1739,Create a table with mean and standard deviation of PM2.5 by state in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1740,Identify the station that recorded the second highest median PM2.5 during the Post-Monsoon season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 1741,"Which state having a land area exceeding 50,000 km² registers the 3rd maximum PM10 level, based on its total PM10 level?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'sum', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}] " 1742,Which station recorded the 2nd lowest 75th percentile of PM2.5 in June 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 1743,"In October 2019, which station registered the lowest median PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 1744,"Show descriptive statistics of PM2.5 (mean, median, std, min, max) per state in 2017."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1745,Tabulate the yearly average PM2.5 trend for Maharashtra across all years.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1746,Generate a table showing the 5 most polluted states based on mean PM2.5 for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 1747,Identify the city that registered the lowest 75th percentile for PM10 during the Post-Monsoon season of 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 1748,"Which city showed the third-lowest 75th percentile for PM10 on March 31, 2020?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 1749,Generate a monthly average PM2.5 table for Aurangabad for the year 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Aurangabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1750,Determine the state exhibiting the 3rd highest 75th percentile of PM2.5 in May 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 1751,Show PM2.5 exceedances above the Indian standard (60 µg/m³) per year as a bar chart for Uttarakhand.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Uttarakhand'].dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 60].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby('Year')['Timestamp'].nunique().reset_index() df.columns = ['Year','Days Exceeded'] chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('Year:N', title='Year'), y=alt.Y('Days Exceeded:Q', title='Days PM2.5 > 60 µg/m³'), tooltip=['Year:N','Days Exceeded:Q'] ).properties(title='Days Uttarakhand Exceeded Indian PM2.5 Standard (60 µg/m³) per Year', width=450, height=300) return chart " 1752,"Create a grouped bar chart comparing the average PM2.5 for Chandigarh, Punjab, and Karnataka across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chandigarh', 'Punjab', 'Karnataka'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 1753,Which station registered the 3rd highest 75th percentile of PM2.5 during November 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 1754,Show a table of average PM2.5 and PM10 for all states in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1755,Generate a monthly average PM10 table for Noida for the year 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Noida'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1756,"Create a faceted bar chart showing top 11 states by average PM2.5 per year for 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year.isin([2019,2020,2021,2022])].copy() df['Year'] = df['Timestamp'].dt.year agg = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() top = agg.groupby('Year').apply(lambda x: x.nlargest(11,'PM2.5')).reset_index(drop=True) chart = alt.Chart(top).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Avg PM2.5'), y=alt.Y('state:N', sort='-x'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet(facet='Year:O', columns=2).properties(title='Top 11 States by PM2.5 per Year') return chart " 1757,Create a table showing PM2.5 levels and population for each state in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1758,Create a summary table ranking the top 10 citys by PM10 concentration in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 1759,Show a heatmap of average PM2.5 for the top 11 most polluted states by month for 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(11).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 11 Polluted States by Month (2024)', width=500, height=300) return chart " 1760,Which city showed the second highest median PM2.5 level historically?," [{'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 1761,"Compare the monthly average PM2.5 of Boisar, Parbhani, and Amaravati in 2020 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Boisar', 'Parbhani', 'Amaravati'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2020)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Boisar vs Parbhani vs Amaravati – 2020', width=550, height=320) return chart " 1762,"Compare the monthly average PM2.5 of Munger, Palkalaiperur, and Pudukottai in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Munger', 'Palkalaiperur', 'Pudukottai'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Munger vs Palkalaiperur vs Pudukottai – 2023', width=550, height=320) return chart " 1763,Which city recorded the peak 75th percentile of PM10 during the Monsoon season of 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 1764,Which 10 states had the lowest mean PM10 in 2023? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 1765,"Tabulate the distribution of PM10 per city in 2019 including mean, median, and std."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1766,Generate a monthly average PM10 table for Chandigarh for the year 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Chandigarh'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1767,Show a table of the 20 cleanest states by average PM10 in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 1768,Determine the state with the 3rd lowest 75th percentile of PM10 in June 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 1769,Generate a table showing the 20 most polluted citys based on mean PM10 for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 1770,Plot the rolling 30-day average PM2.5 for Bihar in 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Bihar') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Bihar 2022', width=600, height=300) " 1771,"Scatter plot PM2.5 vs PM10 for Odisha stations in 2023, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Odisha') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Odisha Stations 2023', width=450, height=350) " 1772,"Create a grouped bar chart comparing the average PM2.5 for Puducherry, Mizoram, and West Bengal across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'Mizoram', 'West Bengal'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 1773,"Visualize the monthly average PM10 for Tamil Nadu, Jammu and Kashmir, and Rajasthan in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Jammu and Kashmir', 'Rajasthan'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Tamil Nadu, Jammu and Kashmir, UP – 2022', width=550, height=320) return chart " 1774,"Create a grouped bar chart comparing the average PM2.5 for Sikkim, Delhi, and Tamil Nadu across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Sikkim', 'Delhi', 'Tamil Nadu'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 1775,"Scatter plot PM2.5 vs PM10 for Uttar Pradesh stations in 2021, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Uttar Pradesh') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Uttar Pradesh Stations 2021', width=450, height=350) " 1776,Create a table of PM2.5 exceedance frequency above 60 µg/m³ by state for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1777,"In January 2022, which state registered the 3rd highest average PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 1778,Tabulate the 20 worst states for average PM2.5 in 2018 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 1779,Show how average PM10 varied month by month for Madhya Pradesh in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1780,Show average PM10 per state in 2023 with area in km².," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1781,"Plot the yearly average PM2.5 trends for Arunachal Pradesh, Sikkim, and Kerala from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Arunachal Pradesh', 'Sikkim', 'Kerala'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Arunachal Pradesh vs Sikkim vs Kerala', width=550, height=320) return chart " 1782,Show PM2.5 exceedances above the Indian standard (60 µg/m³) per year as a bar chart for Arunachal Pradesh.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Arunachal Pradesh'].dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 60].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby('Year')['Timestamp'].nunique().reset_index() df.columns = ['Year','Days Exceeded'] chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('Year:N', title='Year'), y=alt.Y('Days Exceeded:Q', title='Days PM2.5 > 60 µg/m³'), tooltip=['Year:N','Days Exceeded:Q'] ).properties(title='Days Arunachal Pradesh Exceeded Indian PM2.5 Standard (60 µg/m³) per Year', width=450, height=300) return chart " 1783,Show PM2.5 exceedance count and rate (%) above 60 µg/m³ per state in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1784,Which state registered the 2nd highest average PM2.5 during March 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 1785,Identify the station that showed the second highest 25th percentile of PM10 during the Summer season of 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 1786,Identify the city that registered the third lowest 75th percentile for PM2.5 during the Summer season of 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 1787,How many times did Eloor city surpass the WHO guideline for PM2.5 in 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 15.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 1788,Tabulate the monthly mean PM2.5 levels for Punjab during 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1789,"On any New Year's Eve in the records, which city experienced the third-highest PM2.5 concentrations?"," [{'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 1790,Identify the city with the lowest 25th percentile of PM2.5 for January 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 1791,Plot the monthly average PM2.5 trend for Uttarakhand from 2017 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Uttarakhand'].copy() df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly Average PM2.5 Trend – Uttarakhand (2017–2024)', width=600, height=300) return chart " 1792,"Compare the monthly average PM2.5 of Varanasi, Charkhi Dadri, and Palwal in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Varanasi', 'Charkhi Dadri', 'Palwal'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Varanasi vs Charkhi Dadri vs Palwal – 2022', width=550, height=320) return chart " 1793,Which city experienced the third least significant drop in its 25th percentile PM10 levels between October and December 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 1794,Generate a city × month cross-tab of mean PM2.5 for Maharashtra in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Chandrapur']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1795,Plot the weekly average PM2.5 for Mumbai in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Mumbai') & (data['Timestamp'].dt.year == 2024)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Mumbai 2024', width=600, height=300) return chart " 1796,Show a pivot table of monthly average PM10 by city for Uttar Pradesh in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Agra', 'Baghpat', 'Bareilly', 'Bulandshahr', 'Firozabad', 'Ghaziabad', 'Gorakhpur', 'Greater Noida', 'Hapur', 'Jhansi', 'Kanpur', 'Khurja', 'Lucknow', 'Meerut', 'Moradabad', 'Muzaffarnagar', 'Prayagraj', 'Varanasi', 'Vrindavan']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1797,Create a month-wise PM2.5 breakdown table across cities in Punjab for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Amritsar', 'Bathinda', 'Jalandhar', 'Khanna', 'Ludhiana', 'Mandi Gobindgarh', 'Patiala', 'Rupnagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1798,Which 5 states recorded the highest average PM2.5 levels in 2018? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 1799,"Compare the monthly average PM2.5 of Siwan, Jodhpur, and Karauli in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Siwan', 'Jodhpur', 'Karauli'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Siwan vs Jodhpur vs Karauli – 2024', width=550, height=320) return chart " 1800,List citys with their PM10 violation count and rate (>150 µg/m³) in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 150'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1801,Create a table of PM2.5 standard violations (>100 µg/m³) per city in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1802,Plot the rolling 30-day average PM2.5 for Himachal Pradesh in 2018 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Himachal Pradesh') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Himachal Pradesh 2018', width=600, height=300) " 1803,Which station registered the 2nd highest median PM2.5 during September 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 1804,"Which state (excluding Union Territories) possesses the 2nd largest land area among the top 10 most polluted states, based on total PM10 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'sum', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 10, 'ret': 'state'}}] " 1805,"Compare the monthly average PM2.5 of Ooty, Khanna, and Kunjemura in 2020 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Ooty', 'Khanna', 'Kunjemura'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2020)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Ooty vs Khanna vs Kunjemura – 2020', width=550, height=320) return chart " 1806,Plot the rolling 30-day average PM2.5 for Odisha in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Odisha') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Odisha 2023', width=600, height=300) " 1807,Create a month-wise PM2.5 breakdown table across cities in Uttar Pradesh for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Agra', 'Baghpat', 'Bulandshahr', 'Ghaziabad', 'Greater Noida', 'Hapur', 'Kanpur', 'Lucknow', 'Meerut', 'Moradabad', 'Muzaffarnagar', 'Noida', 'Varanasi']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1808,Create a statistical summary table of PM10 readings by city for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1809,Visualize NCAP city-level funding for FY 2021-22 as a horizontal bar chart for the top 7 cities.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = ncap_funding_data[['city','state','Amount released during FY 2021-22']].copy() df.columns = ['city','state','Amount (Cr)'] df = df.nlargest(7, 'Amount (Cr)') df['City_State'] = df['city'] + ', ' + df['state'] chart = alt.Chart(df).mark_bar().encode( x=alt.X('Amount (Cr):Q', title='Amount Released (Cr)'), y=alt.Y('City_State:N', sort='-x', title='City, State'), color=alt.Color('state:N', title='State'), tooltip=['city:N','state:N', alt.Tooltip('Amount (Cr):Q', format='.1f')] ).properties(title='Top 7 Cities by NCAP Funding – FY 2021-22', width=500, height=400) return chart " 1810,Show how average PM10 varied month by month for Kolkata in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Kolkata'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1811,Create a summary table comparing mean PM2.5 and PM10 across citys in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1812,Plot the rolling 30-day average PM2.5 for Delhi in 2019 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Delhi') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Delhi 2019', width=600, height=300) " 1813,"Create a grouped bar chart comparing the average PM2.5 for Rajasthan, Nagaland, and Mizoram across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Nagaland', 'Mizoram'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 1814,Show the monthly average PM10 trend for Pune from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Pune'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Pune (2017–2022)', width=600, height=300) return chart " 1815,"Scatter plot PM2.5 vs PM10 for Meghalaya stations in 2021, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Meghalaya') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Meghalaya Stations 2021', width=450, height=350) " 1816,Tabulate the monthly mean PM10 levels for Chandigarh during 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Chandigarh'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1817,Report the station with the 3rd highest 75th percentile of PM10 in February 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 1818,Which city recorded the lowest median for PM2.5 in the Winter season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 1819,"Which state showed the second-highest 75th percentile for PM10 on March 31, 2023?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 1820,Which 5 states recorded the highest average PM2.5 levels in 2023? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 1821,"Considering 2020, what season (Winter, Summer, Monsoon, Post-Monsoon) had the second-lowest average PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'season'}}] " 1822,What count of Andhra Pradesh stations went above the Indian guideline for PM10 in 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 60.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 1823,Create a table of PM10 exceedance frequency above 100 µg/m³ by city for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1824,"Create a table showing top 20 states ranked by PM2.5 in 2024, also showing PM10."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 1825,Create a table with mean and standard deviation of PM2.5 by state in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1826,Show annual average PM2.5 for Agra as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Agra'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1827,"Compare the monthly average PM2.5 of Pithampur, Milupara, and Barrackpore in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Pithampur', 'Milupara', 'Barrackpore'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Pithampur vs Milupara vs Barrackpore – 2022', width=550, height=320) return chart " 1828,Show a cumulative area chart of PM2.5 readings for Panchkula across 2017.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Panchkula') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Panchkula 2017', width=600, height=300) return chart " 1829,"On January 5, 2020, which state had the second-lowest average PM10 reading?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 1830,Report the city with the 3rd lowest median PM10 in November 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 1831,Plot the weekly average PM2.5 for Dewas in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Dewas') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Dewas 2023', width=600, height=300) return chart " 1832,Find the city that was second in terms of highest average PM2.5 for May 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 1833,List how many days each state breached the PM2.5 limit of 60 µg/m³ in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1834,Show how average PM2.5 varied month by month for Gujarat in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Gujarat'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1835,Show a bar chart of the top 6 cities by median PM2.5 in 2017.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2017] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(6, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 6 Cities by Median PM2.5 in 2017', width=500, height=300) return chart " 1836,Plot the weekly average PM2.5 for Kolkata in 2019 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Kolkata') & (data['Timestamp'].dt.year == 2019)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Kolkata 2019', width=600, height=300) return chart " 1837,Create a table showing PM10 spread (min to max) and central tendency per state for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1838,Tabulate the 15 worst states for average PM2.5 in 2017 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 1839,"In April 2019, report the station with the 3rd highest 75th percentile of PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 1840,"Scatter plot PM2.5 vs PM10 for Maharashtra stations in 2018, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Maharashtra') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Maharashtra Stations 2018', width=450, height=350) " 1841,Show the monthly average PM2.5 for Gangtok in 2024 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Gangtok') & (data['Timestamp'].dt.year == 2024)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Gangtok 2024', width=450, height=280) " 1842,Create a statistical summary table of PM2.5 readings by city for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1843,List the average PM10 for Mumbai broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Mumbai'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1844,"Visualize the monthly average PM10 for Jharkhand, Haryana, and Arunachal Pradesh in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Haryana', 'Arunachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Jharkhand, Haryana, UP – 2024', width=550, height=320) return chart " 1845,Show the monthly average PM10 trend for Latur from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Latur'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Latur (2019–2024)', width=600, height=300) return chart " 1846,Tabulate average PM2.5 for each city in Karnataka across all months of 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Bengaluru', 'Chikkaballapur', 'Hubballi', 'Kalaburagi']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1847,Create a month-wise PM2.5 breakdown table across cities in West Bengal for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'West Bengal'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Asansol', 'Durgapur', 'Howrah', 'Kolkata', 'Siliguri']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1848,"Which union territory shows the 2nd minimum PM10 concentration per square kilometer, using total PM10 values?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'sum', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_km2', 'numerator': 'PM10', 'denominator': 'area (km2)'}}, {'op': 'SORT', 'params': {'col': 'pm_per_km2', 'ascending': True}}] " 1849,"Compare the monthly average PM2.5 of Perundurai, Pune, and Jhalawar in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Perundurai', 'Pune', 'Jhalawar'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Perundurai vs Pune vs Jhalawar – 2023', width=550, height=320) return chart " 1850,Find the state with the third-lowest average PM2.5 reading for June 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 1851,Visualize the bottom 8 states with the lowest average PM2.5 in 2024 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2024] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(8, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 8 States by Average PM2.5 in 2024', width=500, height=300) return chart " 1852,Identify the state with the 2nd highest median PM2.5 for August 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 1853,"Compare the monthly average PM2.5 of Korba, Thoothukudi, and Muzaffarnagar in 2020 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Korba', 'Thoothukudi', 'Muzaffarnagar'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2020)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Korba vs Thoothukudi vs Muzaffarnagar – 2020', width=550, height=320) return chart " 1854,Show average PM2.5 per capita by state in 2022 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM2.5 per million', 'numerator': 'PM2.5', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'PM2.5 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1855,Report the state with the 5th highest NCAP funding considering the standard deviation of its PM10 concentration in 2021 (FY 2020-21).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'std', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 1856,Report the city that had the 3rd lowest 75th percentile of PM10 in April 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 1857,Identify the state with the highest average PM10 for October 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 1858,"Visualize the monthly average PM10 for Tamil Nadu, Andhra Pradesh, and Rajasthan in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Andhra Pradesh', 'Rajasthan'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Tamil Nadu, Andhra Pradesh, UP – 2021', width=550, height=320) return chart " 1859,Which state had the lowest 25th percentile of PM10 in May 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 1860,"Identify the state with the third-lowest median PM2.5 on March 31, 2018."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 1861,Visualize the bottom 9 states with the lowest average PM2.5 in 2017 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2017] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(9, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 9 States by Average PM2.5 in 2017', width=500, height=300) return chart " 1862,"Create a grouped bar chart comparing the average PM2.5 for Gujarat, Kerala, and Sikkim across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Gujarat', 'Kerala', 'Sikkim'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 1863,Tabulate the yearly average PM2.5 trend for Ahmedabad across all years.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Ahmedabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1864,Which station had the lowest 25th percentile of PM2.5 in November 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 1865,Plot the rolling 30-day average PM2.5 for Uttarakhand in 2019 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Uttarakhand') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Uttarakhand 2019', width=600, height=300) " 1866,Show a bar chart of the top 11 cities by median PM2.5 in 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2023] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(11, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 11 Cities by Median PM2.5 in 2023', width=500, height=300) return chart " 1867,"In March 2018, which station exhibited the 2nd lowest 25th percentile of PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 1868,Tabulate the yearly average PM10 trend for Tripura across all years.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tripura'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1869,Create a month-wise summary of average PM2.5 for Karnataka in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1870,"Plot the yearly average PM2.5 trends for Nagaland, Himachal Pradesh, and Delhi from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Nagaland', 'Himachal Pradesh', 'Delhi'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Nagaland vs Himachal Pradesh vs Delhi', width=550, height=320) return chart " 1871,Create a month-wise PM10 breakdown table across cities in Haryana for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Haryana'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Ambala', 'Bahadurgarh', 'Ballabgarh', 'Bhiwani', 'Charkhi Dadri', 'Dharuhera', 'Faridabad', 'Fatehabad', 'Gurugram', 'Hisar', 'Jind', 'Kaithal', 'Karnal', 'Kurukshetra', 'Mandikhera', 'Manesar', 'Narnaul', 'Palwal', 'Panipat', 'Sirsa', 'Sonipat', 'Yamuna Nagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1872,"Show the top 9 states by average PM10 in 2020 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2020] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(9, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 9 States by Average PM10 in 2020', width=500, height=300) return chart " 1873,"In March 2020, which state exhibited the 2nd highest 25th percentile of PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 1874,Identify the city with the second-lowest 75th percentile for PM10 in December 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 1875,Plot the weekly average PM2.5 for Gwalior in 2021 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Gwalior') & (data['Timestamp'].dt.year == 2021)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Gwalior 2021', width=600, height=300) return chart " 1876,Determine the city that recorded the 2nd most minimal 25th percentile of PM10 over the Monsoon season of 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 1877,"Taking all years into account, which June experienced the lowest 75th percentile for PM10 levels?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'Timestamp'}}] " 1878,Report the station that had the 2nd highest 75th percentile of PM2.5 in May 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 1879,"Visualize the monthly average PM10 for Chhattisgarh, Haryana, and Rajasthan in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chhattisgarh', 'Haryana', 'Rajasthan'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Chhattisgarh, Haryana, UP – 2018', width=550, height=320) return chart " 1880,"Plot the yearly average PM2.5 trends for Meghalaya, Jharkhand, and Tripura from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Meghalaya', 'Jharkhand', 'Tripura'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Meghalaya vs Jharkhand vs Tripura', width=550, height=320) return chart " 1881,List how many days each city breached the PM10 limit of 100 µg/m³ in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1882,Identify the state that registered the third lowest median PM10 during the Summer season of 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 1883,"In January 2024, identify the state with the lowest 25th percentile of PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 1884,Show PM2.5 exceedances above the Indian standard (60 µg/m³) per year as a bar chart for Meghalaya.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Meghalaya'].dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 60].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby('Year')['Timestamp'].nunique().reset_index() df.columns = ['Year','Days Exceeded'] chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('Year:N', title='Year'), y=alt.Y('Days Exceeded:Q', title='Days PM2.5 > 60 µg/m³'), tooltip=['Year:N','Days Exceeded:Q'] ).properties(title='Days Meghalaya Exceeded Indian PM2.5 Standard (60 µg/m³) per Year', width=450, height=300) return chart " 1885,"In September 2018, identify the state with the highest 75th percentile of PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 1886,List the bottom 10 states with the lowest average PM10 in 2021 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 1887,"Plot the yearly average PM2.5 trends for Andhra Pradesh, Uttarakhand, and Himachal Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Uttarakhand', 'Himachal Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Andhra Pradesh vs Uttarakhand vs Himachal Pradesh', width=550, height=320) return chart " 1888,Identify the city with the lowest 25th percentile of PM2.5 in January 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 1889,"Which state (excluding Union Territories) has the 3rd highest land area among the top 3 most polluted states, according to median PM10 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 3, 'ret': 'state'}}] " 1890,Create a summary table comparing mean PM2.5 and PM10 across states in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1891,Show a table of the 10 cleanest states by average PM2.5 in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 1892,Report the state with the 5th highest NCAP funding considering its 25th percentile of PM2.5 concentration in 2021 (FY 2020-21).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 1893,"In 2019, which season (Winter, Summer, Monsoon, Post-Monsoon) experienced the second-highest 25th percentile of PM10 concentrations?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'season'}}] " 1894,Which state registered the 2nd lowest average PM2.5 during November 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 1895,"Create a grouped bar chart comparing the average PM2.5 for Madhya Pradesh, Himachal Pradesh, and Tripura across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Madhya Pradesh', 'Himachal Pradesh', 'Tripura'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 1896,Which state received the 4th lowest NCAP funding relative to its median PM10 concentration in 2021 (FY 2020-21)?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 1897,Show annual average PM10 for Chennai as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Chennai'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1898,Show annual average PM2.5 for Uttar Pradesh as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1899,"For 2019, which weekday experienced the highest 25th percentile of PM2.5 pollution levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'Timestamp'}}] " 1900,"Create a grouped bar chart comparing the average PM2.5 for Sikkim, Rajasthan, and Madhya Pradesh across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Sikkim', 'Rajasthan', 'Madhya Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 1901,"Visualize the monthly average PM10 for Chandigarh, Odisha, and Madhya Pradesh in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chandigarh', 'Odisha', 'Madhya Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Chandigarh, Odisha, UP – 2024', width=550, height=320) return chart " 1902,Report the city that was granted the 4th highest NCAP funding with respect to its total PM10 concentration in 2022 (FY 2021-22).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'sum', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2022_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 1903,Show the monthly average PM10 trend for Bareilly from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Bareilly'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Bareilly (2019–2024)', width=600, height=300) return chart " 1904,Create a summary table ranking the top 5 citys by PM10 concentration in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 1905,Tabulate the 10 states with the least PM2.5 pollution in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 1906,Report the state that had the 3rd lowest 25th percentile of PM10 in February 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 1907,"Create a grouped bar chart comparing the average PM2.5 for Tripura, Haryana, and Tripura across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tripura', 'Haryana', 'Tripura'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 1908,Tabulate the monthly mean PM10 levels for Agra during 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Agra'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1909,Create a month-wise summary of average PM10 for Howrah in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Howrah'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1910,Generate a descriptive stats table for PM2.5 grouped by state in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'q25', 'median', 'q75']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1911,Create a statistical summary table of PM2.5 readings by state for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1912,"In Narnaul, which date in the previous two years showed the highest PM10 concentration?"," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 2}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'Timestamp'}}] " 1913,Create a table showing annual mean PM10 levels for Bihar (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Bihar'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1914,Which city had the 3rd highest 25th percentile of PM10 in November 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 1915,Create a summary table ranking the top 20 states by PM10 concentration in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 1916,Create a table showing PM10 spread (min to max) and central tendency per state for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1917,Show the monthly average PM10 trend for Koppal from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Koppal'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Koppal (2017–2022)', width=600, height=300) return chart " 1918,Tabulate the yearly average PM2.5 trend for Kerala across all years.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1919,Report the station with the 3rd highest average PM2.5 in April 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 1920,"Plot the yearly average PM2.5 trends for Himachal Pradesh, Tripura, and Punjab from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Himachal Pradesh', 'Tripura', 'Punjab'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Himachal Pradesh vs Tripura vs Punjab', width=550, height=320) return chart " 1921,Create a table showing annual mean PM2.5 levels for Kolkata (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Kolkata'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1922,Identify the city that recorded the 3rd lowest average PM10 value in March 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 1923,Identify the state that recorded the 2nd lowest median PM2.5 value in August 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 1924,Show the monthly average PM10 trend for Gaya from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Gaya'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Gaya (2017–2022)', width=600, height=300) return chart " 1925,"Which state (excluding Union Territories) presents the 2nd minimum PM2.5 concentration per square kilometer, according to 75th percentile PM2.5 values?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_km2', 'numerator': 'PM2.5', 'denominator': 'area (km2)'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'pm_per_km2', 'ascending': True}}] " 1926,Show the monthly average PM2.5 for Jhalawar in 2023 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Jhalawar') & (data['Timestamp'].dt.year == 2023)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Jhalawar 2023', width=450, height=280) " 1927,Show PM10 exceedance count and rate (%) above 150 µg/m³ per city in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 150'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1928,"Which union territory has the 2nd maximum PM10 concentration per square kilometer, based on median PM10 values?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_km2', 'numerator': 'PM10', 'denominator': 'area (km2)'}}, {'op': 'SORT', 'params': {'col': 'pm_per_km2', 'ascending': False}}] " 1929,Determine the station that recorded the 3rd lowest median PM10 over the Winter season of 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 1930,Show PM2.5 exceedances above the Indian standard (60 µg/m³) per year as a bar chart for Rajasthan.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Rajasthan'].dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 60].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby('Year')['Timestamp'].nunique().reset_index() df.columns = ['Year','Days Exceeded'] chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('Year:N', title='Year'), y=alt.Y('Days Exceeded:Q', title='Days PM2.5 > 60 µg/m³'), tooltip=['Year:N','Days Exceeded:Q'] ).properties(title='Days Rajasthan Exceeded Indian PM2.5 Standard (60 µg/m³) per Year', width=450, height=300) return chart " 1931,Create a month-by-state breakdown table of mean PM10 for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Arunachal Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Chhattisgarh', 'Delhi', 'Gujarat', 'Haryana', 'Jammu and Kashmir', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Meghalaya', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1932,Which station had the 3rd highest median PM10 in July 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 1933,Report which city registered the maximum PM2.5 level on 27 January 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 1934,"Plot the yearly average PM2.5 trends for Puducherry, Jammu and Kashmir, and Bihar from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'Jammu and Kashmir', 'Bihar'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Puducherry vs Jammu and Kashmir vs Bihar', width=550, height=320) return chart " 1935,Bar chart of PM2.5 per capita (average PM2.5 × 1000 / population) for each state in 2017.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): pm = data[data['Timestamp'].dt.year == 2017].groupby('state')['PM2.5'].mean().reset_index().dropna() df = pm.merge(states_data[['state','population']], on='state') df['PM2.5 per Capita (×1000)'] = df['PM2.5'] / df['population'] * 1e6 df = df.sort_values('PM2.5 per Capita (×1000)', ascending=False) chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5 per Capita (×1000):Q', title='PM2.5 per Million Population'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5 per Capita (×1000):Q', scale=alt.Scale(scheme='purples'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5 per Capita (×1000):Q', format='.4f')] ).properties(title='PM2.5 Per-Capita Pollution Index by State – 2017', width=500, height=400) return chart " 1936,Plot the rolling 30-day average PM2.5 for Delhi in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Delhi') & (data['Timestamp'].dt.year == 2020)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Delhi 2020', width=600, height=300) " 1937,Tabulate the 15 states with the least PM10 pollution in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 1938,"In September 2020, identify the state with the lowest 75th percentile of PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 1939,Which state had the highest 25th percentile of PM2.5 in February 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 1940,Show the monthly average PM10 trend for Jalgaon from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Jalgaon'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Jalgaon (2019–2024)', width=600, height=300) return chart " 1941,Show the monthly average PM2.5 for Aurangabad in 2022 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Aurangabad') & (data['Timestamp'].dt.year == 2022)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Aurangabad 2022', width=450, height=280) " 1942,"Scatter plot PM2.5 vs PM10 for Mizoram stations in 2017, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Mizoram') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Mizoram Stations 2017', width=450, height=350) " 1943,Show the monthly average PM2.5 for West Bengal across each year from 2017 to 2024 as small multiples (faceted by year).," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'West Bengal'].copy() df['Year'] = df['Timestamp'].dt.year df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5'), tooltip=['Year:O','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet( facet=alt.Facet('Year:O', title='Year'), columns=4 ).properties(title='Monthly PM2.5 in West Bengal by Year (2017–2024)') return chart " 1944,"Scatter plot PM2.5 vs PM10 for Maharashtra stations in 2019, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Maharashtra') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Maharashtra Stations 2019', width=450, height=350) " 1945,Show a monthly bar chart of the number of days Jammu and Kashmir exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Jammu and Kashmir') & (data['Timestamp'].dt.year == 2023)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Jammu and Kashmir Exceeded WHO PM2.5 Guideline per Month – 2023', width=500, height=300) return chart " 1946,Show a monthly breakdown table of average PM2.5 for Solapur in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Solapur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1947,"Create a grouped bar chart comparing the average PM2.5 for Puducherry, West Bengal, and Chandigarh across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'West Bengal', 'Chandigarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 1948,Show a pivot table of monthly average PM10 by city for Assam in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Assam'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Byrnihat', 'Guwahati', 'Nagaon', 'Nalbari', 'Silchar', 'Sivasagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1949,List states ranked by PM2.5 concentration relative to their area in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, { 'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM2.5 per km²', 'numerator': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)', 'PM2.5 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1950,"In June 2019, identify the station with the 2nd highest median PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 1951,"Plot average PM2.5 (2018) vs state population as a scatter plot, labeling each point with the state name."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): pm = data[data['Timestamp'].dt.year == 2018].groupby('state')['PM2.5'].mean().reset_index().dropna() df = pm.merge(states_data, on='state') points = alt.Chart(df).mark_point(filled=True, size=80).encode( x=alt.X('population:Q', title='Population', axis=alt.Axis(format='~s')), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('population:Q', format=',')] ) labels = alt.Chart(df).mark_text(align='left', dx=5, fontSize=9).encode( x='population:Q', y='PM2\.5:Q', text='state:N' ) return (points + labels).properties(title='PM2.5 vs Population by State – 2018', width=500, height=400) " 1952,Create a month-wise PM2.5 breakdown table across cities in Andhra Pradesh for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Rajamahendravaram', 'Tirupati', 'Visakhapatnam']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1953,Report the state with the 4th highest NCAP funding relative to its average PM10 concentration in 2021 (FY 2020-21).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 1954,Identify the city which received the 4th highest NCAP funding amount.," [] " 1955,"Show the mean, median and standard deviation of PM2.5 per city in 2020 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1956,Show annual average PM2.5 for Maharashtra as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1957,Identify the state with the 3rd highest 75th percentile of PM2.5 for September 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 1958,"Show the mean, median and standard deviation of PM10 per city in 2020 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1959,Show a cumulative area chart of PM2.5 readings for Narnaul across 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Narnaul') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Narnaul 2022', width=600, height=300) return chart " 1960,"Tabulate PM2.5 statistics (mean, std, min, max) for each city in 2018."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1961,Show annual average PM10 for Nagpur as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Nagpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1962,Show the monthly average PM2.5 for Bhilwara in 2024 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bhilwara') & (data['Timestamp'].dt.year == 2024)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Bhilwara 2024', width=450, height=280) " 1963,"Tabulate PM10 levels, population, and land area per state in 2022."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1964,List the bottom 5 citys with the lowest average PM10 in 2019 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 1965,"Tabulate PM2.5 levels, population, and land area per state in 2020."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': { 'map': { 'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1966,Tabulate average PM10 for each city in Rajasthan across all months of 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Ajmer', 'Alwar', 'Bhiwadi', 'Jaipur', 'Jodhpur', 'Kota', 'Pali', 'Udaipur']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1967,Report which state experienced the most minimal median PM10 throughout the Monsoon season of 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 1968,Identify the state with the 2nd highest 75th percentile of PM2.5 for November 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 1969,Report which city experienced the 2nd most minimal 75th percentile of PM2.5 throughout the Post-Monsoon season of 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 1970,Generate a monthly average PM10 table for Nagpur for the year 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Nagpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1971,Tabulate the 15 citys with the least PM10 pollution in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 1972,List the top 10 citys by average PM2.5 in 2024 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 1973,Create a ranked table of the 5 best-performing citys by PM2.5 in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 1974,How many times did Kannur city go above the WHO guideline for PM10 in 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 15.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 1975,Show a monthly bar chart of the number of days Sikkim exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Sikkim') & (data['Timestamp'].dt.year == 2023)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Sikkim Exceeded WHO PM2.5 Guideline per Month – 2023', width=500, height=300) return chart " 1976,"Plot the yearly average PM2.5 trends for Telangana, Kerala, and Haryana from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Telangana', 'Kerala', 'Haryana'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Telangana vs Kerala vs Haryana', width=550, height=320) return chart " 1977,List the average PM10 for Moradabad broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Moradabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1978,Show the monthly average PM2.5 for Gorakhpur in 2022 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Gorakhpur') & (data['Timestamp'].dt.year == 2022)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Gorakhpur 2022', width=450, height=280) " 1979,"Create a grouped bar chart comparing the average PM2.5 for Manipur, Manipur, and Kerala across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Manipur', 'Manipur', 'Kerala'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 1980,"Create a grouped bar chart comparing the average PM2.5 for Himachal Pradesh, Puducherry, and Karnataka across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Himachal Pradesh', 'Puducherry', 'Karnataka'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 1981,"Create a grouped bar chart comparing the average PM2.5 for Tripura, Assam, and Puducherry across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tripura', 'Assam', 'Puducherry'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 1982,Tabulate the monthly mean PM10 levels for Muzaffarpur during 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Muzaffarpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1983,Report which city possessed the third highest average PM2.5 throughout the Summer season of 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 1984,"Plot a scatter chart of state-level average PM2.5 versus population for 2021, with point size representing area."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): pm = data[data['Timestamp'].dt.year == 2021].groupby('state')['PM2.5'].mean().reset_index().dropna() df = pm.merge(states_data, on='state') chart = alt.Chart(df).mark_point(filled=True, opacity=0.7).encode( x=alt.X('population:Q', title='Population', axis=alt.Axis(format='~s')), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), size=alt.Size('area (km2):Q', title='Area (km²)', scale=alt.Scale(range=[50,1000])), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('population:Q', format=','), 'area (km2):Q'] ).properties(title='PM2.5 vs Population (size=Area) – 2021', width=500, height=400) return chart " 1985,Tabulate the 5 states with the least PM2.5 pollution in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 1986,List all citys with their average PM2.5 and PM10 levels in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 1987,Visualize the bottom 6 states with the lowest average PM2.5 in 2019 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2019] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(6, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 6 States by Average PM2.5 in 2019', width=500, height=300) return chart " 1988,Tabulate the 10 worst citys for average PM2.5 in 2017 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 1989,Which city registered the 3rd lowest median PM10 during February 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 1990,"Create a grouped bar chart comparing the average PM2.5 for Assam, Uttar Pradesh, and Haryana across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Assam', 'Uttar Pradesh', 'Haryana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 1991,Plot the weekly average PM2.5 for Tirupati in 2017 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Tirupati') & (data['Timestamp'].dt.year == 2017)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Tirupati 2017', width=600, height=300) return chart " 1992,Which state noted the peak 25th percentile of PM2.5 during the Summer season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 1993,"Visualize the monthly average PM10 for Arunachal Pradesh, Karnataka, and Bihar in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Arunachal Pradesh', 'Karnataka', 'Bihar'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Arunachal Pradesh, Karnataka, UP – 2019', width=550, height=320) return chart " 1994,Which state had the 3rd highest 25th percentile of PM10 in May 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 1995,Which city registered the lowest 75th percentile of PM10 during August 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 1996,Name the state with the lowest 25th percentile for PM2.5 in March 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 1997,"In August 2021, which city exhibited the 3rd lowest 25th percentile of PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 1998,Identify the state that saw the third most significant fall in average PM2.5 levels when comparing December 2023 to October 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 1999,Which state registered the 2nd lowest 25th percentile of PM2.5 during November 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 2000,Create a month-wise summary of average PM2.5 for Ahmedabad in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Ahmedabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2001,Show a ranked table of the 5 most polluted states by average PM2.5 in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 2002,Create a table showing annual mean PM2.5 levels for Nagpur (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Nagpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2003,Identify the city that registered the 2nd most minimal average PM10 during the Post-Monsoon season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 2004,Plot the rolling 30-day average PM2.5 for Uttarakhand in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Uttarakhand') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Uttarakhand 2023', width=600, height=300) " 2005,Tabulate the 10 states with the least PM10 pollution in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 2006,Generate a monthly average PM10 table for Pune for the year 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Pune'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2007,Create a table of PM2.5 per unit area for all states in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, { 'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM2.5 per km²', 'numerator': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)', 'PM2.5 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2008,"Which city showed the third-highest 75th percentile for PM10 on March 31, 2018?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 2009,"Visualize the monthly average PM10 for Nagaland, Chandigarh, and Karnataka in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Nagaland', 'Chandigarh', 'Karnataka'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Nagaland, Chandigarh, UP – 2019', width=550, height=320) return chart " 2010,Show a cumulative area chart of PM2.5 readings for Bulandshahr across 2019.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bulandshahr') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Bulandshahr 2019', width=600, height=300) return chart " 2011,Tabulate the monthly mean PM10 levels for Lucknow during 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Lucknow'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2012,List states with their PM10 violation count and rate (>150 µg/m³) in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 150'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2013,"Report which station had the minimum PM2.5 level on January 27, 2022."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 2014,Plot the rolling 30-day average PM2.5 for Manipur in 2018 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Manipur') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Manipur 2018', width=600, height=300) " 2015,Which state registered the 3rd maximum average PM10 in the Summer season of 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 2016,Show PM2.5 exceedances above the Indian standard (60 µg/m³) per year as a bar chart for Haryana.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Haryana'].dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 60].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby('Year')['Timestamp'].nunique().reset_index() df.columns = ['Year','Days Exceeded'] chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('Year:N', title='Year'), y=alt.Y('Days Exceeded:Q', title='Days PM2.5 > 60 µg/m³'), tooltip=['Year:N','Days Exceeded:Q'] ).properties(title='Days Haryana Exceeded Indian PM2.5 Standard (60 µg/m³) per Year', width=450, height=300) return chart " 2017,"Compare the monthly average PM2.5 of Tumidih, Tirunelveli, and Pali in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Tumidih', 'Tirunelveli', 'Pali'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Tumidih vs Tirunelveli vs Pali – 2017', width=550, height=320) return chart " 2018,Plot the top 13 states by average PM2.5 in 2018 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2018] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(13, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 13 States by Average PM2.5 in 2018', width=500, height=300) return chart " 2019,Create a summary table ranking the top 20 citys by PM2.5 concentration in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 2020,Report the state with the 2nd lowest 25th percentile of PM2.5 in May 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 2021,"Visualize the monthly average PM10 for Puducherry, Delhi, and Jharkhand in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'Delhi', 'Jharkhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Puducherry, Delhi, UP – 2022', width=550, height=320) return chart " 2022,Show a monthly bar chart of the number of days Delhi exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Delhi') & (data['Timestamp'].dt.year == 2018)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Delhi Exceeded WHO PM2.5 Guideline per Month – 2018', width=500, height=300) return chart " 2023,Show a pivot table of monthly average PM10 by city for Rajasthan in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Ajmer', 'Alwar', 'Banswara', 'Baran', 'Barmer', 'Bharatpur', 'Bhilwara', 'Bhiwadi', 'Bikaner', 'Bundi', 'Chittorgarh', 'Churu', 'Dausa', 'Dholpur', 'Dungarpur', 'Hanumangarh', 'Jaipur', 'Jaisalmer', 'Jalore', 'Jhalawar', 'Jhunjhunu', 'Jodhpur', 'Karauli', 'Kota', 'Nagaur', 'Pali', 'Pratapgarh', 'Rajsamand', 'Sawai Madhopur', 'Sikar', 'Sirohi', 'Sri Ganganagar', 'Tonk', 'Udaipur']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2024,"Compare the monthly average PM2.5 of Gangtok, Gandhinagar, and Nanded in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Gangtok', 'Gandhinagar', 'Nanded'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Gangtok vs Gandhinagar vs Nanded – 2022', width=550, height=320) return chart " 2025,Show how many times PM10 exceeded 150 µg/m³ per day across states in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2026,Plot the weekly average PM2.5 for Patna in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Patna') & (data['Timestamp'].dt.year == 2024)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Patna 2024', width=600, height=300) return chart " 2027,Plot the rolling 30-day average PM2.5 for Manipur in 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Manipur') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Manipur 2022', width=600, height=300) " 2028,Show a bar chart of the top 14 cities by median PM2.5 in 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2018] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(14, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 14 Cities by Median PM2.5 in 2018', width=500, height=300) return chart " 2029,"Over all years, which October showed the third-highest median PM10 concentration?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'Timestamp'}}] " 2030,Determine the city that showed the lowest 75th percentile of PM10 over the Monsoon season of 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 2031,Show how average PM2.5 varied month by month for Tripura in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tripura'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2032,Which city had the 3rd lowest average PM2.5 in March 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 2033,Create a month-by-state breakdown table of mean PM2.5 for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Arunachal Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Chhattisgarh', 'Delhi', 'Gujarat', 'Haryana', 'Jammu and Kashmir', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Meghalaya', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2034,Determine the station with the 2nd lowest average PM2.5 in December 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 2035,List average PM10 by month for Meghalaya in 2022 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Meghalaya'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2036,"In Mizoram, what is the median PM10 concentration on Saturdays?"," [{'op': 'FILTER', 'params': {'field': 'state', 'value': 'Mizoram'}}] " 2037,"Tabulate the distribution of PM2.5 per city in 2018 including mean, median, and std."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2038,List states ranked by PM10 concentration relative to their area in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM10 per km²', 'numerator': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)', 'PM10 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2039,Determine the city exhibiting the lowest 25th percentile of PM2.5 in February 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 2040,Show how average PM2.5 varied month by month for Haryana in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Haryana'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2041,Show a cumulative area chart of PM2.5 readings for Navi Mumbai across 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Navi Mumbai') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Navi Mumbai 2022', width=600, height=300) return chart " 2042,"Compare the monthly average PM2.5 of Bahadurgarh, Bulandshahr, and Bagalkot in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Bahadurgarh', 'Bulandshahr', 'Bagalkot'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Bahadurgarh vs Bulandshahr vs Bagalkot – 2024', width=550, height=320) return chart " 2043,"Which state (excluding Union Territories) exhibits the 3rd maximum PM10 concentration per square kilometer, based on 25th percentile PM10 values?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_km2', 'numerator': 'PM10', 'denominator': 'area (km2)'}}, {'op': 'SORT', 'params': {'col': 'pm_per_km2', 'ascending': False}}] " 2044,"Plot the yearly average PM2.5 trends for Chhattisgarh, Karnataka, and Tamil Nadu from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chhattisgarh', 'Karnataka', 'Tamil Nadu'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Chhattisgarh vs Karnataka vs Tamil Nadu', width=550, height=320) return chart " 2045,Which state possessed the highest median for PM2.5 in the Summer season of 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 2046,Identify the city that received the 2nd lowest NCAP funding relative to the standard deviation of its PM10 concentration in 2021 (FY 2020-21).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'std', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 2047,Show average PM2.5 per capita by state in 2019 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM2.5 per million', 'numerator': 'PM2.5', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'PM2.5 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2048,"Visualize the monthly average PM10 for Tamil Nadu, Jharkhand, and Tamil Nadu in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Jharkhand', 'Tamil Nadu'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Tamil Nadu, Jharkhand, UP – 2018', width=550, height=320) return chart " 2049,"Compare the monthly average PM2.5 of Chikkaballapur, Chandrapur, and Sawai Madhopur in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Chikkaballapur', 'Chandrapur', 'Sawai Madhopur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Chikkaballapur vs Chandrapur vs Sawai Madhopur – 2023', width=550, height=320) return chart " 2050,"Create a grouped bar chart comparing the average PM2.5 for Jammu and Kashmir, Madhya Pradesh, and Chhattisgarh across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jammu and Kashmir', 'Madhya Pradesh', 'Chhattisgarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 2051,Create a table with mean and standard deviation of PM2.5 by city in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2052,Identify the state with the 2nd highest 25th percentile of PM2.5 in April 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 2053,"Visualize the monthly average PM10 for Rajasthan, Chandigarh, and Jharkhand in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Chandigarh', 'Jharkhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Rajasthan, Chandigarh, UP – 2019', width=550, height=320) return chart " 2054,Show the number of days each city exceeded a PM10 threshold of 100 µg/m³ in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2055,Tabulate the monthly mean PM10 levels for Meerut during 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Meerut'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2056,Determine the state that registered the second highest 75th percentile of PM2.5 over the Winter season of 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 2057,Which station recorded the 3rd lowest median PM2.5 in the Winter season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 2058,Identify the city that recorded the 3rd highest median PM2.5 value in June 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 2059,Show a monthly bar chart of the number of days Uttarakhand exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Uttarakhand') & (data['Timestamp'].dt.year == 2022)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Uttarakhand Exceeded WHO PM2.5 Guideline per Month – 2022', width=500, height=300) return chart " 2060,Report the state that had the 2nd highest 25th percentile of PM10 in September 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 2061,Show the monthly average PM10 trend for Solapur from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Solapur'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Solapur (2019–2024)', width=600, height=300) return chart " 2062,Generate a table showing the 15 most polluted citys based on mean PM10 for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 2063,"Over all years, which March experienced the second-lowest 75th percentile for PM10 concentration?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'Timestamp'}}] " 2064,"Which station showed the second-highest 75th percentile for PM10 on March 31, 2024?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 2065,Create a table of PM10 per unit area for all states in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM10 per km²', 'numerator': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)', 'PM10 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2066,Tabulate average and median PM10 for all citys in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2067,Which state noted the 2nd highest 25th percentile of PM10 in the Winter season of 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 2068,"Compare the monthly average PM2.5 of Karauli, Brajrajnagar, and Hosur in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Karauli', 'Brajrajnagar', 'Hosur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Karauli vs Brajrajnagar vs Hosur – 2023', width=550, height=320) return chart " 2069,Plot the weekly average PM2.5 for Narnaul in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Narnaul') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Narnaul 2023', width=600, height=300) return chart " 2070,"Compare the monthly average PM2.5 of Agra, Bhiwadi, and Akola in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Agra', 'Bhiwadi', 'Akola'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Agra vs Bhiwadi vs Akola – 2022', width=550, height=320) return chart " 2071,Show a year-wise table of average PM2.5 for Puducherry from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Puducherry'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2072,"On January 14, 2018, which station showed the highest PM10 values?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 2073,"Which state (excluding UTs) possesses the smallest population among the top 5 most polluted states, determined by the 25th percentile of PM10 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 5, 'ret': 'state'}}] " 2074,"In May 2023, identify the station with the 3rd highest 75th percentile of PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 2075,Show the number of days each state exceeded a PM10 threshold of 100 µg/m³ in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2076,Show a table of the top 15 citys by average PM2.5 in 2017 including their PM10 levels too.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 2077,"Create a grouped bar chart comparing the average PM2.5 for Tripura, Meghalaya, and West Bengal across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tripura', 'Meghalaya', 'West Bengal'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 2078,Generate a monthly average PM10 table for Mizoram for the year 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Mizoram'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2079,"On March 31, 2024, which station recorded the second-highest average PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 2080,Show how average PM10 varied month by month for Faridabad in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Faridabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2081,Show the monthly average PM10 trend for Hapur from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Hapur'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Hapur (2017–2022)', width=600, height=300) return chart " 2082,Generate a city × month cross-tab of mean PM10 for Tamil Nadu in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Chennai', 'Coimbatore', 'Gummidipoondi', 'Thoothukudi']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2083,Identify the city that recorded the highest average PM2.5 value in March 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 2084,"Compare the monthly average PM2.5 of Damoh, Malegaon, and Korba in 2020 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Damoh', 'Malegaon', 'Korba'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2020)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Damoh vs Malegaon vs Korba – 2020', width=550, height=320) return chart " 2085,"Create a grouped bar chart comparing the average PM2.5 for Bihar, Jharkhand, and Rajasthan across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Bihar', 'Jharkhand', 'Rajasthan'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 2086,Show a monthly bar chart of the number of days Kerala exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2017.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Kerala') & (data['Timestamp'].dt.year == 2017)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Kerala Exceeded WHO PM2.5 Guideline per Month – 2017', width=500, height=300) return chart " 2087,How many times did Madhya Pradesh city exceed 90 µg/m³ of PM2.5 in the year 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 90.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 2088,Plot the weekly average PM2.5 for Pali in 2018 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Pali') & (data['Timestamp'].dt.year == 2018)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Pali 2018', width=600, height=300) return chart " 2089,Plot the weekly average PM2.5 for Mandikhera in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Mandikhera') & (data['Timestamp'].dt.year == 2020)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Mandikhera 2020', width=600, height=300) return chart " 2090,How many stations in Mizoram went above 30 µg/m³ of PM10 in the year 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 30.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 2091,"Compare the monthly average PM2.5 of Coimbatore, Nagaon, and Kolhapur in 2020 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Coimbatore', 'Nagaon', 'Kolhapur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2020)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Coimbatore vs Nagaon vs Kolhapur – 2020', width=550, height=320) return chart " 2092,"Create a grouped bar chart comparing the average PM2.5 for Odisha, Karnataka, and Rajasthan across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Odisha', 'Karnataka', 'Rajasthan'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 2093,"Create a grouped bar chart comparing the average PM2.5 for Bihar, Madhya Pradesh, and Assam across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Bihar', 'Madhya Pradesh', 'Assam'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 2094,Tabulate the 20 states with the least PM2.5 pollution in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 2095,Generate a monthly average PM2.5 table for Durgapur for the year 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Durgapur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2096,"Create a grouped bar chart comparing the average PM2.5 for Uttar Pradesh, Maharashtra, and Kerala across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttar Pradesh', 'Maharashtra', 'Kerala'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 2097,Tabulate average PM2.5 for each city in Punjab across all months of 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Amritsar', 'Bathinda', 'Jalandhar', 'Khanna', 'Ludhiana', 'Mandi Gobindgarh', 'Patiala', 'Rupnagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2098,Plot the weekly average PM2.5 for Asansol in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Asansol') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Asansol 2023', width=600, height=300) return chart " 2099,List citys with their PM10 violation count and rate (>100 µg/m³) in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2100,"Considering 2021, what week number displayed the third-lowest 25th percentile for PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'week'}}] " 2101,Show a pivot table of monthly average PM10 by city for Andhra Pradesh in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Amaravati', 'Rajamahendravaram', 'Tirupati', 'Vijayawada', 'Visakhapatnam']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2102,Tabulate average PM2.5 for each city in Assam across all months of 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Assam'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Guwahati']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2103,Plot the weekly average PM2.5 for Amritsar in 2021 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Amritsar') & (data['Timestamp'].dt.year == 2021)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Amritsar 2021', width=600, height=300) return chart " 2104,Show a cumulative area chart of PM2.5 readings for Naharlagun across 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Naharlagun') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Naharlagun 2022', width=600, height=300) return chart " 2105,Determine the station exhibiting the 2nd highest median PM10 over the Summer season of 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 2106,Generate a descriptive stats table for PM10 grouped by state in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2107,Create a month-wise PM2.5 breakdown table across cities in Andhra Pradesh for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Amaravati', 'Rajamahendravaram', 'Tirupati', 'Visakhapatnam']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2108,Tabulate days with PM2.5 > 100 µg/m³ and exceedance percentage per city in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2109,Generate a city × month cross-tab of mean PM2.5 for Rajasthan in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Ajmer', 'Alwar', 'Bhiwadi', 'Jaipur', 'Jodhpur', 'Kota', 'Pali', 'Udaipur']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2110,"Show the variability of PM2.5 across states in 2022 using mean, median, and standard deviation."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2111,Generate a monthly average PM2.5 table for Uttar Pradesh for the year 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2112,Create a ranked table of the 20 best-performing states by PM10 in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 2113,"During the past two years in Ankleshwar, on which date was the PM2.5 level the second lowest?"," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 2}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'Timestamp'}}] " 2114,"On January 14, 2020, which station recorded the third-lowest PM10 measurements?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 2115,Plot the distribution of PM2.5 values in Manipur across all years using a histogram.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Manipur'].dropna(subset=['PM2.5']) df = df[['PM2.5']] chart = alt.Chart(df).mark_bar(color='steelblue', opacity=0.75).encode( x=alt.X('PM2\.5:Q', bin=alt.Bin(maxbins=40), title='PM2.5 (µg/m³)'), y=alt.Y('count()', title='Number of Observations'), tooltip=[alt.Tooltip('PM2\.5:Q', bin=True), 'count()'] ).properties(title='PM2.5 Distribution – Manipur (All Years)', width=500, height=300) return chart " 2116,Show a monthly bar chart of the number of days Tripura exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Tripura') & (data['Timestamp'].dt.year == 2021)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Tripura Exceeded WHO PM2.5 Guideline per Month – 2021', width=500, height=300) return chart " 2117,Show a ranked table of the 20 most polluted citys by average PM10 in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 2118,Which city received the 5th lowest NCAP funding relative to its total PM2.5 concentration in 2020 (FY 2019-20)?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'sum', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2020_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 2119,Determine the station with the third-highest 25th percentile of PM2.5 for August 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 2120,Which station experienced the highest median for PM10 in the Summer season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 2121,Which city recorded the highest 75th percentile for PM10 in the Post-Monsoon season of 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 2122,Report the state with the 2nd highest average PM10 in June 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 2123,On which date in the last five years did Chikkamagaluru record its 3rd peak PM2.5 level?," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 5}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'Timestamp'}}] " 2124,Report the state that had the 2nd highest median PM10 in November 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 2125,Show a monthly bar chart of the number of days Kerala exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Kerala') & (data['Timestamp'].dt.year == 2018)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Kerala Exceeded WHO PM2.5 Guideline per Month – 2018', width=500, height=300) return chart " 2126,Create a ranked table of the 20 best-performing citys by PM2.5 in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 2127,Plot the rolling 30-day average PM2.5 for Andhra Pradesh in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Andhra Pradesh') & (data['Timestamp'].dt.year == 2020)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Andhra Pradesh 2020', width=600, height=300) " 2128,Which city noted the 2nd maximum 25th percentile of PM2.5 in the Post-Monsoon season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 2129,"In June 2024, report the state with the lowest 25th percentile of PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 2130,"In July 2019, report the city with the 3rd highest 25th percentile of PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 2131,"Show average PM2.5, PM10 and the number of monitoring stations per state in 2021."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}, {'alias': 'Station Count', 'col': 'station', 'fn': 'nunique'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2132,List how many days each state breached the PM10 limit of 100 µg/m³ in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2133,Which state recorded the 3rd highest 75th percentile of PM2.5 in January 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 2134,"Show mean, median, minimum, and maximum PM2.5 for each state in 2020 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2135,How many times did Bangalore city surpass 30 µg/m³ of PM2.5 in 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 30.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 2136,Show the monthly average PM2.5 for Bhiwani in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bhiwani') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Bhiwani 2020', width=450, height=280) " 2137,Generate a city × month cross-tab of mean PM10 for Gujarat in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Gujarat'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Ahmedabad', 'Ankleshwar', 'Gandhinagar', 'Nandesari', 'Vapi', 'Vatva']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2138,"Tabulate PM10 statistics (mean, std, min, max) for each city in 2019."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2139,"Compare the monthly average PM2.5 of Malegaon, Meerut, and Siliguri in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Malegaon', 'Meerut', 'Siliguri'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Malegaon vs Meerut vs Siliguri – 2024', width=550, height=320) return chart " 2140,Visualize the bottom 9 states with the lowest average PM2.5 in 2018 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2018] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(9, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 9 States by Average PM2.5 in 2018', width=500, height=300) return chart " 2141,Determine the station exhibiting the highest 25th percentile of PM2.5 in November 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 2142,Which station had the most substantial increase in its 75th percentile PM2.5 level between September 2019 and September 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 2143,Tabulate the monthly mean PM10 levels for Delhi during 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Delhi'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2144,"Considering 2021, what season (Winter, Summer, Monsoon, Post-Monsoon) displayed the second-lowest median PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'season'}}] " 2145,"Create a grouped bar chart comparing the average PM2.5 for Chhattisgarh, Chhattisgarh, and Jammu and Kashmir across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chhattisgarh', 'Chhattisgarh', 'Jammu and Kashmir'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 2146,Identify the state with the 2nd highest 75th percentile of PM10 for April 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 2147,"In December 2020, which station had the 3rd highest 75th percentile of PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 2148,How many times did Bhilwara city surpass 90 µg/m³ of PM2.5 in 2017?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 90.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 2149,Show a monthly breakdown table of average PM2.5 for West Bengal in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'West Bengal'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2150,List the bottom 10 citys with the lowest average PM2.5 in 2018 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 2151,Show a monthly breakdown table of average PM2.5 for Chandigarh in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Chandigarh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2152,"In August 2019, which city recorded the 3rd lowest 25th percentile of PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 2153,Identify the city with the 3rd lowest 75th percentile of PM10 for March 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 2154,Which station had the 2nd lowest 25th percentile of PM2.5 in January 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 2155,Determine the state with the 2nd lowest median PM10 in January 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 2156,"Comparing October to December in 2023, which city experienced the second smallest reduction in its 75th percentile PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 2157,Show a monthly bar chart of the number of days Delhi exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Delhi') & (data['Timestamp'].dt.year == 2022)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Delhi Exceeded WHO PM2.5 Guideline per Month – 2022', width=500, height=300) return chart " 2158,Create a table of PM10 standard violations (>150 µg/m³) per state in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2159,Plot the median PM10 for each state in summer 2017 (April–June) as a sorted bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['Timestamp'].dt.year == 2017) & (data['Timestamp'].dt.month.isin([4,5,6]))] df = df.groupby('state')['PM10'].median().reset_index().dropna() df = df.sort_values('PM10', ascending=False) chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Median PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='yelloworangered'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Median PM10 by State – Summer 2017 (Apr–Jun)', width=500, height=400) return chart " 2160,List average PM2.5 by month for Varanasi in 2021 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Varanasi'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2161,"Scatter plot PM2.5 vs PM10 for Chhattisgarh stations in 2021, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Chhattisgarh') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Chhattisgarh Stations 2021', width=450, height=350) " 2162,Create a statistical summary table of PM2.5 readings by city for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2163,"Create a grouped bar chart comparing the average PM2.5 for Arunachal Pradesh, Himachal Pradesh, and Sikkim across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Arunachal Pradesh', 'Himachal Pradesh', 'Sikkim'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 2164,"Show a table of average PM2.5, population, and area for all states in 2020."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': { 'map': { 'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2165,"Show the mean, median and standard deviation of PM10 per state in 2024 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2166,Show a cumulative area chart of PM2.5 readings for Ramanathapuram across 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ramanathapuram') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Ramanathapuram 2024', width=600, height=300) return chart " 2167,Show a cross-tab of state vs year for average PM10 levels.," [ { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Delhi', 'Haryana', 'Jharkhand', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Odisha', 'Punjab', 'Rajasthan', 'Telangana', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'year', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2168,Identify the state that registered the third highest median PM2.5 during the Winter season of 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 2169,Tabulate the yearly average PM2.5 trend for Kolkata across all years.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Kolkata'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2170,"For the period October to December 2024, which state had the smallest decrease in average PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 2171,"Which state showed the second-lowest average PM10 on March 31, 2019?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 2172,"For the period October to December 2018, which station had the third smallest decrease in median PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 2173,Report the station with the 3rd lowest 75th percentile of PM10 in March 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 2174,List how many days each state breached the PM2.5 limit of 100 µg/m³ in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2175,Plot the average PM2.5 across all states in February 2024 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['Timestamp'].dt.year == 2024) & (data['Timestamp'].dt.month == 2)] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('PM2.5', ascending=False) chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='plasma'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Average PM2.5 by State – February 2024', width=500, height=400) return chart " 2176,Show a monthly bar chart of the number of days Gujarat exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Gujarat') & (data['Timestamp'].dt.year == 2021)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Gujarat Exceeded WHO PM2.5 Guideline per Month – 2021', width=500, height=300) return chart " 2177,Which state had the highest average PM2.5 in September 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 2178,Report the state (excluding union territories) that received the minimum NCAP funding relative to its land area on a per-square basis.," [{'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_sqkm', 'numerator': 'total_fund', 'denominator': 'area (km2)'}}, {'op': 'SORT', 'params': {'col': 'funding_per_sqkm', 'ascending': True}}] " 2179,Report the state with the lowest median PM10 in January 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 2180,"Which station showed the second-highest 25th percentile for PM2.5 on March 31, 2019?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 2181,Show a bar chart of the top 9 cities by median PM2.5 in 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2021] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(9, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 9 Cities by Median PM2.5 in 2021', width=500, height=300) return chart " 2182,Identify the city that recorded the 2nd highest 75th percentile of PM2.5 value in March 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 2183,Show the monthly average PM10 trend for Rourkela from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Rourkela'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Rourkela (2017–2022)', width=600, height=300) return chart " 2184,Which station exhibited the largest decrease in its 75th percentile PM10 levels between October and December of 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 2185,"Which state (excluding Union Territories) possesses the smallest land area among the top 5 most polluted states, based on the 25th percentile of PM10 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 5, 'ret': 'state'}}] " 2186,Which state had the 3rd highest 25th percentile of PM2.5 in January 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 2187,"Visualize the monthly average PM10 for Uttarakhand, Madhya Pradesh, and Himachal Pradesh in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttarakhand', 'Madhya Pradesh', 'Himachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Uttarakhand, Madhya Pradesh, UP – 2023', width=550, height=320) return chart " 2188,Show how many times PM2.5 exceeded 100 µg/m³ per day across states in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2189,Tabulate the yearly average PM10 trend for Andhra Pradesh across all years.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2190,"Visualize the monthly average PM10 for Punjab, Rajasthan, and Jammu and Kashmir in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Punjab', 'Rajasthan', 'Jammu and Kashmir'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Punjab, Rajasthan, UP – 2024', width=550, height=320) return chart " 2191,Tabulate mean PM10 and land area for each state in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2192,"Compare the monthly average PM2.5 of Chittoor, Rajgir, and Jind in 2020 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Chittoor', 'Rajgir', 'Jind'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2020)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Chittoor vs Rajgir vs Jind – 2020', width=550, height=320) return chart " 2193,"Create a comprehensive state summary with PM2.5, population, and area for 2022."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': { 'map': { 'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2194,"Create a grouped bar chart comparing the average PM2.5 for Jharkhand, Haryana, and Chhattisgarh across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Haryana', 'Chhattisgarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 2195,How many times did Chandigarh city exceed the WHO guideline for PM2.5 in the year 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 15.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 2196,Show average PM10 per capita by state in 2017 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM10 per million', 'numerator': 'PM10', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'PM10 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2197,"In November 2020, identify the city with the 3rd highest average PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 2198,Determine which state had the lowest NCAP funding relative to its 25th percentile of PM2.5 concentration in 2021 (FY 2020-21).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 2199,Create a table of PM10 exceedance frequency above 100 µg/m³ by state for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2200,Name the station showing the second-highest median PM10 for August 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 2201,List the top 20 citys by average PM2.5 in 2022 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 2202,Generate a city × month cross-tab of mean PM10 for Karnataka in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Bengaluru']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2203,Create a month-wise PM10 breakdown table across cities in Odisha for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Odisha'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Baripada', 'Bileipada', 'Brajrajnagar', 'Keonjhar', 'Nayagarh', 'Rourkela', 'Suakati', 'Talcher', 'Tensa']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2204,Create a month-wise PM2.5 breakdown table across cities in Andhra Pradesh for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Amaravati', 'Rajamahendravaram', 'Tirupati', 'Visakhapatnam']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2205,"Compare the monthly average PM2.5 of Amaravati, Lucknow, and Visakhapatnam in 2020 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Amaravati', 'Lucknow', 'Visakhapatnam'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2020)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Amaravati vs Lucknow vs Visakhapatnam – 2020', width=550, height=320) return chart " 2206,Which state exhibited the third largest decrease in its average PM10 levels between October and December of 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 2207,Tabulate average PM2.5 for each city in Tamil Nadu across all months of 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Chennai']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2208,Identify the station that showed the second lowest 25th percentile of PM2.5 during the Monsoon season of 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 2209,Show a pivot table of monthly average PM10 by state for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Delhi', 'Gujarat', 'Haryana', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Meghalaya', 'Odisha', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2210,Generate a table showing the 5 most polluted citys based on mean PM10 for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 2211,Create a month-wise PM2.5 breakdown table across cities in Andhra Pradesh for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Amaravati', 'Anantapur', 'Chittoor', 'Kadapa', 'Rajamahendravaram', 'Tirupati', 'Vijayawada', 'Visakhapatnam']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2212,Which state registered the 3rd highest 25th percentile of PM10 during July 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 2213,"Plot the yearly average PM2.5 trends for Bihar, Himachal Pradesh, and Tamil Nadu from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Bihar', 'Himachal Pradesh', 'Tamil Nadu'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Bihar vs Himachal Pradesh vs Tamil Nadu', width=550, height=320) return chart " 2214,Which city recorded the 2nd highest 75th percentile of PM2.5 in May 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 2215,Show the monthly average PM2.5 for Silchar in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Silchar') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Silchar 2019', width=450, height=280) " 2216,Which station showed the 2nd highest median for PM2.5 in the Post-Monsoon season of 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 2217,Show a bar chart of the top 14 cities by median PM2.5 in 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2023] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(14, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 14 Cities by Median PM2.5 in 2023', width=500, height=300) return chart " 2218,Report the state with the 3rd lowest median PM2.5 in November 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 2219,"Identify the station with the minimum 75th percentile for PM2.5 on March 31, 2020."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 2220,Identify the year that recorded the second-lowest 75th percentile of PM10.," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'Timestamp'}}] " 2221,"In June 2019, which city recorded the highest median PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 2222,Show the monthly average PM10 trend for Byrnihat from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Byrnihat'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Byrnihat (2019–2024)', width=600, height=300) return chart " 2223,"Plot the yearly average PM2.5 trends for Tripura, Meghalaya, and Telangana from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tripura', 'Meghalaya', 'Telangana'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Tripura vs Meghalaya vs Telangana', width=550, height=320) return chart " 2224,Show a pivot table of monthly average PM2.5 by city for Kerala in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Thiruvananthapuram']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2225,Tabulate the 5 states with the least PM2.5 pollution in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 2226,Which station had the 3rd lowest 25th percentile of PM2.5 in November 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 2227,Report the union territory that received the maximum NCAP funding relative to its land area on a per-square basis.," [{'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_sqkm', 'numerator': 'total_fund', 'denominator': 'area (km2)'}}, {'op': 'SORT', 'params': {'col': 'funding_per_sqkm', 'ascending': False}}] " 2228,Determine the state exhibiting the most minimal average PM2.5 over the Post-Monsoon season of 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 2229,"Scatter plot PM2.5 vs PM10 for Chhattisgarh stations in 2020, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Chhattisgarh') & (data['Timestamp'].dt.year == 2020)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Chhattisgarh Stations 2020', width=450, height=350) " 2230,Plot the monthly average PM2.5 trend for Maharashtra from 2017 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Maharashtra'].copy() df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly Average PM2.5 Trend – Maharashtra (2017–2024)', width=600, height=300) return chart " 2231,How many times did Gujarat go above 75 µg/m³ of PM10 in the year 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 75.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 2232,Show a heatmap of average PM2.5 for the top 12 most polluted states by month for 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(12).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 12 Polluted States by Month (2024)', width=500, height=300) return chart " 2233,Which state exhibited the highest 25th percentile for PM10 during August 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 2234,Generate a year-by-year summary table of PM2.5 readings for Raipur.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Raipur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2235,Visualize the bottom 11 states with the lowest average PM2.5 in 2022 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2022] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(11, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 11 States by Average PM2.5 in 2022', width=500, height=300) return chart " 2236,Plot the weekly average PM2.5 for Aurangabad in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Aurangabad') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Aurangabad 2023', width=600, height=300) return chart " 2237,Generate a table showing the 10 most polluted states based on mean PM10 for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 2238,Show how average PM2.5 varied month by month for Jaipur in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Jaipur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2239,Determine the least polluted union territory concerning per capita PM10 exposure in 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'COMPUTE', 'params': {'new_col': 'per_capita_pm', 'numerator': 'PM10', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'per_capita_pm', 'ascending': True}}] " 2240,Tabulate daily PM10 exceedances (above 150 µg/m³) per state for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2241,"Considering 2021, what week number displayed the second-lowest median PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'week'}}] " 2242,"Create a grouped bar chart comparing the average PM2.5 for Tripura, Uttar Pradesh, and Assam across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tripura', 'Uttar Pradesh', 'Assam'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 2243,Show PM2.5 exceedance count and rate (%) above 60 µg/m³ per state in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2244,Identify the state that recorded the 3rd highest median PM10 value in October 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 2245,"Identify the station with the second-lowest 75th percentile for PM2.5 on March 31, 2018."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 2246,Which station displayed the 3rd highest average PM2.5 in October 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 2247,Which state recorded the 3rd lowest 25th percentile of PM2.5 in August 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 2248,"Across all recorded years, which January registered the second-lowest median PM10 levels?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'Timestamp'}}] " 2249,"Report which union territory, out of those with populations above the average, obtains the lowest per capita NCAP funding."," [{'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_capita', 'numerator': 'total_fund', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'funding_per_capita', 'ascending': True}}] " 2250,Generate a cross-tab of state vs month for average PM10 in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Delhi', 'Haryana', 'Jharkhand', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Odisha', 'Punjab', 'Rajasthan', 'Telangana', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2251,"Compare the monthly average PM2.5 of Maihar, Ernakulam, and Visakhapatnam in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Maihar', 'Ernakulam', 'Visakhapatnam'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Maihar vs Ernakulam vs Visakhapatnam – 2023', width=550, height=320) return chart " 2252,Generate a monthly average PM2.5 table for Tamil Nadu for the year 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2253,Plot the rolling 30-day average PM2.5 for Uttar Pradesh in 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Uttar Pradesh') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Uttar Pradesh 2022', width=600, height=300) " 2254,List the top 10 citys by average PM2.5 in 2018 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 2255,Identify the state with the 2nd highest median PM10 for May 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 2256,"Create a grouped bar chart comparing the average PM2.5 for Bihar, Manipur, and Jharkhand across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Bihar', 'Manipur', 'Jharkhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 2257,Which city had the highest 75th percentile of PM2.5 in March 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 2258,List the top 5 citys by average PM10 in 2023 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 2259,Plot the weekly average PM2.5 for Munger in 2021 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Munger') & (data['Timestamp'].dt.year == 2021)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Munger 2021', width=600, height=300) return chart " 2260,Which 15 citys recorded the highest average PM2.5 levels in 2017? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 2261,"Plot the yearly average PM2.5 trends for Karnataka, Tamil Nadu, and Uttarakhand from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Karnataka', 'Tamil Nadu', 'Uttarakhand'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Karnataka vs Tamil Nadu vs Uttarakhand', width=550, height=320) return chart " 2262,"Considering 2020, what season (Winter, Summer, Monsoon, Post-Monsoon) displayed the lowest average PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'season'}}] " 2263,Create a statistical summary table of PM2.5 readings by state for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2264,Create a table of PM2.5 exceedance frequency above 60 µg/m³ by state for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2265,Tabulate days with PM2.5 > 60 µg/m³ and exceedance percentage per city in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2266,Report which station registered the most minimal median PM10 throughout the Winter season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 2267,"Tabulate PM2.5 statistics (mean, std, min, max) for each city in 2023."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2268,Plot the weekly average PM2.5 for Byrnihat in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Byrnihat') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Byrnihat 2023', width=600, height=300) return chart " 2269,List the top 15 citys by average PM10 in 2022 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 2270,"Comparing August 2019 with August 2020, which state showed the largest increase in its 25th percentile PM10 level?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 2271,Show a table of average PM10 per state in 2021 along with population.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2272,Show a heatmap of average PM2.5 for the top 11 most polluted states by month for 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(11).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 11 Polluted States by Month (2021)', width=500, height=300) return chart " 2273,Show a table of average PM2.5 and PM10 for all citys in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2274,Show the number of days each state exceeded a PM2.5 threshold of 60 µg/m³ in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2275,Determine which state got the 3rd highest NCAP funding with respect to its 25th percentile of PM2.5 concentration in 2021 (FY 2020-21).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 2276,"In May 2018, which city displayed the 3rd highest 75th percentile of PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 2277,Show the number of days each state exceeded a PM2.5 threshold of 60 µg/m³ in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2278,"Identify the station with the third-lowest 25th percentile for PM10 on March 31, 2024."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 2279,"Plot the yearly average PM2.5 trends for Tripura, Jammu and Kashmir, and Madhya Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tripura', 'Jammu and Kashmir', 'Madhya Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Tripura vs Jammu and Kashmir vs Madhya Pradesh', width=550, height=320) return chart " 2280,Show a ranked table of the 20 most polluted states by average PM10 in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 2281,Show a cumulative area chart of PM2.5 readings for Bhiwani across 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bhiwani') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Bhiwani 2022', width=600, height=300) return chart " 2282,"Compare the monthly average PM2.5 of Gorakhpur, Vijayawada, and Perundurai in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Gorakhpur', 'Vijayawada', 'Perundurai'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Gorakhpur vs Vijayawada vs Perundurai – 2018', width=550, height=320) return chart " 2283,How many times did Bundi city go above 75 µg/m³ of PM2.5 in 2017?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 75.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 2284,Plot the weekly average PM2.5 for Bhopal in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bhopal') & (data['Timestamp'].dt.year == 2024)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Bhopal 2024', width=600, height=300) return chart " 2285,Tabulate average PM10 for each city in Karnataka across all months of 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Bagalkot', 'Bengaluru', 'Chamarajanagar', 'Chikkaballapur', 'Chikkamagaluru', 'Davanagere', 'Gadag', 'Hubballi', 'Koppal', 'Madikeri', 'Mysuru', 'Raichur', 'Ramanagara', 'Shivamogga', 'Udupi', 'Vijayapura', 'Yadgir']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2286,Create a table of PM10 standard violations (>100 µg/m³) per state in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2287,Plot the rolling 30-day average PM2.5 for Arunachal Pradesh in 2018 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Arunachal Pradesh') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Arunachal Pradesh 2018', width=600, height=300) " 2288,"Considering all years, which March experienced the third-highest average PM10 levels?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'Timestamp'}}] " 2289,"Comparing September 2019 with September 2020, which city experienced the largest increase in its 75th percentile PM2.5 level?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 2290,Tabulate population-adjusted PM2.5 levels for each state in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM2.5 per million', 'numerator': 'PM2.5', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'PM2.5 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2291,Identify the city with the 2nd highest average PM2.5 in June 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 2292,"Plot the yearly average PM2.5 trends for Jharkhand, Puducherry, and Madhya Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Puducherry', 'Madhya Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Jharkhand vs Puducherry vs Madhya Pradesh', width=550, height=320) return chart " 2293,Which state recorded the highest 25th percentile for PM10 in the Monsoon season of 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 2294,"Create a comprehensive state summary with PM10, population, and area for 2022."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2295,Which state recorded the peak average PM2.5 in the Post-Monsoon season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 2296,Show the monthly average PM2.5 for Bharatpur in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bharatpur') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Bharatpur 2020', width=450, height=280) " 2297,Which city recorded the 2nd highest average PM2.5 in May 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 2298,Identify the station with the 3rd lowest median PM2.5 in February 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 2299,Show PM10 exceedance count and rate (%) above 100 µg/m³ per city in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2300,Show annual average PM2.5 for Rajasthan as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2301,"Plot the yearly average PM2.5 trends for Puducherry, Odisha, and Rajasthan from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'Odisha', 'Rajasthan'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Puducherry vs Odisha vs Rajasthan', width=550, height=320) return chart " 2302,List states by PM2.5 concentration per million inhabitants in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM2.5 per million', 'numerator': 'PM2.5', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'PM2.5 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2303,Plot the top 15 states by average PM2.5 in 2024 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2024] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(15, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 15 States by Average PM2.5 in 2024', width=500, height=300) return chart " 2304,Identify the station that showed the highest rise in median PM10 levels from November 2019 to November 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 2305,Show a bar chart of the top 14 cities by median PM2.5 in 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2021] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(14, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 14 Cities by Median PM2.5 in 2021', width=500, height=300) return chart " 2306,Identify the city that received the 4th lowest NCAP funding relative to the variance of its PM2.5 concentration in 2022 (FY 2021-22).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'var', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2022_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 2307,Create a table showing PM2.5 spread (min to max) and central tendency per state for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2308,Show a pivot table of monthly average PM2.5 by state for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Arunachal Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Chhattisgarh', 'Delhi', 'Gujarat', 'Haryana', 'Himachal Pradesh', 'Jammu and Kashmir', 'Jharkhand', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Manipur', 'Meghalaya', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh', 'Uttarakhand', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2309,Report the city with the highest average PM10 in December 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 2310,List how many days each state breached the PM10 limit of 150 µg/m³ in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2311,"Plot the yearly average PM2.5 trends for Tripura, Jharkhand, and Uttar Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tripura', 'Jharkhand', 'Uttar Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Tripura vs Jharkhand vs Uttar Pradesh', width=550, height=320) return chart " 2312,Create a statistical summary table of PM10 readings by state for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2313,Show a ranked table of the 5 most polluted citys by average PM10 in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 2314,Which 5 citys had the lowest mean PM2.5 in 2017? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 2315,Report the station that had the lowest average PM10 in January 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 2316,Show the monthly average PM2.5 for Mumbai in 2023 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Mumbai') & (data['Timestamp'].dt.year == 2023)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Mumbai 2023', width=450, height=280) " 2317,Which city noted the 3rd maximum average PM10 during the Post-Monsoon season of 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 2318,Identify the state with the 2nd highest 75th percentile of PM10 for November 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 2319,On which date in the past four years did Dhanbad register its 3rd minimum PM10 level?," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 4}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'Timestamp'}}] " 2320,"Plot the yearly average PM2.5 trends for Tamil Nadu, Chandigarh, and Himachal Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Chandigarh', 'Himachal Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Tamil Nadu vs Chandigarh vs Himachal Pradesh', width=550, height=320) return chart " 2321,Which city experienced the third most significant drop in its average PM10 levels between October and December 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 2322,Which union territory demonstrates the 2nd highest standard deviation of PM2.5 concentration in relation to its population density?," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'std', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_capita', 'numerator': 'PM2.5', 'denominator': 'population'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'pm_per_capita', 'ascending': False}}] " 2323,Which city recorded the lowest average PM2.5 value in November 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 2324,Create a summary table ranking the top 5 states by PM2.5 concentration in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 2325,Report which state experienced the 2nd highest 75th percentile of PM10 throughout the Monsoon season of 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 2326,Identify the city with the 2nd lowest 25th percentile of PM2.5 in May 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 2327,"Plot the yearly average PM2.5 trends for Rajasthan, Uttar Pradesh, and Telangana from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Uttar Pradesh', 'Telangana'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Rajasthan vs Uttar Pradesh vs Telangana', width=550, height=320) return chart " 2328,"Over the past three years in Darbhanga, on which date was the PM10 level the lowest?"," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 3}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'Timestamp'}}] " 2329,Create a table showing PM2.5 spread (min to max) and central tendency per city for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2330,Report the station that had the highest 75th percentile of PM2.5 in April 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 2331,Show the monthly average PM10 trend for Hisar from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Hisar'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Hisar (2019–2024)', width=600, height=300) return chart " 2332,"On March 31, 2019, which city had the third-lowest 25th percentile for PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 2333,Report which state experienced the most minimal median PM10 throughout the Post-Monsoon season of 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 2334,"Create a grouped bar chart comparing the average PM2.5 for Jammu and Kashmir, Rajasthan, and Karnataka across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jammu and Kashmir', 'Rajasthan', 'Karnataka'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 2335,Which station had the 3rd lowest average PM10 in September 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 2336,Show the monthly average PM2.5 for Punjab across each year from 2017 to 2024 as small multiples (faceted by year).," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Punjab'].copy() df['Year'] = df['Timestamp'].dt.year df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5'), tooltip=['Year:O','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet( facet=alt.Facet('Year:O', title='Year'), columns=4 ).properties(title='Monthly PM2.5 in Punjab by Year (2017–2024)') return chart " 2337,"Scatter plot PM2.5 vs PM10 for Assam stations in 2019, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Assam') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Assam Stations 2019', width=450, height=350) " 2338,"Visualize the monthly average PM10 for Karnataka, Odisha, and Chandigarh in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Karnataka', 'Odisha', 'Chandigarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Karnataka, Odisha, UP – 2023', width=550, height=320) return chart " 2339,Which state shows the 3rd lowest standard deviation of PM10 concentration in relation to its population density?," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'std', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_capita', 'numerator': 'PM10', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'pm_per_capita', 'ascending': True}}] " 2340,Show the monthly average PM2.5 for Aizawl in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Aizawl') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Aizawl 2020', width=450, height=280) " 2341,Show how average PM10 varied month by month for Nagaland in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Nagaland'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2342,Plot the rolling 30-day average PM2.5 for Uttar Pradesh in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Uttar Pradesh') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Uttar Pradesh 2023', width=600, height=300) " 2343,Plot the rolling 30-day average PM2.5 for Gujarat in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Gujarat') & (data['Timestamp'].dt.year == 2020)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Gujarat 2020', width=600, height=300) " 2344,"Scatter plot PM2.5 vs PM10 for Jammu and Kashmir stations in 2018, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Jammu and Kashmir') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Jammu and Kashmir Stations 2018', width=450, height=350) " 2345,Which 10 states recorded the highest average PM10 levels in 2024? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 2346,"Report the state (excluding UTs) having the 3rd smallest population within the top 3 most polluted states, when pollution is measured by standard deviation of PM10 levels."," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'std', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 3, 'ret': 'state'}}] " 2347,Determine the state that recorded the 2nd most minimal 25th percentile of PM2.5 over the Monsoon season of 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 2348,"Plot the yearly average PM2.5 trends for West Bengal, Uttarakhand, and Tamil Nadu from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['West Bengal', 'Uttarakhand', 'Tamil Nadu'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: West Bengal vs Uttarakhand vs Tamil Nadu', width=550, height=320) return chart " 2349,Show a heatmap of average PM2.5 for the top 7 most polluted states by month for 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(7).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 7 Polluted States by Month (2021)', width=500, height=300) return chart " 2350,Determine the state exhibiting the 2nd highest 25th percentile of PM2.5 in January 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 2351,Identify the state that recorded the 2nd highest 75th percentile of PM10 value in July 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 2352,"Visualize the monthly average PM10 for Himachal Pradesh, Jammu and Kashmir, and Kerala in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Himachal Pradesh', 'Jammu and Kashmir', 'Kerala'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Himachal Pradesh, Jammu and Kashmir, UP – 2018', width=550, height=320) return chart " 2353,Tabulate average PM2.5 for each city in Andhra Pradesh across all months of 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Rajamahendravaram', 'Tirupati', 'Visakhapatnam']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2354,"Plot the yearly average PM2.5 trends for Haryana, Himachal Pradesh, and Tamil Nadu from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Himachal Pradesh', 'Tamil Nadu'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Haryana vs Himachal Pradesh vs Tamil Nadu', width=550, height=320) return chart " 2355,Generate a monthly average PM10 table for Madhya Pradesh for the year 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2356,Report which city possessed the third highest median PM2.5 throughout the Summer season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 2357,Plot the weekly average PM2.5 for Tirupur in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Tirupur') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Tirupur 2023', width=600, height=300) return chart " 2358,Identify the station that recorded the 3rd highest 25th percentile of PM10 value in May 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 2359,Tabulate average PM2.5 for each city in West Bengal across all months of 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'West Bengal'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Asansol', 'Durgapur', 'Haldia', 'Howrah', 'Kolkata', 'Siliguri']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2360,Identify the state with the highest average PM2.5 in February 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 2361,Create a heatmap showing the average PM2.5 by month (x-axis) and year (y-axis) for Haryana.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Haryana'].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Year:N', title='Year'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='Avg PM2.5'), tooltip=['Year:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Haryana (Month × Year)', width=500, height=280) return chart " 2362,"Considering all years, which September experienced the lowest 75th percentile for PM10 concentration?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'Timestamp'}}] " 2363,"Create a grouped bar chart comparing the average PM2.5 for Assam, Karnataka, and Delhi across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Assam', 'Karnataka', 'Delhi'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 2364,"Compare the monthly average PM2.5 of Chittorgarh, Kishanganj, and Vatva in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Chittorgarh', 'Kishanganj', 'Vatva'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Chittorgarh vs Kishanganj vs Vatva – 2023', width=550, height=320) return chart " 2365,Show how average PM2.5 varied month by month for Lucknow in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Lucknow'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2366,Tabulate average and median PM2.5 for all states in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2367,Which station had the 2nd highest median PM10 in February 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 2368,Plot the rolling 30-day average PM2.5 for Jharkhand in 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Jharkhand') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Jharkhand 2022', width=600, height=300) " 2369,"Show descriptive statistics of PM2.5 (mean, median, std, min, max) per city in 2023."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2370,"Create a grouped bar chart comparing the average PM2.5 for Uttar Pradesh, Mizoram, and Himachal Pradesh across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttar Pradesh', 'Mizoram', 'Himachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 2371,Determine the state with the 2nd lowest median PM2.5 in January 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 2372,List how many days each state breached the PM2.5 limit of 100 µg/m³ in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2373,"Identify the city that recorded the third highest PM2.5 level on January 27, 2021."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 2374,Create a ranked table of the 10 best-performing citys by PM10 in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 2375,Tabulate days with PM2.5 > 60 µg/m³ and exceedance percentage per state in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2376,Which city experienced the second least significant drop in its average PM10 levels between October and December 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 2377,"On August 15, 2022, which city experienced the minimum PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 2378,List the bottom 15 citys with the lowest average PM2.5 in 2021 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 2379,"Visualize the monthly average PM10 for Arunachal Pradesh, Maharashtra, and Uttarakhand in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Arunachal Pradesh', 'Maharashtra', 'Uttarakhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Arunachal Pradesh, Maharashtra, UP – 2018', width=550, height=320) return chart " 2380,"In October 2019, report the state with the 3rd highest median PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 2381,Determine the city that showed the peak median PM10 over the Monsoon season of 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 2382,List citys with their PM10 violation count and rate (>150 µg/m³) in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 150'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2383,Show a table of the top 5 citys by average PM2.5 in 2024 including their PM10 levels too.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 2384,Tabulate the yearly average PM2.5 trend for Meghalaya across all years.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Meghalaya'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2385,List average PM10 by month for Rajasthan in 2022 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2386,"Show the top 14 states by average PM10 in 2020 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2020] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(14, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 14 States by Average PM10 in 2020', width=500, height=300) return chart " 2387,Show a heatmap of average PM2.5 for the top 10 most polluted states by month for 2017.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(10).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 10 Polluted States by Month (2017)', width=500, height=300) return chart " 2388,Show the monthly average PM2.5 for Palwal in 2022 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Palwal ') & (data['Timestamp'].dt.year == 2022)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Palwal 2022', width=450, height=280) " 2389,"Create a grouped bar chart comparing the average PM2.5 for Meghalaya, Sikkim, and Gujarat across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Meghalaya', 'Sikkim', 'Gujarat'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 2390,Report the station that had the 2nd highest median PM10 in January 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 2391,Tabulate average PM10 for each city in Madhya Pradesh across all months of 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Bhopal', 'Damoh', 'Dewas', 'Gwalior', 'Indore', 'Jabalpur', 'Katni', 'Mandideep', 'Pithampur', 'Ratlam', 'Sagar', 'Satna', 'Singrauli', 'Ujjain']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2392,Determine the station with the 3rd lowest 25th percentile of PM10 in June 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 2393,Visualize the bottom 9 states with the lowest average PM2.5 in 2022 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2022] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(9, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 9 States by Average PM2.5 in 2022', width=500, height=300) return chart " 2394,"In 2019, which season (Winter, Summer, Monsoon, Post-Monsoon) corresponded to the highest median PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'season'}}] " 2395,Which state got the 4th lowest NCAP funding considering its 75th percentile of PM10 concentration in 2020 (FY 2019-20)?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2020_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 2396,"Report which station documented the second most minimal PM10 level on January 27, 2020."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 2397,Show the monthly average PM2.5 for Arrah in 2023 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Arrah') & (data['Timestamp'].dt.year == 2023)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Arrah 2023', width=450, height=280) " 2398,Create a month-wise PM2.5 breakdown table across cities in Karnataka for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Bagalkot', 'Belgaum', 'Bengaluru', 'Chamarajanagar', 'Chikkaballapur', 'Chikkamagaluru', 'Davanagere', 'Dharwad', 'Gadag', 'Hassan', 'Haveri', 'Hubballi', 'Kalaburagi', 'Koppal', 'Madikeri', 'Mangalore', 'Mysuru', 'Raichur', 'Ramanagara', 'Shivamogga', 'Tumakuru', 'Vijayapura', 'Yadgir']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2399,Tabulate the 20 citys with the least PM2.5 pollution in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 2400,"Create a faceted bar chart showing top 13 states by average PM2.5 per year for 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year.isin([2017,2018,2019,2020])].copy() df['Year'] = df['Timestamp'].dt.year agg = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() top = agg.groupby('Year').apply(lambda x: x.nlargest(13,'PM2.5')).reset_index(drop=True) chart = alt.Chart(top).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Avg PM2.5'), y=alt.Y('state:N', sort='-x'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet(facet='Year:O', columns=2).properties(title='Top 13 States by PM2.5 per Year') return chart " 2401,"In May 2020, report the city with the 2nd lowest 75th percentile of PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 2402,Show the monthly average PM10 trend for Chandigarh from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Chandigarh'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Chandigarh (2017–2022)', width=600, height=300) return chart " 2403,Show a heatmap of average PM2.5 for the top 11 most polluted states by month for 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(11).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 11 Polluted States by Month (2022)', width=500, height=300) return chart " 2404,Identify the city that recorded the 3rd highest 25th percentile of PM10 value in February 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 2405,Show a heatmap of average PM2.5 for the top 7 most polluted states by month for 2019.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(7).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 7 Polluted States by Month (2019)', width=500, height=300) return chart " 2406,What is the median PM2.5 value on Tuesdays in Himachal Pradesh?," [{'op': 'FILTER', 'params': {'field': 'state', 'value': 'Himachal Pradesh'}}] " 2407,How many times did Kerala surpass 75 µg/m³ of PM2.5 in 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 75.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 2408,Tabulate average PM2.5 for each city in Punjab across all months of 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Amritsar', 'Bathinda', 'Jalandhar', 'Khanna', 'Ludhiana', 'Mandi Gobindgarh', 'Patiala', 'Rupnagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2409,Identify the city with the lowest 75th percentile of PM2.5 for June 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 2410,Plot the rolling 30-day average PM2.5 for Arunachal Pradesh in 2019 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Arunachal Pradesh') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Arunachal Pradesh 2019', width=600, height=300) " 2411,Show the monthly average PM2.5 for Jhalawar in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Jhalawar') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Jhalawar 2020', width=450, height=280) " 2412,Determine the city exhibiting the 2nd highest average PM10 in November 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 2413,Tabulate the 5 worst states for average PM10 in 2023 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 2414,"Considering 2023, what day of the week had the third-highest 75th percentile of PM10 pollution levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'Timestamp'}}] " 2415,"Compare the monthly average PM2.5 of Faridabad, Nagaon, and Bileipada in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Faridabad', 'Nagaon', 'Bileipada'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Faridabad vs Nagaon vs Bileipada – 2024', width=550, height=320) return chart " 2416,"Considering all years, which May showed the lowest 75th percentile for PM10 concentration?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'Timestamp'}}] " 2417,Show a pivot table of monthly average PM10 by city for Rajasthan in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Ajmer', 'Alwar', 'Bhiwadi', 'Jaipur', 'Jodhpur', 'Kota', 'Pali', 'Udaipur']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2418,Show annual average PM2.5 for Himachal Pradesh as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Himachal Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2419,Which city registered the lowest 25th percentile of PM10 during November 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 2420,Tabulate daily PM10 exceedances (above 100 µg/m³) per state for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2421,"Compare the monthly average PM2.5 of Bharatpur, Mahad, and Cuttack in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Bharatpur', 'Mahad', 'Cuttack'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Bharatpur vs Mahad vs Cuttack – 2023', width=550, height=320) return chart " 2422,Show the monthly average PM2.5 for Rajgir in 2024 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Rajgir') & (data['Timestamp'].dt.year == 2024)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Rajgir 2024', width=450, height=280) " 2423,Which station had the 3rd lowest 25th percentile of PM2.5 in June 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 2424,Identify the city with the lowest NCAP funding considering its median PM2.5 concentration in 2020 (FY 2019-20).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2020_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 2425,Show a heatmap of average PM2.5 for the top 8 most polluted states by month for 2020.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(8).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2020)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 8 Polluted States by Month (2020)', width=500, height=300) return chart " 2426,"In June 2020, report the city with the 3rd lowest average PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 2427,"On March 31, 2024, which station had the second-highest average PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 2428,List the bottom 10 citys with the lowest average PM10 in 2021 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 2429,How many times did Gaya city go above the WHO guideline for PM10 in 2017?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 15.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 2430,Identify the city that recorded the 3rd lowest 75th percentile of PM2.5 value in January 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 2431,Which 20 states recorded the highest average PM10 levels in 2021? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 2432,"In 2022, which weekday experienced the third-highest median PM10 pollution concentrations?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'Timestamp'}}] " 2433,Show the monthly average PM2.5 for Latur in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Latur') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Latur 2018', width=450, height=280) " 2434,"In October 2019, identify the state with the 2nd lowest 75th percentile of PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 2435,Show how many times PM2.5 exceeded 60 µg/m³ per day across citys in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2436,Identify the station that registered the second-highest average PM2.5 in January 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 2437,"Show the top 9 states by average PM10 in 2017 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2017] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(9, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 9 States by Average PM10 in 2017', width=500, height=300) return chart " 2438,Show a pivot table of monthly average PM2.5 by city for Kerala in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Eloor', 'Kannur', 'Kochi', 'Kollam', 'Kozhikode', 'Thiruvananthapuram', 'Thrissur']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2439,Name the city with the second-lowest 25th percentile for PM10 in January 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 2440,"Plot the yearly average PM2.5 trends for Nagaland, Puducherry, and Haryana from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Nagaland', 'Puducherry', 'Haryana'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Nagaland vs Puducherry vs Haryana', width=550, height=320) return chart " 2441,"Visualize the monthly average PM10 for Arunachal Pradesh, Delhi, and Uttar Pradesh in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Arunachal Pradesh', 'Delhi', 'Uttar Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Arunachal Pradesh, Delhi, UP – 2021', width=550, height=320) return chart " 2442,Plot the distribution of PM2.5 values in Tripura across all years using a histogram.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Tripura'].dropna(subset=['PM2.5']) df = df[['PM2.5']] chart = alt.Chart(df).mark_bar(color='steelblue', opacity=0.75).encode( x=alt.X('PM2\.5:Q', bin=alt.Bin(maxbins=40), title='PM2.5 (µg/m³)'), y=alt.Y('count()', title='Number of Observations'), tooltip=[alt.Tooltip('PM2\.5:Q', bin=True), 'count()'] ).properties(title='PM2.5 Distribution – Tripura (All Years)', width=500, height=300) return chart " 2443,"Visualize the monthly average PM10 for Karnataka, Tripura, and Assam in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Karnataka', 'Tripura', 'Assam'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Karnataka, Tripura, UP – 2024', width=550, height=320) return chart " 2444,Show a cumulative area chart of PM2.5 readings for Sirohi across 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Sirohi') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Sirohi 2023', width=600, height=300) return chart " 2445,Visualize NCAP city-level funding for FY 2021-22 as a horizontal bar chart for the top 8 cities.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = ncap_funding_data[['city','state','Amount released during FY 2021-22']].copy() df.columns = ['city','state','Amount (Cr)'] df = df.nlargest(8, 'Amount (Cr)') df['City_State'] = df['city'] + ', ' + df['state'] chart = alt.Chart(df).mark_bar().encode( x=alt.X('Amount (Cr):Q', title='Amount Released (Cr)'), y=alt.Y('City_State:N', sort='-x', title='City, State'), color=alt.Color('state:N', title='State'), tooltip=['city:N','state:N', alt.Tooltip('Amount (Cr):Q', format='.1f')] ).properties(title='Top 8 Cities by NCAP Funding – FY 2021-22', width=500, height=400) return chart " 2446,"Which state registered the third-highest PM10 values on January 14, 2022?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 2447,Show a heatmap of average PM2.5 for the top 10 most polluted states by month for 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(10).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 10 Polluted States by Month (2018)', width=500, height=300) return chart " 2448,"Create a faceted bar chart showing top 8 states by average PM2.5 per year for 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year.isin([2021,2022,2023,2024])].copy() df['Year'] = df['Timestamp'].dt.year agg = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() top = agg.groupby('Year').apply(lambda x: x.nlargest(8,'PM2.5')).reset_index(drop=True) chart = alt.Chart(top).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Avg PM2.5'), y=alt.Y('state:N', sort='-x'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet(facet='Year:O', columns=2).properties(title='Top 8 States by PM2.5 per Year') return chart " 2449,Which state exhibited the third-most minimal 25th percentile of PM10 in July 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 2450,Tabulate the top 5 states for PM2.5 in 2024 along with their corresponding PM10 values.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 2451,Create a table with mean and standard deviation of PM10 by city in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2452,"Considering 2020, what week number displayed the second-lowest median PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'week'}}] " 2453,Show a table of average PM2.5 per state in 2024 along with population.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2454,Which state recorded the lowest median PM10 in June 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 2455,Which state showed the 3rd lowest 75th percentile of PM2.5 in the Monsoon season of 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 2456,"Show descriptive statistics of PM2.5 (mean, median, std, min, max) per city in 2020."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2457,Show a monthly breakdown table of average PM10 for Ghaziabad in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Ghaziabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2458,Report the state with the 2nd highest NCAP funding considering its 75th percentile of PM2.5 concentration in 2020 (FY 2019-20).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2020_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 2459,Create a table with mean and standard deviation of PM2.5 by city in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2460,"Taking all years into account, which January showed the third-lowest 75th percentile of PM2.5 levels?"," [{'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'Timestamp'}}] " 2461,Show a bar chart of the top 15 cities by median PM2.5 in 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2018] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(15, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 15 Cities by Median PM2.5 in 2018', width=500, height=300) return chart " 2462,"Create a grouped bar chart comparing the average PM2.5 for Gujarat, Arunachal Pradesh, and Himachal Pradesh across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Gujarat', 'Arunachal Pradesh', 'Himachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 2463,"Plot the yearly average PM2.5 trends for West Bengal, Sikkim, and Himachal Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['West Bengal', 'Sikkim', 'Himachal Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: West Bengal vs Sikkim vs Himachal Pradesh', width=550, height=320) return chart " 2464,Create a statistical summary table of PM2.5 readings by city for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2465,Which city noted the maximum average PM10 level?," [{'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 2466,Create a month-by-state breakdown table of mean PM2.5 for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Bihar', 'Delhi', 'Gujarat', 'Haryana', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2467,Show a monthly breakdown table of average PM10 for Kerala in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2468,Show the number of days each city exceeded a PM2.5 threshold of 100 µg/m³ in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2469,"Comparing December 2023 to October 2023, which city showed the least significant drop in 25th percentile PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 2470,Which city showed the highest 75th percentile of PM10 in September 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 2471,Show the monthly average PM10 trend for Dindigul from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Dindigul'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Dindigul (2019–2024)', width=600, height=300) return chart " 2472,"Considering 2020, what season (Winter, Summer, Monsoon, Post-Monsoon) displayed the second-lowest median PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'season'}}] " 2473,"On January 14, 2023, which state had the highest PM10 readings?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 2474,Create a summary table ranking the top 5 citys by PM2.5 concentration in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 2475,Which 15 states had the lowest mean PM2.5 in 2024? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 2476,Plot the weekly average PM2.5 for Vijayawada in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Vijayawada') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Vijayawada 2023', width=600, height=300) return chart " 2477,Show how many times PM2.5 exceeded 100 µg/m³ per day across citys in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2478,List the top 10 citys by average PM10 in 2019 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 2479,Which station recorded the 3rd lowest 75th percentile of PM10 in December 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 2480,"Create a grouped bar chart comparing the average PM2.5 for Chandigarh, Haryana, and Jammu and Kashmir across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chandigarh', 'Haryana', 'Jammu and Kashmir'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 2481,Create a table of PM10 standard violations (>150 µg/m³) per city in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2482,"Show a table of average PM2.5, population, and area for all states in 2023."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': { 'map': { 'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2483,Show NCAP total funds and utilisation percentage per state as a table.," [ {'op': 'SOURCE', 'params': {'table': 'ncap'}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Total Fund (Cr)', 'col': 'Total fund released', 'fn': 'sum'}, {'alias': 'Utilised (Cr)', 'col': 'Utilisation as on June 2022', 'fn': 'sum'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': {'denominator': 'Total Fund (Cr)', 'new_col': 'Utilisation %', 'numerator': 'Utilised (Cr)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Total Fund (Cr)'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2484,"Create a faceted bar chart showing top 6 states by average PM2.5 per year for 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year.isin([2017,2018,2019,2020])].copy() df['Year'] = df['Timestamp'].dt.year agg = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() top = agg.groupby('Year').apply(lambda x: x.nlargest(6,'PM2.5')).reset_index(drop=True) chart = alt.Chart(top).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Avg PM2.5'), y=alt.Y('state:N', sort='-x'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet(facet='Year:O', columns=2).properties(title='Top 6 States by PM2.5 per Year') return chart " 2485,Create a grouped bar chart comparing the average PM2.5 in Winter vs Summer for the top 12 most polluted states.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top6 = data.groupby('state')['PM2.5'].mean().nlargest(12).index.tolist() df = data[data['state'].isin(top6)].copy() df['Season'] = df['Timestamp'].dt.month.apply( lambda m: 'Winter' if m in [12,1,2] else ('Summer' if m in [3,4,5] else None)) df = df.dropna(subset=['Season']) df = df.groupby(['state','Season'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('state:N', title='State'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('Season:N', title='Season'), xOffset='Season:N', tooltip=['state:N','Season:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Winter vs Summer PM2.5 – Top 12 Polluted States', width=550, height=320) return chart " 2486,Show the monthly average PM2.5 for Himachal Pradesh across each year from 2017 to 2024 as small multiples (faceted by year).," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Himachal Pradesh'].copy() df['Year'] = df['Timestamp'].dt.year df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5'), tooltip=['Year:O','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet( facet=alt.Facet('Year:O', title='Year'), columns=4 ).properties(title='Monthly PM2.5 in Himachal Pradesh by Year (2017–2024)') return chart " 2487,Which state showed the highest 75th percentile of PM10 in August 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 2488,Create a month-wise summary of average PM10 for Himachal Pradesh in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Himachal Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2489,Create a month-by-state breakdown table of mean PM2.5 for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Delhi', 'Gujarat', 'Haryana', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2490,Show PM10 exceedance count and rate (%) above 100 µg/m³ per city in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2491,Which city possessed the 3rd lowest average for PM10 in the Winter season of 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 2492,"Plot the yearly average PM2.5 trends for Himachal Pradesh, Chhattisgarh, and Himachal Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Himachal Pradesh', 'Chhattisgarh', 'Himachal Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Himachal Pradesh vs Chhattisgarh vs Himachal Pradesh', width=550, height=320) return chart " 2493,Tabulate the yearly average PM10 trend for Nashik across all years.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Nashik'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2494,Create a table with mean and standard deviation of PM10 by city in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2495,Show PM10 exceedance count and rate (%) above 100 µg/m³ per city in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2496,Generate a dual-pollutant summary table (PM2.5 and PM10) by state for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2497,Show a table of the 15 cleanest citys by average PM10 in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 2498,Report the station with the 2nd lowest 75th percentile of PM10 in June 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 2499,Plot the top 15 states by average PM2.5 in 2017 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2017] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(15, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 15 States by Average PM2.5 in 2017', width=500, height=300) return chart " 2500,Show the monthly average PM2.5 for Bhilai in 2023 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bhilai') & (data['Timestamp'].dt.year == 2023)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Bhilai 2023', width=450, height=280) " 2501,"Create a scatter plot of PM2.5 vs PM10 for all stations in 2023, colored by state."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2023] df = df.groupby(['station','state'])[['PM2.5','PM10']].mean().reset_index().dropna() chart = alt.Chart(df).mark_point(opacity=0.6, size=60).encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['station:N','state:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='PM2.5 vs PM10 by Station – 2023', width=500, height=400) return chart " 2502,Show a monthly breakdown table of average PM10 for Rajasthan in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2503,Show a cumulative area chart of PM2.5 readings for Chittorgarh across 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Chittorgarh') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Chittorgarh 2023', width=600, height=300) return chart " 2504,"Within the last two years in Asansol, on what date was the PM10 level the lowest?"," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 2}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'Timestamp'}}] " 2505,Report which station registered the 2nd highest median PM10 throughout the Post-Monsoon season of 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 2506,"Create a scatter plot of PM2.5 vs PM10 for all stations in 2017, colored by state."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2017] df = df.groupby(['station','state'])[['PM2.5','PM10']].mean().reset_index().dropna() chart = alt.Chart(df).mark_point(opacity=0.6, size=60).encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['station:N','state:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='PM2.5 vs PM10 by Station – 2017', width=500, height=400) return chart " 2507,Find the city that was second in terms of highest average PM10 for July 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 2508,Show a cumulative area chart of PM2.5 readings for Shillong across 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Shillong') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Shillong 2024', width=600, height=300) return chart " 2509,List the average PM10 for Agra broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Agra'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2510,"Create a faceted bar chart showing top 7 states by average PM2.5 per year for 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year.isin([2021,2022,2023,2024])].copy() df['Year'] = df['Timestamp'].dt.year agg = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() top = agg.groupby('Year').apply(lambda x: x.nlargest(7,'PM2.5')).reset_index(drop=True) chart = alt.Chart(top).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Avg PM2.5'), y=alt.Y('state:N', sort='-x'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet(facet='Year:O', columns=2).properties(title='Top 7 States by PM2.5 per Year') return chart " 2511,"Visualize the monthly average PM10 for Sikkim, Karnataka, and Mizoram in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Sikkim', 'Karnataka', 'Mizoram'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Sikkim, Karnataka, UP – 2024', width=550, height=320) return chart " 2512,"Plot the yearly average PM2.5 trends for Assam, Uttarakhand, and Gujarat from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Assam', 'Uttarakhand', 'Gujarat'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Assam vs Uttarakhand vs Gujarat', width=550, height=320) return chart " 2513,Which state had the 2nd highest average PM2.5 in September 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 2514,"Create a grouped bar chart comparing the average PM2.5 for Uttarakhand, Bihar, and Tripura across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttarakhand', 'Bihar', 'Tripura'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 2515,"Visualize the monthly average PM10 for Nagaland, Bihar, and Andhra Pradesh in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Nagaland', 'Bihar', 'Andhra Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Nagaland, Bihar, UP – 2022', width=550, height=320) return chart " 2516,Which station registered the second-highest PM2.5 levels during the COVID-19 lockdown in April 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 2517,Create a table showing annual mean PM2.5 levels for Gujarat (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Gujarat'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2518,List the bottom 20 states with the lowest average PM2.5 in 2023 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 2519,Create a summary table ranking the top 5 states by PM2.5 concentration in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 2520,Show a monthly bar chart of the number of days Karnataka exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Karnataka') & (data['Timestamp'].dt.year == 2021)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Karnataka Exceeded WHO PM2.5 Guideline per Month – 2021', width=500, height=300) return chart " 2521,"Compare the monthly average PM2.5 of Gummidipoondi, Vatva, and Kashipur in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Gummidipoondi', 'Vatva', 'Kashipur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Gummidipoondi vs Vatva vs Kashipur – 2019', width=550, height=320) return chart " 2522,"Plot the yearly average PM2.5 trends for Odisha, Arunachal Pradesh, and Gujarat from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Odisha', 'Arunachal Pradesh', 'Gujarat'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Odisha vs Arunachal Pradesh vs Gujarat', width=550, height=320) return chart " 2523,"In the year 2021, which season (Winter, Summer, Monsoon, Post-Monsoon) recorded the third-lowest 75th percentile for PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'season'}}] " 2524,Create a ranked table of the 15 best-performing citys by PM10 in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 2525,Generate a city × month cross-tab of mean PM2.5 for Haryana in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Haryana'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Ambala', 'Bahadurgarh', 'Ballabgarh', 'Bhiwani', 'Dharuhera', 'Faridabad', 'Fatehabad', 'Gurugram', 'Hisar', 'Jind', 'Kaithal', 'Karnal', 'Kurukshetra', 'Mandikhera', 'Manesar', 'Narnaul', 'Palwal', 'Panchkula', 'Panipat', 'Rohtak', 'Sirsa', 'Sonipat', 'Yamuna Nagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2526,How many stations in Arunachal Pradesh surpassed 90 µg/m³ of PM2.5 in the year 2017?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 90.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 2527,List all states with the total NCAP funds they received.," [ {'op': 'SOURCE', 'params': {'table': 'ncap'}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'Total fund released', 'fn': 'sum'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Total fund released'}}, {'op': 'RENAME', 'params': {'map': {'Total fund released': 'Total Fund Released (Cr)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2528,Create a summary table comparing mean PM2.5 and PM10 across citys in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2529,"Create a grouped bar chart comparing the average PM2.5 for Punjab, Rajasthan, and Kerala across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Punjab', 'Rajasthan', 'Kerala'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 2530,Generate a city × month cross-tab of mean PM2.5 for Madhya Pradesh in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Dewas', 'Mandideep', 'Pithampur', 'Singrauli', 'Ujjain']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2531,Identify the city with the second lowest PM2.5 level on 27 January 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 2532,Show the number of days each city exceeded a PM10 threshold of 100 µg/m³ in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2533,List average PM10 by month for Asansol in 2019 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Asansol'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2534,Show a cumulative area chart of PM2.5 readings for Kannur across 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Kannur') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Kannur 2023', width=600, height=300) return chart " 2535,Show a bar chart of the top 6 cities by median PM2.5 in 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2024] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(6, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 6 Cities by Median PM2.5 in 2024', width=500, height=300) return chart " 2536,Create a month-wise PM2.5 breakdown table across cities in West Bengal for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'West Bengal'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Asansol', 'Howrah', 'Kolkata', 'Siliguri']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2537,"Plot the yearly average PM2.5 trends for Punjab, Haryana, and Andhra Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Punjab', 'Haryana', 'Andhra Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Punjab vs Haryana vs Andhra Pradesh', width=550, height=320) return chart " 2538,Create a month-wise PM2.5 breakdown table across cities in Uttar Pradesh for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Agra', 'Bulandshahr', 'Ghaziabad', 'Greater Noida', 'Hapur', 'Kanpur', 'Lucknow', 'Meerut', 'Moradabad', 'Muzaffarnagar', 'Noida', 'Varanasi']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2539,"Compare the monthly average PM2.5 of Mysuru, Rishikesh, and Chandrapur in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Mysuru', 'Rishikesh', 'Chandrapur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Mysuru vs Rishikesh vs Chandrapur – 2022', width=550, height=320) return chart " 2540,Create a table showing PM2.5 spread (min to max) and central tendency per state for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2541,"Compare the monthly average PM2.5 of Kadapa, Jorapokhar, and Kadapa in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Kadapa', 'Jorapokhar', 'Kadapa'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Kadapa vs Jorapokhar vs Kadapa – 2023', width=550, height=320) return chart " 2542,Which 15 states recorded the highest average PM2.5 levels in 2020? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 2543,Which 5 states had the lowest mean PM10 in 2023? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 2544,Determine the station that showed the 2nd lowest average PM10 over the Post-Monsoon season of 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 2545,Generate a city × month cross-tab of mean PM2.5 for Haryana in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Haryana'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Ambala', 'Bahadurgarh', 'Ballabgarh', 'Bhiwani', 'Dharuhera', 'Faridabad', 'Fatehabad', 'Gurugram', 'Hisar', 'Jind', 'Karnal', 'Kurukshetra', 'Manesar', 'Narnaul', 'Palwal', 'Panchkula', 'Panipat', 'Rohtak', 'Sirsa', 'Sonipat', 'Yamuna Nagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2546,"Compare the monthly average PM2.5 of Faridabad, Shivamogga, and Chennai in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Faridabad', 'Shivamogga', 'Chennai'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Faridabad vs Shivamogga vs Chennai – 2022', width=550, height=320) return chart " 2547,"Create a grouped bar chart comparing the average PM2.5 for Tamil Nadu, Meghalaya, and Bihar across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Meghalaya', 'Bihar'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 2548,Generate a table showing the 5 most polluted citys based on mean PM2.5 for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 2549,Plot the weekly average PM2.5 for Dindigul in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Dindigul') & (data['Timestamp'].dt.year == 2024)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Dindigul 2024', width=600, height=300) return chart " 2550,Show a monthly breakdown table of average PM10 for Solapur in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Solapur'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2551,Show the monthly average PM10 trend for Satna from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Satna'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Satna (2019–2024)', width=600, height=300) return chart " 2552,Tabulate average PM10 for each city in Rajasthan across all months of 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Ajmer', 'Alwar', 'Bhiwadi', 'Jaipur', 'Jodhpur', 'Kota', 'Pali', 'Udaipur']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2553,Determine the city that recorded the 3rd highest 25th percentile of PM10 over the Monsoon season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 2554,Show a cumulative area chart of PM2.5 readings for Manesar across 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Manesar') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Manesar 2022', width=600, height=300) return chart " 2555,Tabulate days with PM10 > 150 µg/m³ and exceedance percentage per city in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 150'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2556,"Visualize the monthly average PM10 for Andhra Pradesh, Chhattisgarh, and Chandigarh in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Chhattisgarh', 'Chandigarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Andhra Pradesh, Chhattisgarh, UP – 2024', width=550, height=320) return chart " 2557,Show the monthly average PM2.5 for Brajrajnagar in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Brajrajnagar') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Brajrajnagar 2019', width=450, height=280) " 2558,Identify the station that showed the peak average PM2.5 during the Summer season of 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 2559,Show the monthly average PM10 trend for Palkalaiperur from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Palkalaiperur'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Palkalaiperur (2019–2024)', width=600, height=300) return chart " 2560,Tabulate the 20 worst citys for average PM10 in 2018 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 2561,Show annual average PM2.5 for Hyderabad as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Hyderabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2562,"Show descriptive statistics of PM10 (mean, median, std, min, max) per city in 2019."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2563,Which city recorded the 2nd highest average PM10 in September 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 2564,Generate a city × month cross-tab of mean PM10 for Rajasthan in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Ajmer', 'Alwar', 'Bhiwadi', 'Jaipur', 'Jodhpur', 'Kota', 'Pali', 'Udaipur']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2565,"Visualize the monthly average PM10 for West Bengal, Madhya Pradesh, and Jammu and Kashmir in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['West Bengal', 'Madhya Pradesh', 'Jammu and Kashmir'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: West Bengal, Madhya Pradesh, UP – 2019', width=550, height=320) return chart " 2566,Tabulate the 20 worst citys for average PM10 in 2019 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 2567,"Taking all years into account, which August had the second-lowest 25th percentile for PM10 levels?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'Timestamp'}}] " 2568,"Create a grouped bar chart comparing the average PM2.5 for Uttarakhand, Himachal Pradesh, and Himachal Pradesh across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttarakhand', 'Himachal Pradesh', 'Himachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 2569,"Compare the monthly average PM2.5 of Brajrajnagar, Nagapattinam, and Nanded in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Brajrajnagar', 'Nagapattinam', 'Nanded'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Brajrajnagar vs Nagapattinam vs Nanded – 2022', width=550, height=320) return chart " 2570,"Visualize the monthly average PM10 for Punjab, Bihar, and Gujarat in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Punjab', 'Bihar', 'Gujarat'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Punjab, Bihar, UP – 2022', width=550, height=320) return chart " 2571,"Plot the yearly average PM2.5 trends for Gujarat, West Bengal, and Haryana from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Gujarat', 'West Bengal', 'Haryana'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Gujarat vs West Bengal vs Haryana', width=550, height=320) return chart " 2572,Create a ranked table of the 20 best-performing states by PM2.5 in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 2573,Show a monthly breakdown table of average PM10 for Jammu and Kashmir in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Jammu and Kashmir'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2574,List the average PM2.5 for Solapur broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Solapur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2575,Create a table of PM10 exceedance frequency above 150 µg/m³ by state for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 150'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2576,Show the monthly average PM2.5 for Visakhapatnam in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Visakhapatnam') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Visakhapatnam 2020', width=450, height=280) " 2577,List the average PM10 for Gwalior broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Gwalior'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2578,Show a table of the top 15 states by average PM2.5 in 2021 including their PM10 levels too.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 2579,Which 5 citys had the lowest mean PM2.5 in 2022? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 2580,How many times did Mahad city surpass the Indian guideline for PM10 in 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 60.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 2581,Show a cumulative area chart of PM2.5 readings for Dharwad across 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Dharwad') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Dharwad 2023', width=600, height=300) return chart " 2582,"Create a table of NCAP funds released in FY 2019-20, 2020-21, and 2021-22 by state."," [ {'op': 'SOURCE', 'params': {'table': 'ncap'}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ { 'alias': 'FY 2019-20 (Cr)', 'col': 'Amount released during FY 2019-20', 'fn': 'sum'}, { 'alias': 'FY 2020-21 (Cr)', 'col': 'Amount released during FY 2020-21', 'fn': 'sum'}, { 'alias': 'FY 2021-22 (Cr)', 'col': 'Amount released during FY 2021-22', 'fn': 'sum'}, {'alias': 'Total (Cr)', 'col': 'Total fund released', 'fn': 'sum'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Total (Cr)'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2583,"Create a grouped bar chart comparing the average PM2.5 for Uttar Pradesh, Arunachal Pradesh, and Jammu and Kashmir across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttar Pradesh', 'Arunachal Pradesh', 'Jammu and Kashmir'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 2584,Tabulate average PM10 for each state across all months in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Arunachal Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Chhattisgarh', 'Delhi', 'Gujarat', 'Haryana', 'Himachal Pradesh', 'Jammu and Kashmir', 'Jharkhand', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Meghalaya', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Sikkim', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh', 'Uttarakhand', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2585,Generate a dual-pollutant summary table (PM2.5 and PM10) by state for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2586,List the bottom 10 states with the lowest average PM10 in 2018 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 2587,Report which city experienced the third highest median PM2.5 throughout the Monsoon season of 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 2588,Visualize the bottom 9 states with the lowest average PM2.5 in 2020 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2020] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(9, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 9 States by Average PM2.5 in 2020', width=500, height=300) return chart " 2589,Report the city with the highest NCAP funding considering its 25th percentile of PM10 concentration in 2021 (FY 2020-21).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 2590,"Compare the monthly average PM2.5 of Jalgaon, Naharlagun, and Talcher in 2020 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Jalgaon', 'Naharlagun', 'Talcher'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2020)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Jalgaon vs Naharlagun vs Talcher – 2020', width=550, height=320) return chart " 2591,"Create a grouped bar chart comparing the average PM2.5 for Gujarat, Telangana, and West Bengal across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Gujarat', 'Telangana', 'West Bengal'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 2592,Which city registered the 2nd highest median PM2.5 during December 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 2593,Show a ranked table of the 10 most polluted states by average PM10 in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 2594,Tabulate the top 15 citys for PM2.5 in 2020 along with their corresponding PM10 values.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 2595,Show annual average PM2.5 for Nashik as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Nashik'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2596,Generate a year-by-year summary table of PM10 readings for Solapur.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Solapur'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2597,Show a pivot table of monthly average PM2.5 by city for Haryana in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Haryana'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Ambala', 'Bahadurgarh', 'Ballabgarh', 'Bhiwani', 'Charkhi Dadri', 'Dharuhera', 'Faridabad', 'Fatehabad', 'Gurugram', 'Hisar', 'Jind', 'Kaithal', 'Karnal', 'Kurukshetra', 'Mandikhera', 'Manesar', 'Narnaul', 'Palwal', 'Panchkula', 'Rohtak', 'Sirsa', 'Sonipat', 'Yamuna Nagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2598,Report the state with the 2nd highest average PM2.5 in May 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 2599,What count of Tamil Nadu stations went above 45 µg/m³ of PM10 in 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 45.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 2600,Which state registered the 2nd minimum average PM10 during the Summer season of 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 2601,"Create a grouped bar chart comparing the average PM2.5 for Chandigarh, Manipur, and Karnataka across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chandigarh', 'Manipur', 'Karnataka'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 2602,"Compare the monthly average PM2.5 of Begusarai, Jorapokhar, and Kolar in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Begusarai', 'Jorapokhar', 'Kolar'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Begusarai vs Jorapokhar vs Kolar – 2024', width=550, height=320) return chart " 2603,Create a table showing PM2.5 spread (min to max) and central tendency per city for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2604,"Show a box plot of PM10 for each season (Winter, Summer, Monsoon, Post-Monsoon) for all of India."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): def season(m): if m in [12,1,2]: return 'Winter' elif m in [3,4,5]: return 'Summer' elif m in [6,7,8,9]: return 'Monsoon' else: return 'Post-Monsoon' df = data.dropna(subset=['PM10']).copy() df['Season'] = df['Timestamp'].dt.month.apply(season) df = df[['Season','PM10']] order = ['Winter','Post-Monsoon','Summer','Monsoon'] chart = alt.Chart(df).mark_boxplot(extent='min-max').encode( x=alt.X('Season:N', sort=order, title='Season'), y=alt.Y('PM10:Q', title='PM10 (µg/m³)'), color=alt.Color('Season:N', legend=None) ).properties(title='PM10 Distribution by Season – India', width=450, height=320) return chart " 2605,Show PM10 exceedance count and rate (%) above 150 µg/m³ per state in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 150'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2606,"For 2019, which weekday experienced the second-lowest average PM2.5 pollution levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'Timestamp'}}] " 2607,Identify the city that registered the third lowest average for PM2.5 during the Winter season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 2608,"On March 31, 2023, which station recorded the second-lowest average PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 2609,Which 10 states recorded the highest average PM10 levels in 2019? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 2610,Show a monthly bar chart of the number of days Gujarat exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Gujarat') & (data['Timestamp'].dt.year == 2022)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Gujarat Exceeded WHO PM2.5 Guideline per Month – 2022', width=500, height=300) return chart " 2611,"Tabulate PM10 statistics (mean, std, min, max) for each state in 2018."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'q25', 'median', 'q75']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2612,What count of Andhra Pradesh stations exceeded 30 µg/m³ of PM10 in 2017?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 30.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 2613,Which city was second in terms of highest average PM2.5 for December 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 2614,Identify the station with the second-lowest 75th percentile for PM2.5 in December 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 2615,"Show mean, median, minimum, and maximum PM10 for each state in 2024 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2616,Create a month-wise PM2.5 breakdown table across cities in Maharashtra for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Aurangabad', 'Chandrapur', 'Nagpur', 'Nashik', 'Thane']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2617,Determine the state exhibiting the 2nd lowest median PM2.5 in November 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 2618,Identify the state that received the 4th lowest NCAP funding relative to the standard deviation of its PM2.5 concentration in 2022 (FY 2021-22).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'std', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2022_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 2619,"Considering all years, which August registered the second-highest average PM10 levels?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'Timestamp'}}] " 2620,Tabulate the monthly mean PM10 levels for Bhilai during 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Bhilai'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2621,Show a table of the 10 cleanest citys by average PM2.5 in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 2622,Show a monthly bar chart of the number of days Arunachal Pradesh exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Arunachal Pradesh') & (data['Timestamp'].dt.year == 2023)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Arunachal Pradesh Exceeded WHO PM2.5 Guideline per Month – 2023', width=500, height=300) return chart " 2623,"On January 27, 2018, which station documented the second highest PM2.5 level?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 2624,Show the monthly average PM2.5 for Hanumangarh in 2024 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Hanumangarh') & (data['Timestamp'].dt.year == 2024)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Hanumangarh 2024', width=450, height=280) " 2625,"Over the past four years in Rajsamand, on which date was the PM2.5 level the second highest?"," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 4}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'Timestamp'}}] " 2626,"In July 2021, which state recorded the lowest 25th percentile of PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 2627,Show a monthly bar chart of the number of days Chhattisgarh exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Chhattisgarh') & (data['Timestamp'].dt.year == 2022)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Chhattisgarh Exceeded WHO PM2.5 Guideline per Month – 2022', width=500, height=300) return chart " 2628,Show the monthly average PM2.5 for Aurangabad in 2024 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Aurangabad') & (data['Timestamp'].dt.year == 2024)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Aurangabad 2024', width=450, height=280) " 2629,Show the monthly average PM2.5 for Vijayawada in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Vijayawada') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Vijayawada 2018', width=450, height=280) " 2630,Which state recorded the third-highest median PM2.5 concentration in December 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 2631,Generate a city × month cross-tab of mean PM2.5 for Odisha in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Odisha'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Brajrajnagar', 'Talcher']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2632,"Plot the yearly average PM2.5 trends for Mizoram, Puducherry, and Kerala from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Mizoram', 'Puducherry', 'Kerala'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Mizoram vs Puducherry vs Kerala', width=550, height=320) return chart " 2633,Create a statistical summary table of PM10 readings by city for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2634,"Plot the yearly average PM2.5 trends for Gujarat, Karnataka, and Bihar from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Gujarat', 'Karnataka', 'Bihar'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Gujarat vs Karnataka vs Bihar', width=550, height=320) return chart " 2635,Tabulate average PM2.5 for each city in Rajasthan across all months of 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Ajmer', 'Alwar', 'Bhiwadi', 'Jaipur', 'Jodhpur', 'Kota', 'Pali', 'Udaipur']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2636,Identify the city that recorded the 3rd highest median PM2.5 value in June 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 2637,List how many days each city breached the PM2.5 limit of 60 µg/m³ in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2638,Identify the city that recorded the highest 25th percentile of PM2.5 value in September 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 2639,Show a monthly bar chart of the number of days Odisha exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2017.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Odisha') & (data['Timestamp'].dt.year == 2017)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Odisha Exceeded WHO PM2.5 Guideline per Month – 2017', width=500, height=300) return chart " 2640,Create a table showing PM10 spread (min to max) and central tendency per state for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2641,Determine the city showing the highest 75th percentile of PM10 for April 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 2642,Determine the state that has the lowest average PM2.5 concentration relative to its population density.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_capita', 'numerator': 'PM2.5', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'pm_per_capita', 'ascending': True}}] " 2643,"Compare the monthly average PM2.5 of Kannur, Gummidipoondi, and Koppal in 2020 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Kannur', 'Gummidipoondi', 'Koppal'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2020)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Kannur vs Gummidipoondi vs Koppal – 2020', width=550, height=320) return chart " 2644,Plot the rolling 30-day average PM2.5 for West Bengal in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'West Bengal') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – West Bengal 2023', width=600, height=300) " 2645,"Compare the monthly average PM2.5 of Indore, Bhilai, and Varanasi in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Indore', 'Bhilai', 'Varanasi'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Indore vs Bhilai vs Varanasi – 2017', width=550, height=320) return chart " 2646,"Plot the yearly average PM2.5 trends for Haryana, Uttarakhand, and Karnataka from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Uttarakhand', 'Karnataka'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Haryana vs Uttarakhand vs Karnataka', width=550, height=320) return chart " 2647,"Report the union territory having the largest population among the top 2 most polluted union territories, when pollution is measured by average PM2.5 levels."," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 2, 'ret': 'state'}}] " 2648,Generate a table showing the 10 most polluted states based on mean PM10 for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 2649,Show a cumulative area chart of PM2.5 readings for Panipat across 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Panipat') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Panipat 2023', width=600, height=300) return chart " 2650,"Plot the yearly average PM2.5 trends for Sikkim, Chhattisgarh, and Karnataka from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Sikkim', 'Chhattisgarh', 'Karnataka'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Sikkim vs Chhattisgarh vs Karnataka', width=550, height=320) return chart " 2651,Show how many times PM10 exceeded 100 µg/m³ per day across states in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2652,"Plot the yearly average PM2.5 trends for Jharkhand, Tamil Nadu, and Uttar Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Tamil Nadu', 'Uttar Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Jharkhand vs Tamil Nadu vs Uttar Pradesh', width=550, height=320) return chart " 2653,"Create a grouped bar chart comparing the average PM2.5 for Chhattisgarh, Delhi, and Assam across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chhattisgarh', 'Delhi', 'Assam'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 2654,Tabulate population-adjusted PM10 levels for each state in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM10 per million', 'numerator': 'PM10', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'PM10 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2655,"Show descriptive statistics of PM2.5 (mean, median, std, min, max) per state in 2020."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2656,Plot the rolling 30-day average PM2.5 for Haryana in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Haryana') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Haryana 2023', width=600, height=300) " 2657,Show the monthly average PM2.5 for Dharwad in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Dharwad') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Dharwad 2020', width=450, height=280) " 2658,Show the monthly average PM2.5 for Mandi Gobindgarh in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Mandi Gobindgarh') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Mandi Gobindgarh 2020', width=450, height=280) " 2659,Generate a descriptive stats table for PM10 grouped by state in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2660,Report the station with the 3rd lowest 25th percentile of PM2.5 in December 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 2661,"Visualize the monthly average PM10 for Jammu and Kashmir, Haryana, and Himachal Pradesh in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jammu and Kashmir', 'Haryana', 'Himachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Jammu and Kashmir, Haryana, UP – 2024', width=550, height=320) return chart " 2662,Show the monthly average PM10 trend for Rairangpur from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Rairangpur'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Rairangpur (2017–2022)', width=600, height=300) return chart " 2663,"Visualize the monthly average PM10 for West Bengal, Kerala, and Tripura in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['West Bengal', 'Kerala', 'Tripura'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: West Bengal, Kerala, UP – 2018', width=550, height=320) return chart " 2664,Plot the rolling 30-day average PM2.5 for Bihar in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Bihar') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Bihar 2023', width=600, height=300) " 2665,"Plot the yearly average PM2.5 trends for Punjab, Haryana, and Chandigarh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Punjab', 'Haryana', 'Chandigarh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Punjab vs Haryana vs Chandigarh', width=550, height=320) return chart " 2666,"Which union territory has the 2nd minimum land area among the top 4 most polluted union territories, according to average PM2.5 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 4, 'ret': 'state'}}] " 2667,Create a ranked table of the 15 best-performing citys by PM2.5 in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 2668,Tabulate the 20 worst states for average PM10 in 2023 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 2669,"Create a grouped bar chart comparing the average PM2.5 for Uttar Pradesh, Chhattisgarh, and Haryana across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttar Pradesh', 'Chhattisgarh', 'Haryana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 2670,Show a table of the 15 cleanest citys by average PM10 in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 2671,Show the PM2.5 per 1000 km² (air quality density) for each state in 2019 as a bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): pm = data[data['Timestamp'].dt.year == 2019].groupby('state')['PM2.5'].mean().reset_index().dropna() df = pm.merge(states_data[['state','area (km2)']], on='state') df['PM2.5 per 1000 km²'] = df['PM2.5'] / df['area (km2)'] * 1000 df = df.sort_values('PM2.5 per 1000 km²', ascending=False) chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5 per 1000 km²:Q', title='PM2.5 per 1000 km²'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5 per 1000 km²:Q', scale=alt.Scale(scheme='orangered'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5 per 1000 km²:Q', format='.3f')] ).properties(title='Air Quality Density (PM2.5 per 1000 km²) by State – 2019', width=500, height=400) return chart " 2672,Identify the state that was second in terms of highest average PM2.5 for April 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 2673,"Compare the monthly average PM2.5 of Agartala, Rishikesh, and Muzaffarpur in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Agartala', 'Rishikesh', 'Muzaffarpur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Agartala vs Rishikesh vs Muzaffarpur – 2022', width=550, height=320) return chart " 2674,"Create a grouped bar chart comparing the average PM2.5 for Uttar Pradesh, Himachal Pradesh, and Nagaland across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttar Pradesh', 'Himachal Pradesh', 'Nagaland'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 2675,Find the state with the highest 75th percentile for PM2.5 in February 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 2676,How many stations in Tamil Nadu went above 30 µg/m³ of PM10 in the year 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 30.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 2677,Which 10 citys had the lowest mean PM10 in 2024? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 2678,Show a ranked table of the 10 most polluted states by average PM2.5 in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 2679,Which 20 states recorded the highest average PM10 levels in 2018? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 2680,Which city got the 5th lowest NCAP funding considering its total PM10 concentration in 2020 (FY 2019-20)?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'sum', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2020_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 2681,"Scatter plot PM2.5 vs PM10 for Delhi stations in 2023, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Delhi') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Delhi Stations 2023', width=450, height=350) " 2682,"In December 2023, which state recorded the 2nd highest average PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 2683,"Create a grouped bar chart comparing the average PM2.5 for Gujarat, Bihar, and Haryana across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Gujarat', 'Bihar', 'Haryana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 2684,Generate a year-by-year summary table of PM2.5 readings for Uttar Pradesh.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2685,Show a heatmap of average PM2.5 for the top 13 most polluted states by month for 2017.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(13).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 13 Polluted States by Month (2017)', width=500, height=300) return chart " 2686,How many times did Bangalore city surpass 75 µg/m³ of PM2.5 in 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 75.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 2687,Plot the weekly average PM2.5 for Kalyan in 2021 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Kalyan') & (data['Timestamp'].dt.year == 2021)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Kalyan 2021', width=600, height=300) return chart " 2688,Visualize the bottom 13 states with the lowest average PM2.5 in 2023 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2023] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(13, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 13 States by Average PM2.5 in 2023', width=500, height=300) return chart " 2689,Tabulate the 20 citys with the least PM10 pollution in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 2690,Plot the rolling 30-day average PM2.5 for Chhattisgarh in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Chhattisgarh') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Chhattisgarh 2024', width=600, height=300) " 2691,Generate a city × month cross-tab of mean PM2.5 for Punjab in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Amritsar', 'Bathinda', 'Jalandhar', 'Khanna', 'Ludhiana', 'Mandi Gobindgarh', 'Patiala']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2692,"Scatter plot PM2.5 vs PM10 for Jharkhand stations in 2017, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Jharkhand') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Jharkhand Stations 2017', width=450, height=350) " 2693,Report which state documented the third lowest average PM2.5 of all time.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 2694,"Show the top 6 states by average PM10 in 2023 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2023] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(6, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 6 States by Average PM10 in 2023', width=500, height=300) return chart " 2695,Which state registered the peak median PM2.5 during the Winter season of 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 2696,Plot the rolling 30-day average PM2.5 for Delhi in 2021 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Delhi') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Delhi 2021', width=600, height=300) " 2697,Determine the city with the 2nd highest 75th percentile of PM2.5 in October 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 2698,Determine which state had the 5th highest NCAP funding relative to its median PM10 concentration in 2022 (FY 2021-22).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2022_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 2699,Determine the city exhibiting the 3rd highest median PM10 in November 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 2700,Determine the city exhibiting the 2nd highest 75th percentile of PM10 over the Summer season of 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 2701,"Plot the yearly average PM2.5 trends for Telangana, Himachal Pradesh, and West Bengal from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Telangana', 'Himachal Pradesh', 'West Bengal'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Telangana vs Himachal Pradesh vs West Bengal', width=550, height=320) return chart " 2702,Report the city with the lowest median PM2.5 in December 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 2703,Generate a monthly average PM2.5 table for Himachal Pradesh for the year 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Himachal Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2704,"Create a table showing top 15 citys ranked by PM2.5 in 2021, also showing PM10."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 2705,What is the median PM2.5 value on Sundays in Puducherry?," [{'op': 'FILTER', 'params': {'field': 'state', 'value': 'Puducherry'}}] " 2706,Determine the city exhibiting the peak median PM2.5 over the Post-Monsoon season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 2707,"In June 2019, identify the city with the lowest 25th percentile of PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 2708,Plot the weekly average PM2.5 for Howrah in 2021 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Howrah') & (data['Timestamp'].dt.year == 2021)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Howrah 2021', width=600, height=300) return chart " 2709,Show the monthly average PM2.5 for Vellore in 2022 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Vellore') & (data['Timestamp'].dt.year == 2022)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Vellore 2022', width=450, height=280) " 2710,On which date in the previous two years did Hyderabad register its 2nd minimum PM2.5 level?," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 2}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'Timestamp'}}] " 2711,Which city received the lowest NCAP funding relative to its total PM2.5 concentration in 2020 (FY 2019-20)?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'sum', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2020_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 2712,"Tabulate PM2.5 statistics (mean, std, min, max) for each city in 2022."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2713,"Scatter plot PM2.5 vs PM10 for Manipur stations in 2017, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Manipur') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Manipur Stations 2017', width=450, height=350) " 2714,List the bottom 15 states with the lowest average PM2.5 in 2024 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 2715,Which union territory shows the 3rd lowest 25th percentile of PM10 concentration in relation to its population density?," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_capita', 'numerator': 'PM10', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'pm_per_capita', 'ascending': True}}] " 2716,Which state registered the 3rd highest average PM10 during January 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 2717,Tabulate population-adjusted PM10 levels for each state in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM10 per million', 'numerator': 'PM10', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'PM10 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2718,Visualize NCAP city-level funding for FY 2021-22 as a horizontal bar chart for the top 5 cities.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = ncap_funding_data[['city','state','Amount released during FY 2021-22']].copy() df.columns = ['city','state','Amount (Cr)'] df = df.nlargest(5, 'Amount (Cr)') df['City_State'] = df['city'] + ', ' + df['state'] chart = alt.Chart(df).mark_bar().encode( x=alt.X('Amount (Cr):Q', title='Amount Released (Cr)'), y=alt.Y('City_State:N', sort='-x', title='City, State'), color=alt.Color('state:N', title='State'), tooltip=['city:N','state:N', alt.Tooltip('Amount (Cr):Q', format='.1f')] ).properties(title='Top 5 Cities by NCAP Funding – FY 2021-22', width=500, height=400) return chart " 2719,"In January 2018, report the state with the 2nd lowest average PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 2720,Show a monthly bar chart of the number of days Puducherry exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Puducherry') & (data['Timestamp'].dt.year == 2021)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Puducherry Exceeded WHO PM2.5 Guideline per Month – 2021', width=500, height=300) return chart " 2721,Determine the station with the highest 75th percentile of PM2.5 in June 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 2722,Tabulate the yearly average PM2.5 trend for Tamil Nadu across all years.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2723,Plot the weekly average PM2.5 for Ajmer in 2018 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ajmer') & (data['Timestamp'].dt.year == 2018)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Ajmer 2018', width=600, height=300) return chart " 2724,"Visualize the monthly average PM10 for Karnataka, Madhya Pradesh, and Andhra Pradesh in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Karnataka', 'Madhya Pradesh', 'Andhra Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Karnataka, Madhya Pradesh, UP – 2024', width=550, height=320) return chart " 2725,Show a cumulative area chart of PM2.5 readings for Sonipat across 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Sonipat') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Sonipat 2024', width=600, height=300) return chart " 2726,Tabulate average PM10 for each city in Assam across all months of 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Assam'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Byrnihat', 'Guwahati', 'Nagaon', 'Nalbari', 'Silchar', 'Sivasagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2727,"Which station showed the second-highest average PM2.5 on March 31, 2020?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 2728,"In September 2024, which state registered the 3rd lowest 25th percentile of PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 2729,Tabulate the yearly average PM10 trend for Telangana across all years.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Telangana'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2730,Determine the station exhibiting the 3rd lowest average PM2.5 over the Summer season of 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 2731,Show the monthly average PM2.5 for Malegaon in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Malegaon') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Malegaon 2018', width=450, height=280) " 2732,Show how many times PM10 exceeded 100 µg/m³ per day across citys in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2733,Create a month-wise summary of average PM10 for Mizoram in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Mizoram'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2734,How many times did Guwahati city go above 30 µg/m³ of PM2.5 in 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 30.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 2735,Which state possessed the lowest 75th percentile for PM10 in the Post-Monsoon season of 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 2736,Create a table showing PM10 levels and population for each state in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2737,Create a table with mean and standard deviation of PM10 by state in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2738,"Visualize the monthly average PM10 for Rajasthan, Himachal Pradesh, and Haryana in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Himachal Pradesh', 'Haryana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Rajasthan, Himachal Pradesh, UP – 2023', width=550, height=320) return chart " 2739,"Scatter plot PM2.5 vs PM10 for Andhra Pradesh stations in 2019, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Andhra Pradesh') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Andhra Pradesh Stations 2019', width=450, height=350) " 2740,Tabulate the yearly average PM2.5 trend for West Bengal across all years.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'West Bengal'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2741,"Plot the yearly average PM2.5 trends for Mizoram, Uttar Pradesh, and Odisha from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Mizoram', 'Uttar Pradesh', 'Odisha'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Mizoram vs Uttar Pradesh vs Odisha', width=550, height=320) return chart " 2742,Show a cumulative area chart of PM2.5 readings for Varanasi across 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Varanasi') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Varanasi 2018', width=600, height=300) return chart " 2743,What is the count of cities having only six stations?," [{'op': 'AGG', 'params': {'by': 'city', 'fn': 'nunique', 'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 2744,Which city had the highest 75th percentile of PM2.5 in November 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 2745,"Create a table showing top 20 states ranked by PM2.5 in 2017, also showing PM10."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 2746,List the top 20 citys by average PM10 in 2023 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 2747,"Plot the yearly average PM2.5 trends for Chandigarh, Maharashtra, and Manipur from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chandigarh', 'Maharashtra', 'Manipur'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Chandigarh vs Maharashtra vs Manipur', width=550, height=320) return chart " 2748,Which state recorded the minimum 25th percentile of PM10 during the Post-Monsoon season of 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 2749,What number of Telangana stations surpassed 30 µg/m³ of PM2.5 in 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 30.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 2750,"Scatter plot PM2.5 vs PM10 for Gujarat stations in 2018, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Gujarat') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Gujarat Stations 2018', width=450, height=350) " 2751,"Plot average PM2.5 (2019) vs state population as a scatter plot, labeling each point with the state name."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): pm = data[data['Timestamp'].dt.year == 2019].groupby('state')['PM2.5'].mean().reset_index().dropna() df = pm.merge(states_data, on='state') points = alt.Chart(df).mark_point(filled=True, size=80).encode( x=alt.X('population:Q', title='Population', axis=alt.Axis(format='~s')), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('population:Q', format=',')] ) labels = alt.Chart(df).mark_text(align='left', dx=5, fontSize=9).encode( x='population:Q', y='PM2\.5:Q', text='state:N' ) return (points + labels).properties(title='PM2.5 vs Population by State – 2019', width=500, height=400) " 2752,List the bottom 15 citys with the lowest average PM2.5 in 2017 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 2753,"Scatter plot PM2.5 vs PM10 for Maharashtra stations in 2020, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Maharashtra') & (data['Timestamp'].dt.year == 2020)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Maharashtra Stations 2020', width=450, height=350) " 2754,List average PM10 by month for Gandhinagar in 2021 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Gandhinagar'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2755,Which city had the 2nd highest median PM10 in April 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 2756,Plot the top 8 states by average PM2.5 in 2018 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2018] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(8, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 8 States by Average PM2.5 in 2018', width=500, height=300) return chart " 2757,Show a bar chart of the top 5 cities by median PM2.5 in 2020.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2020] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(5, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 5 Cities by Median PM2.5 in 2020', width=500, height=300) return chart " 2758,Show a pivot table of monthly average PM2.5 by city for Andhra Pradesh in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Amaravati', 'Rajamahendravaram', 'Tirupati', 'Visakhapatnam']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2759,Report which state documented the lowest average PM10 level of all time.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 2760,Show the monthly average PM10 trend for Hajipur from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Hajipur'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Hajipur (2019–2024)', width=600, height=300) return chart " 2761,"Visualize the monthly average PM10 for Mizoram, Puducherry, and Sikkim in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Mizoram', 'Puducherry', 'Sikkim'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Mizoram, Puducherry, UP – 2023', width=550, height=320) return chart " 2762,"Which city showed the second-highest median PM10 on March 31, 2024?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 2763,Show the monthly average PM2.5 for Manesar in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Manesar') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Manesar 2020', width=450, height=280) " 2764,"Plot the yearly average PM2.5 trends for Madhya Pradesh, Tamil Nadu, and Odisha from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Madhya Pradesh', 'Tamil Nadu', 'Odisha'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Madhya Pradesh vs Tamil Nadu vs Odisha', width=550, height=320) return chart " 2765,Create a ranked table of the 15 best-performing citys by PM10 in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 2766,Plot the weekly average PM2.5 for Ernakulam in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ernakulam') & (data['Timestamp'].dt.year == 2020)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Ernakulam 2020', width=600, height=300) return chart " 2767,Show a pivot table of monthly average PM2.5 by city for Madhya Pradesh in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Bhopal', 'Damoh', 'Gwalior', 'Indore', 'Jabalpur', 'Katni', 'Mandideep', 'Pithampur', 'Ratlam', 'Sagar', 'Satna', 'Singrauli', 'Ujjain']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2768,"Compare the monthly average PM2.5 of Jalgaon, Bhilai, and Bhopal in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Jalgaon', 'Bhilai', 'Bhopal'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Jalgaon vs Bhilai vs Bhopal – 2022', width=550, height=320) return chart " 2769,Report the state that had the 3rd highest average PM2.5 in December 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 2770,Identify the station with the 3rd lowest 75th percentile of PM10 in August 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 2771,Generate a city × month cross-tab of mean PM2.5 for Maharashtra in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Ahmednagar', 'Akola', 'Amravati', 'Aurangabad', 'Badlapur', 'Belapur', 'Bhiwandi', 'Boisar', 'Chandrapur', 'Dhule', 'Jalgaon', 'Jalna', 'Kalyan', 'Kolhapur', 'Latur', 'Mahad', 'Malegaon', 'Mira-Bhayandar', 'Mumbai', 'Nagpur', 'Nanded', 'Nashik', 'Navi Mumbai', 'Parbhani', 'Pimpri-Chinchwad', 'Pune', 'Sangli', 'Solapur', 'Thane', 'Ulhasnagar', 'Virar']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2772,Tabulate the 5 worst states for average PM10 in 2017 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 2773,Show the monthly average PM2.5 for Chengalpattu in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Chengalpattu') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Chengalpattu 2018', width=450, height=280) " 2774,"Tabulate PM10 levels, population, and land area per state in 2024."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2775,Identify the city that recorded the 2nd highest average PM10 value in December 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 2776,Show a pivot table of monthly average PM2.5 by city for Assam in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Assam'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Guwahati']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2777,Identify the station with the 3rd highest median PM2.5 for May 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 2778,Determine the city exhibiting the 2nd highest average PM10 over the Monsoon season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 2779,"On January 5, 2019, which city recorded the second-lowest average PM10 level?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 2780,Tabulate the 5 citys with the least PM2.5 pollution in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 2781,Generate a city × month cross-tab of mean PM10 for Bihar in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Bihar'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Araria', 'Arrah', 'Aurangabad', 'Begusarai', 'Bettiah', 'Bhagalpur', 'Bihar Sharif', 'Chhapra', 'Gaya', 'Hajipur', 'Katihar', 'Kishanganj', 'Manguraha', 'Motihari', 'Munger', 'Muzaffarpur', 'Patna', 'Purnia', 'Rajgir', 'Saharsa', 'Samastipur', 'Sasaram', 'Siwan']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2782,List the bottom 5 citys with the lowest average PM2.5 in 2017 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 2783,Determine the station exhibiting the 2nd highest 25th percentile of PM10 over the Winter season of 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 2784,Show the monthly average PM2.5 for Kohima in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Kohima') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Kohima 2018', width=450, height=280) " 2785,Identify the union territory possessing the 3rd highest average PM2.5 concentration normalized by population density.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_capita', 'numerator': 'PM2.5', 'denominator': 'population'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'pm_per_capita', 'ascending': False}}] " 2786,Show a pivot table of monthly average PM2.5 by city for Andhra Pradesh in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Amaravati', 'Anantapur', 'Chittoor', 'Kadapa', 'Rajamahendravaram', 'Tirupati', 'Vijayawada', 'Visakhapatnam']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2787,Create a summary table ranking the top 5 states by PM2.5 concentration in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 2788,"Identify the state that had the second-lowest PM10 concentrations on August 15, 2024."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 2789,Which state had the 2nd highest median PM10 in October 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 2790,Report the state with the 2nd highest median PM10 in February 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 2791,Show a pivot table of monthly average PM10 by city for Maharashtra in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Aurangabad', 'Chandrapur', 'Kalyan', 'Mumbai', 'Nagpur', 'Nashik', 'Navi Mumbai', 'Pune', 'Solapur', 'Thane']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2792,Show a cumulative area chart of PM2.5 readings for Panchkula across 2019.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Panchkula') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Panchkula 2019', width=600, height=300) return chart " 2793,"In June 2022, identify the state with the highest median PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 2794,Plot the weekly average PM2.5 for Singrauli in 2017 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Singrauli') & (data['Timestamp'].dt.year == 2017)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Singrauli 2017', width=600, height=300) return chart " 2795,Show a year-wise table of average PM10 for Solapur from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Solapur'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2796,Which station showed the highest median PM10 value in June 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 2797,"In January 2018, identify the station with the 3rd highest 75th percentile of PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 2798,Show a ranked table of the 20 most polluted citys by average PM10 in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 2799,Report the city with the 3rd lowest 25th percentile of PM10 in June 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 2800,Create a table of PM10 per unit area for all states in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM10 per km²', 'numerator': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)', 'PM10 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2801,"On March 31, 2019, which city recorded the second-highest 25th percentile of PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 2802,Show a table of the 20 cleanest citys by average PM10 in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 2803,"In June 2018, identify the city with the 2nd lowest 25th percentile of PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 2804,Generate a descriptive stats table for PM10 grouped by state in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2805,"Compare the monthly average PM2.5 of Jhalawar, Gandhinagar, and Mira-Bhayandar in 2020 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Jhalawar', 'Gandhinagar', 'Mira-Bhayandar'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2020)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Jhalawar vs Gandhinagar vs Mira-Bhayandar – 2020', width=550, height=320) return chart " 2806,Report the state that was granted the 2nd highest NCAP funding with respect to its median PM2.5 concentration in 2021 (FY 2020-21).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 2807,"Which station showed the second-highest 75th percentile for PM2.5 on March 31, 2018?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 2808,Which station noted the peak 75th percentile of PM10 during the Monsoon season of 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 2809,Which state showed the second lowest average PM2.5 level historically?," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 2810,Tabulate mean PM10 alongside state population figures for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2811,"Plot the yearly average PM2.5 trends for Jharkhand, Andhra Pradesh, and Madhya Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Andhra Pradesh', 'Madhya Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Jharkhand vs Andhra Pradesh vs Madhya Pradesh', width=550, height=320) return chart " 2812,"Compare the monthly average PM2.5 of Hanumangarh, Eloor, and Perundurai in 2020 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Hanumangarh', 'Eloor', 'Perundurai'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2020)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Hanumangarh vs Eloor vs Perundurai – 2020', width=550, height=320) return chart " 2813,Report the state with the 5th highest NCAP funding considering its total PM10 concentration in 2021 (FY 2020-21).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'sum', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 2814,Determine a week with Bahadurgarh's 2nd highest PM2.5 levels over all these years.," [{'op': 'FILTER', 'params': {'field': 'city', 'value': 'Bahadurgarh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'week'}}] " 2815,Create a month-wise summary of average PM10 for Faridabad in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Faridabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2816,"Show the top 13 states by average PM10 in 2017 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2017] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(13, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 13 States by Average PM10 in 2017', width=500, height=300) return chart " 2817,"Considering 2021, what weekday displayed the third-lowest 75th percentile for PM2.5 pollution levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'Timestamp'}}] " 2818,Show the monthly average PM10 trend for Pali from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Pali'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Pali (2019–2024)', width=600, height=300) return chart " 2819,"Create a grouped bar chart comparing the average PM2.5 for Tamil Nadu, Mizoram, and Delhi across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Mizoram', 'Delhi'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 2820,"Show the top 8 states by average PM10 in 2023 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2023] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(8, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 8 States by Average PM10 in 2023', width=500, height=300) return chart " 2821,Tabulate average and median PM2.5 for all states in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2822,Show a pivot table of monthly average PM10 by city for Rajasthan in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Ajmer', 'Alwar', 'Bhiwadi', 'Jaipur', 'Jodhpur', 'Kota', 'Pali', 'Sirohi', 'Udaipur']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2823,"Create a table showing top 10 citys ranked by PM2.5 in 2024, also showing PM10."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 2824,"Across all recorded years, which September showed the second-highest average PM10 concentration?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'Timestamp'}}] " 2825,Determine the state with the third-lowest median PM2.5 concentration in February 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 2826,List the top 15 citys by PM2.5 in 2018 with both PM2.5 and PM10 averages.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 2827,How many times did Assam exceed 75 µg/m³ of PM10 in 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 75.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 2828,"On March 31, 2022, which station had the third-highest 25th percentile for PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 2829,"On March 31, 2023, which station had the third-highest median PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 2830,Create a month-wise summary of average PM10 for Andhra Pradesh in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2831,Show the monthly average PM2.5 for Madikeri in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Madikeri') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Madikeri 2017', width=450, height=280) " 2832,Create a statistical summary table of PM10 readings by city for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2833,Show the number of days each state exceeded a PM10 threshold of 150 µg/m³ in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2834,How many times did Odisha go above 30 µg/m³ of PM2.5 in 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 30.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 2835,Find the city with the second-lowest mean PM10 reading for September 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 2836,Determine which city had the 3rd highest NCAP funding considering its 75th percentile of PM10 concentration in 2021 (FY 2020-21).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 2837,"In 2019, which week of the year was associated with the third-highest 25th percentile for PM2.5 concentrations?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'week'}}] " 2838,"Plot the yearly average PM2.5 trends for Assam, Karnataka, and Telangana from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Assam', 'Karnataka', 'Telangana'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Assam vs Karnataka vs Telangana', width=550, height=320) return chart " 2839,Show the monthly average PM2.5 for Perundurai in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Perundurai') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Perundurai 2020', width=450, height=280) " 2840,"Visualize the monthly average PM10 for Madhya Pradesh, Sikkim, and Rajasthan in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Madhya Pradesh', 'Sikkim', 'Rajasthan'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Madhya Pradesh, Sikkim, UP – 2021', width=550, height=320) return chart " 2841,Which 5 states recorded the highest average PM2.5 levels in 2017? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 2842,Which city noted the 2nd minimum 75th percentile of PM10 in the Winter season of 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 2843,"Which state (excluding Union Territories) exhibits the minimum PM2.5 concentration per square kilometer, based on average PM2.5 values?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_km2', 'numerator': 'PM2.5', 'denominator': 'area (km2)'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'pm_per_km2', 'ascending': True}}] " 2844,"Visualize the monthly average PM10 for Andhra Pradesh, Kerala, and Madhya Pradesh in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Kerala', 'Madhya Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Andhra Pradesh, Kerala, UP – 2019', width=550, height=320) return chart " 2845,Show a cumulative area chart of PM2.5 readings for Guwahati across 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Guwahati') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Guwahati 2024', width=600, height=300) return chart " 2846,"Visualize the monthly average PM10 for Arunachal Pradesh, Tripura, and Telangana in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Arunachal Pradesh', 'Tripura', 'Telangana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Arunachal Pradesh, Tripura, UP – 2024', width=550, height=320) return chart " 2847,Generate a table showing the 20 most polluted states based on mean PM2.5 for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 2848,Which city had the 3rd lowest 75th percentile of PM10 in February 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 2849,List states with their average PM2.5 and area for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2850,Identify the city with the 2nd lowest 75th percentile of PM10 in September 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 2851,Create a summary table ranking the top 20 states by PM10 concentration in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 2852,"Scatter plot PM2.5 vs PM10 for Arunachal Pradesh stations in 2019, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Arunachal Pradesh') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Arunachal Pradesh Stations 2019', width=450, height=350) " 2853,"Plot the yearly average PM2.5 trends for Uttar Pradesh, Gujarat, and West Bengal from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttar Pradesh', 'Gujarat', 'West Bengal'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Uttar Pradesh vs Gujarat vs West Bengal', width=550, height=320) return chart " 2854,"Show a table of average PM2.5, population, and area for all states in 2017."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': { 'map': { 'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2855,"Plot the yearly average PM2.5 trends for Jammu and Kashmir, Meghalaya, and Delhi from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jammu and Kashmir', 'Meghalaya', 'Delhi'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Jammu and Kashmir vs Meghalaya vs Delhi', width=550, height=320) return chart " 2856,"Tabulate PM2.5 levels, population, and land area per state in 2022."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': { 'map': { 'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2857,"Taking all years into account, which February was associated with the minimum 25th percentile of PM10 levels?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'Timestamp'}}] " 2858,Identify the city that recorded the most minimal average PM2.5 during the Summer season of 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 2859,"Create a table showing top 10 states ranked by PM2.5 in 2019, also showing PM10."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 2860,List the bottom 5 citys with the lowest average PM2.5 in 2023 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 2861,"In April 2020, identify the state with the highest 75th percentile of PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 2862,Identify the state that received the 4th lowest NCAP funding relative to its 25th percentile of PM2.5 concentration in 2022 (FY 2021-22).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2022_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 2863,Identify the city that saw the least significant fall in 25th percentile PM10 levels when comparing December 2019 to October 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 2864,"Compare the monthly average PM2.5 of Karnal, Manguraha, and Gandhinagar in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Karnal', 'Manguraha', 'Gandhinagar'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Karnal vs Manguraha vs Gandhinagar – 2022', width=550, height=320) return chart " 2865,"Comparing December 2024 to October 2024, which station showed the third most significant drop in 75th percentile PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 2866,Plot the rolling 30-day average PM2.5 for Meghalaya in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Meghalaya') & (data['Timestamp'].dt.year == 2020)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Meghalaya 2020', width=600, height=300) " 2867,"In January 2023, identify the station with the 3rd highest 75th percentile of PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 2868,Show a year-wise table of average PM2.5 for Delhi from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Delhi'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2869,Plot the weekly average PM2.5 for Chikkamagaluru in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Chikkamagaluru') & (data['Timestamp'].dt.year == 2024)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Chikkamagaluru 2024', width=600, height=300) return chart " 2870,Create a table showing PM10 levels and population for each state in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2871,"Tabulate PM2.5 statistics (mean, std, min, max) for each state in 2018."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2872,Show average PM10 per state in 2020 with area in km².," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2873,"Compare the monthly average PM2.5 of Bathinda, Satna, and Darbhanga in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Bathinda', 'Satna', 'Darbhanga'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Bathinda vs Satna vs Darbhanga – 2019', width=550, height=320) return chart " 2874,Tabulate average and median PM2.5 for all states in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2875,"In 2022, which city will rank second for the smallest reduction in 25th percentile PM2.5 levels from October to December?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 2876,Plot the monthly average PM2.5 trend for Puducherry from 2017 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Puducherry'].copy() df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly Average PM2.5 Trend – Puducherry (2017–2024)', width=600, height=300) return chart " 2877,Show the monthly average PM2.5 for Tonk in 2024 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Tonk') & (data['Timestamp'].dt.year == 2024)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Tonk 2024', width=450, height=280) " 2878,Which station showed the highest average PM2.5 in August 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 2879,Create a table showing annual mean PM2.5 levels for Howrah (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Howrah'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2880,Show how average PM2.5 varied month by month for Durgapur in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Durgapur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2881,Show a monthly bar chart of the number of days West Bengal exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2020.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'West Bengal') & (data['Timestamp'].dt.year == 2020)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days West Bengal Exceeded WHO PM2.5 Guideline per Month – 2020', width=500, height=300) return chart " 2882,Create a month-wise PM10 breakdown table across cities in Andhra Pradesh for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Amaravati', 'Anantapur', 'Chittoor', 'Kadapa', 'Rajamahendravaram', 'Tirupati', 'Vijayawada', 'Visakhapatnam']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2883,"Visualize the monthly average PM10 for Bihar, Andhra Pradesh, and Karnataka in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Bihar', 'Andhra Pradesh', 'Karnataka'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Bihar, Andhra Pradesh, UP – 2022', width=550, height=320) return chart " 2884,Show the monthly average PM10 trend for Bilaspur from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Bilaspur'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Bilaspur (2019–2024)', width=600, height=300) return chart " 2885,"For the period October to December 2020, which station had the third smallest decrease in 25th percentile PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 2886,Determine the state with the lowest 75th percentile of PM2.5 in June 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 2887,Show how many times PM10 exceeded 100 µg/m³ per day across states in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2888,Which station had the most substantial increase in average PM10 levels between March 2019 and March 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 2889,Create a table showing PM10 spread (min to max) and central tendency per state for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'q25', 'median', 'q75']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2890,"Plot the yearly average PM2.5 trends for Karnataka, Telangana, and Chhattisgarh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Karnataka', 'Telangana', 'Chhattisgarh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Karnataka vs Telangana vs Chhattisgarh', width=550, height=320) return chart " 2891,"Create a grouped bar chart comparing the average PM2.5 for Jammu and Kashmir, Maharashtra, and Andhra Pradesh across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jammu and Kashmir', 'Maharashtra', 'Andhra Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 2892,"Create a grouped bar chart comparing the average PM2.5 for Haryana, Jammu and Kashmir, and Tripura across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Jammu and Kashmir', 'Tripura'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 2893,Show the monthly average PM2.5 for Karwar in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Karwar') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Karwar 2020', width=450, height=280) " 2894,"Plot the yearly average PM2.5 trends for Bihar, Andhra Pradesh, and Karnataka from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Bihar', 'Andhra Pradesh', 'Karnataka'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Bihar vs Andhra Pradesh vs Karnataka', width=550, height=320) return chart " 2895,"Plot the yearly average PM2.5 trends for Sikkim, Tripura, and Kerala from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Sikkim', 'Tripura', 'Kerala'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Sikkim vs Tripura vs Kerala', width=550, height=320) return chart " 2896,How many times did Prayagraj city exceed 75 µg/m³ of PM10 in the year 2017?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 75.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 2897,Show PM2.5 averages in a state × month matrix for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Bihar', 'Delhi', 'Gujarat', 'Haryana', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Odisha', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2898,Create a month-wise PM10 breakdown table across cities in Karnataka for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Bengaluru']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2899,Identify the city that recorded the 2nd lowest median PM2.5 value in February 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 2900,Identify the state with the highest 25th percentile of PM10 in May 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 2901,"List each state's average PM2.5, PM10, and how many stations it has in 2019."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}, {'alias': 'Station Count', 'col': 'station', 'fn': 'nunique'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2902,Report the station that had the lowest average PM10 in October 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 2903,"Create a grouped bar chart comparing the average PM2.5 for Kerala, Manipur, and Madhya Pradesh across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Kerala', 'Manipur', 'Madhya Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 2904,Tabulate average PM2.5 for each city in Tamil Nadu across all months of 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Chennai', 'Coimbatore', 'Gummidipoondi']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2905,Which station experienced the second least significant drop in its median PM10 levels between October and December 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 2906,"Compare the monthly average PM2.5 of Nagaur, Chikkamagaluru, and Barbil in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Nagaur', 'Chikkamagaluru', 'Barbil'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Nagaur vs Chikkamagaluru vs Barbil – 2023', width=550, height=320) return chart " 2907,Create a heatmap showing the average PM2.5 by month (x-axis) and year (y-axis) for Delhi.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Delhi'].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Year:N', title='Year'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='Avg PM2.5'), tooltip=['Year:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Delhi (Month × Year)', width=500, height=280) return chart " 2908,"Create a grouped bar chart comparing the average PM2.5 for Jammu and Kashmir, Tamil Nadu, and Nagaland across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jammu and Kashmir', 'Tamil Nadu', 'Nagaland'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 2909,"Create a grouped bar chart comparing the average PM2.5 for Arunachal Pradesh, Rajasthan, and Manipur across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Arunachal Pradesh', 'Rajasthan', 'Manipur'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 2910,"Plot the yearly average PM2.5 trends for Gujarat, Mizoram, and Gujarat from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Gujarat', 'Mizoram', 'Gujarat'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Gujarat vs Mizoram vs Gujarat', width=550, height=320) return chart " 2911,How many times did Naharlagun city exceed the WHO guideline for PM2.5 in the year 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 15.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 2912,"Compare the monthly average PM2.5 of Parbhani, Sri Ganganagar, and Mandideep in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Parbhani', 'Sri Ganganagar', 'Mandideep'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Parbhani vs Sri Ganganagar vs Mandideep – 2019', width=550, height=320) return chart " 2913,"Plot the yearly average PM2.5 trends for Haryana, Arunachal Pradesh, and Assam from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Arunachal Pradesh', 'Assam'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Haryana vs Arunachal Pradesh vs Assam', width=550, height=320) return chart " 2914,List average PM10 by month for Aurangabad in 2021 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Aurangabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2915,"Identify the season in 2019 (Winter, Summer, Monsoon, Post-Monsoon) that registered the third-highest 75th percentile of PM2.5 levels."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'season'}}] " 2916,Determine the second-highest PM2.5 value recorded in 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}] " 2917,Tabulate the top 10 states for PM2.5 in 2021 along with their corresponding PM10 values.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 2918,Show a table of average PM2.5 per state in 2018 along with population.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2919,Create a table showing PM2.5 levels and population for each state in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2920,List all states with their average PM2.5 and PM10 levels in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2921,Create a ranked table of the 15 best-performing citys by PM2.5 in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 2922,Create a per-capita PM2.5 summary table by state for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM2.5 per million', 'numerator': 'PM2.5', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'PM2.5 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2923,Which station showed the 2nd highest 75th percentile for PM10 in the Summer season of 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 2924,Report which state registered the 2nd most minimal 75th percentile of PM2.5 throughout the Post-Monsoon season of 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 2925,Identify the state exhibiting the peak median PM2.5 during the Winter season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 2926,List average PM2.5 by month for Tamil Nadu in 2021 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2927,"Which state with a land area greater than 50,000 km² shows the 2nd lowest PM10 level, according to its average PM10 level?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}] " 2928,Determine the state exhibiting the 2nd most minimal average PM2.5 over the Summer season of 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 2929,"Plot the yearly average PM2.5 trends for Andhra Pradesh, Puducherry, and Arunachal Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Puducherry', 'Arunachal Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Andhra Pradesh vs Puducherry vs Arunachal Pradesh', width=550, height=320) return chart " 2930,"Create a faceted bar chart showing top 5 states by average PM2.5 per year for 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year.isin([2019,2020,2021,2022])].copy() df['Year'] = df['Timestamp'].dt.year agg = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() top = agg.groupby('Year').apply(lambda x: x.nlargest(5,'PM2.5')).reset_index(drop=True) chart = alt.Chart(top).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Avg PM2.5'), y=alt.Y('state:N', sort='-x'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet(facet='Year:O', columns=2).properties(title='Top 5 States by PM2.5 per Year') return chart " 2931,"Which state (excluding Union Territories) has the 2nd minimum land area among the top 10 most polluted states, according to average PM2.5 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 10, 'ret': 'state'}}] " 2932,"Report which station had the third lowest PM10 level on January 27, 2022."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 2933,How many times did Assam exceed the WHO guideline for PM10 in the year 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 15.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 2934,"Compare the monthly average PM2.5 of Pathardih, Gangtok, and Byrnihat in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Pathardih', 'Gangtok', 'Byrnihat'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Pathardih vs Gangtok vs Byrnihat – 2023', width=550, height=320) return chart " 2935,"Compare the monthly average PM2.5 of Jabalpur, Panchkula, and Gummidipoondi in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Jabalpur', 'Panchkula', 'Gummidipoondi'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Jabalpur vs Panchkula vs Gummidipoondi – 2022', width=550, height=320) return chart " 2936,Tabulate daily PM10 exceedances (above 100 µg/m³) per state for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2937,Show a cumulative area chart of PM2.5 readings for Gangtok across 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Gangtok') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Gangtok 2022', width=600, height=300) return chart " 2938,"Plot the yearly average PM2.5 trends for West Bengal, Tripura, and Chandigarh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['West Bengal', 'Tripura', 'Chandigarh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: West Bengal vs Tripura vs Chandigarh', width=550, height=320) return chart " 2939,Show a heatmap of average PM2.5 for the top 9 most polluted states by month for 2019.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(9).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 9 Polluted States by Month (2019)', width=500, height=300) return chart " 2940,Identify the state that received the 5th lowest NCAP funding relative to its median PM2.5 concentration in 2022 (FY 2021-22).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2022_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 2941,Show annual average PM2.5 for Puducherry as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Puducherry'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2942,"Tabulate the distribution of PM10 per city in 2022 including mean, median, and std."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2943,What number of Odisha stations surpassed 90 µg/m³ of PM10 in 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 90.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 2944,"Over all years, which June showed the maximum average PM10 concentration?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'Timestamp'}}] " 2945,"Show descriptive statistics of PM10 (mean, median, std, min, max) per state in 2024."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'q25', 'median', 'q75']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2946,Create a month-wise summary of average PM10 for Lucknow in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Lucknow'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2947,"Visualize the monthly average PM10 for Tamil Nadu, Gujarat, and Sikkim in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Gujarat', 'Sikkim'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Tamil Nadu, Gujarat, UP – 2019', width=550, height=320) return chart " 2948,"Compare the monthly average PM2.5 of Sawai Madhopur, Jaipur, and Ankleshwar in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Sawai Madhopur', 'Jaipur', 'Ankleshwar'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Sawai Madhopur vs Jaipur vs Ankleshwar – 2024', width=550, height=320) return chart " 2949,Plot the rolling 30-day average PM2.5 for West Bengal in 2018 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'West Bengal') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – West Bengal 2018', width=600, height=300) " 2950,"On March 31, 2021, which state recorded the third-highest median PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 2951,Which state had the lowest average PM10 in April 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 2952,Show a table of the 15 cleanest states by average PM10 in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 2953,Show a ranked table of the 5 most polluted citys by average PM10 in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 2954,Show a pivot table of monthly average PM10 by city for Tamil Nadu in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Ariyalur', 'Chennai', 'Gummidipoondi', 'Hosur', 'Kanchipuram', 'Ooty', 'Ramanathapuram', 'Salem', 'Thoothukudi', 'Tirupur', 'Vellore']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2955,Plot the weekly average PM2.5 for Damoh in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Damoh') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Damoh 2023', width=600, height=300) return chart " 2956,Which city registered the 3rd lowest 75th percentile of PM10 during the Winter season of 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 2957,Identify the city with the lowest median PM2.5 in October 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 2958,How many stations in Nagaland surpassed the WHO guideline for PM2.5 in the year 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 15.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 2959,Show a pivot table of monthly average PM2.5 by state for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Bihar', 'Delhi', 'Gujarat', 'Haryana', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2960,Plot the weekly average PM2.5 for Kalaburagi in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Kalaburagi') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Kalaburagi 2023', width=600, height=300) return chart " 2961,Show annual average PM2.5 for Asansol as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Asansol'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2962,Plot the top 5 states by average PM2.5 in 2018 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2018] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(5, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 5 States by Average PM2.5 in 2018', width=500, height=300) return chart " 2963,"Create a grouped bar chart comparing the average PM2.5 for Chhattisgarh, Chandigarh, and Chandigarh across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chhattisgarh', 'Chandigarh', 'Chandigarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 2964,List the bottom 20 citys with the lowest average PM2.5 in 2022 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 2965,"Plot the yearly average PM2.5 trends for Rajasthan, West Bengal, and Mizoram from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'West Bengal', 'Mizoram'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Rajasthan vs West Bengal vs Mizoram', width=550, height=320) return chart " 2966,"Scatter plot PM2.5 vs PM10 for Chhattisgarh stations in 2024, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Chhattisgarh') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Chhattisgarh Stations 2024', width=450, height=350) " 2967,Which 5 states recorded the highest average PM10 levels in 2023? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 2968,Plot the weekly average PM2.5 for Ludhiana in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ludhiana') & (data['Timestamp'].dt.year == 2020)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Ludhiana 2020', width=600, height=300) return chart " 2969,Tabulate average PM10 for each city in Maharashtra across all months of 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Chandrapur', 'Navi Mumbai', 'Pune', 'Solapur']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2970,List the bottom 10 citys with the lowest average PM10 in 2023 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 2971,"Plot the yearly average PM2.5 trends for West Bengal, Punjab, and Assam from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['West Bengal', 'Punjab', 'Assam'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: West Bengal vs Punjab vs Assam', width=550, height=320) return chart " 2972,Show a pivot table of yearly average PM2.5 by state across all years.," [ { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Bihar', 'Delhi', 'Gujarat', 'Haryana', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Odisha', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Uttar Pradesh']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'year', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2973,Create a summary table ranking the top 10 citys by PM10 concentration in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 2974,"In 2018, which week experienced the second-lowest median PM10 concentrations?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'week'}}] " 2975,Identify the city that recorded the 2nd lowest average PM10 value in February 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 2976,Show the monthly average PM10 trend for Vellore from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Vellore'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Vellore (2019–2024)', width=600, height=300) return chart " 2977,Show the monthly average PM10 trend for Ooty from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Ooty'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Ooty (2017–2022)', width=600, height=300) return chart " 2978,"Visualize the monthly average PM10 for Manipur, Tamil Nadu, and Haryana in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Manipur', 'Tamil Nadu', 'Haryana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Manipur, Tamil Nadu, UP – 2024', width=550, height=320) return chart " 2979,Show the monthly average PM2.5 for Karur in 2023 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Karur') & (data['Timestamp'].dt.year == 2023)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Karur 2023', width=450, height=280) " 2980,Tabulate the 15 states with the least PM2.5 pollution in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 2981,Identify the state that was the 3rd most polluted concerning per capita PM2.5 exposure in 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'per_capita_pm', 'numerator': 'PM2.5', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'per_capita_pm', 'ascending': False}}] " 2982,Visualize NCAP city-level funding for FY 2021-22 as a horizontal bar chart for the top 10 cities.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = ncap_funding_data[['city','state','Amount released during FY 2021-22']].copy() df.columns = ['city','state','Amount (Cr)'] df = df.nlargest(10, 'Amount (Cr)') df['City_State'] = df['city'] + ', ' + df['state'] chart = alt.Chart(df).mark_bar().encode( x=alt.X('Amount (Cr):Q', title='Amount Released (Cr)'), y=alt.Y('City_State:N', sort='-x', title='City, State'), color=alt.Color('state:N', title='State'), tooltip=['city:N','state:N', alt.Tooltip('Amount (Cr):Q', format='.1f')] ).properties(title='Top 10 Cities by NCAP Funding – FY 2021-22', width=500, height=400) return chart " 2983,Report which station registered the 2nd highest average PM2.5 throughout the Winter season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 2984,Tabulate the 20 worst citys for average PM2.5 in 2017 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 2985,"Create a grouped bar chart comparing the average PM2.5 for Tripura, Kerala, and Kerala across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tripura', 'Kerala', 'Kerala'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 2986,Identify the station with the 3rd highest median PM2.5 for August 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 2987,"During March 31, 2021, which station exhibited the second-lowest 25th percentile for PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 2988,List the average PM10 for Rajasthan broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2989,List how many days each city breached the PM2.5 limit of 100 µg/m³ in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 2990,"Scatter plot PM2.5 vs PM10 for Punjab stations in 2024, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Punjab') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Punjab Stations 2024', width=450, height=350) " 2991,Show the monthly average PM10 trend for Katihar from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Katihar'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Katihar (2019–2024)', width=600, height=300) return chart " 2992,Show the monthly average PM10 trend for Thoothukudi from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Thoothukudi'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Thoothukudi (2017–2022)', width=600, height=300) return chart " 2993,"Compare the monthly average PM2.5 of Balasore, Jalore, and Haveri in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Balasore', 'Jalore', 'Haveri'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Balasore vs Jalore vs Haveri – 2024', width=550, height=320) return chart " 2994,Show the monthly average PM10 trend for Chhapra from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Chhapra'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Chhapra (2019–2024)', width=600, height=300) return chart " 2995,"Visualize the monthly average PM10 for Kerala, Jammu and Kashmir, and Mizoram in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Kerala', 'Jammu and Kashmir', 'Mizoram'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Kerala, Jammu and Kashmir, UP – 2018', width=550, height=320) return chart " 2996,Report the state that had the highest 75th percentile of PM2.5 in February 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 2997,Show the monthly average PM2.5 for Nagaur in 2023 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Nagaur') & (data['Timestamp'].dt.year == 2023)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Nagaur 2023', width=450, height=280) " 2998,Identify the city with the highest median PM2.5 for November 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 2999,"Compare the monthly average PM2.5 of Jalgaon, Gwalior, and Bengaluru in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Jalgaon', 'Gwalior', 'Bengaluru'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Jalgaon vs Gwalior vs Bengaluru – 2019', width=550, height=320) return chart " 3000,Show a cumulative area chart of PM2.5 readings for Kadapa across 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Kadapa') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Kadapa 2023', width=600, height=300) return chart " 3001,Show the monthly average PM2.5 for Karnal in 2022 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Karnal') & (data['Timestamp'].dt.year == 2022)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Karnal 2022', width=450, height=280) " 3002,Create a per-capita PM10 summary table by state for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM10 per million', 'numerator': 'PM10', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'PM10 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3003,Create a ranked table of the 20 best-performing citys by PM2.5 in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 3004,Tabulate the 10 states with the least PM10 pollution in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 3005,Show the monthly average PM2.5 for Durgapur in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Durgapur') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Durgapur 2020', width=450, height=280) " 3006,Determine the station exhibiting the 3rd highest 25th percentile of PM10 over the Monsoon season of 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 3007,"Create a grouped bar chart comparing the average PM2.5 for Nagaland, Madhya Pradesh, and Uttar Pradesh across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Nagaland', 'Madhya Pradesh', 'Uttar Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 3008,"Plot a scatter chart of state-level average PM2.5 versus population for 2018, with point size representing area."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): pm = data[data['Timestamp'].dt.year == 2018].groupby('state')['PM2.5'].mean().reset_index().dropna() df = pm.merge(states_data, on='state') chart = alt.Chart(df).mark_point(filled=True, opacity=0.7).encode( x=alt.X('population:Q', title='Population', axis=alt.Axis(format='~s')), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), size=alt.Size('area (km2):Q', title='Area (km²)', scale=alt.Scale(range=[50,1000])), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('population:Q', format=','), 'area (km2):Q'] ).properties(title='PM2.5 vs Population (size=Area) – 2018', width=500, height=400) return chart " 3009,Show a cumulative area chart of PM2.5 readings for Katni across 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Katni') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Katni 2021', width=600, height=300) return chart " 3010,"Compare the monthly average PM2.5 of Gandhinagar, Kota, and Aizawl in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Gandhinagar', 'Kota', 'Aizawl'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Gandhinagar vs Kota vs Aizawl – 2024', width=550, height=320) return chart " 3011,Generate a year-by-state matrix of average PM2.5 for all available years.," [ { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Bihar', 'Delhi', 'Gujarat', 'Haryana', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Odisha', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Uttar Pradesh']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'year', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3012,"Visualize the monthly average PM10 for Mizoram, Andhra Pradesh, and Telangana in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Mizoram', 'Andhra Pradesh', 'Telangana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Mizoram, Andhra Pradesh, UP – 2017', width=550, height=320) return chart " 3013,Create a heatmap showing the average PM2.5 by month (x-axis) and year (y-axis) for Puducherry.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Puducherry'].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Year:N', title='Year'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='Avg PM2.5'), tooltip=['Year:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Puducherry (Month × Year)', width=500, height=280) return chart " 3014,"Considering all years, which February showed the third-highest median PM10 concentration?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'Timestamp'}}] " 3015,Generate a year-by-year summary table of PM2.5 readings for Puducherry.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Puducherry'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3016,"Plot the yearly average PM2.5 trends for West Bengal, Maharashtra, and Tamil Nadu from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['West Bengal', 'Maharashtra', 'Tamil Nadu'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: West Bengal vs Maharashtra vs Tamil Nadu', width=550, height=320) return chart " 3017,List how many days each city breached the PM10 limit of 100 µg/m³ in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3018,Show a heatmap of average PM2.5 for the top 12 most polluted states by month for 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(12).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 12 Polluted States by Month (2022)', width=500, height=300) return chart " 3019,Determine the city that recorded the 3rd highest median for PM2.5 over the Winter season of 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 3020,Plot the top 11 states by average PM2.5 in 2019 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2019] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(11, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 11 States by Average PM2.5 in 2019', width=500, height=300) return chart " 3021,Determine the state exhibiting the 2nd lowest 75th percentile of PM2.5 over the Summer season of 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 3022,Tabulate the 15 worst states for average PM10 in 2021 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 3023,Which state registered the 3rd highest 75th percentile of PM2.5 in the Post-Monsoon season of 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 3024,Identify the station that registered the peak 25th percentile of PM10 during the Winter season of 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 3025,Determine the city exhibiting the 2nd highest 75th percentile of PM10 in May 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 3026,Tabulate the 15 worst states for average PM2.5 in 2024 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 3027,What count of Kerala stations went above the Indian guideline for PM10 in 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 60.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 3028,Tabulate daily PM2.5 exceedances (above 60 µg/m³) per state for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3029,Which station had the 3rd lowest median PM10 in February 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 3030,Generate a city × month cross-tab of mean PM10 for Andhra Pradesh in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Tirupati']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3031,Generate a year-by-year summary table of PM2.5 readings for Himachal Pradesh.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Himachal Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3032,"Plot the yearly average PM2.5 trends for Manipur, Telangana, and Meghalaya from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Manipur', 'Telangana', 'Meghalaya'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Manipur vs Telangana vs Meghalaya', width=550, height=320) return chart " 3033,Which station registered the minimum median PM2.5 during the Summer season of 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 3034,Show a monthly bar chart of the number of days Haryana exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Haryana') & (data['Timestamp'].dt.year == 2021)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Haryana Exceeded WHO PM2.5 Guideline per Month – 2021', width=500, height=300) return chart " 3035,Which state had the 5th lowest NCAP funding with respect to its average PM2.5 concentration in 2022 (FY 2021-22)?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2022_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 3036,Show a pivot table of monthly average PM10 by city for Madhya Pradesh in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Bhopal', 'Damoh', 'Dewas', 'Gwalior', 'Indore', 'Jabalpur', 'Katni', 'Maihar', 'Mandideep', 'Pithampur', 'Ratlam', 'Sagar', 'Satna', 'Singrauli', 'Ujjain']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3037,"Plot the yearly average PM2.5 trends for Delhi, Sikkim, and Delhi from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Delhi', 'Sikkim', 'Delhi'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Delhi vs Sikkim vs Delhi', width=550, height=320) return chart " 3038,Create a table of PM2.5 standard violations (>60 µg/m³) per state in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3039,Create a table of PM2.5 exceedance frequency above 60 µg/m³ by city for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3040,Show PM2.5 exceedances above the Indian standard (60 µg/m³) per year as a bar chart for Tripura.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Tripura'].dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 60].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby('Year')['Timestamp'].nunique().reset_index() df.columns = ['Year','Days Exceeded'] chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('Year:N', title='Year'), y=alt.Y('Days Exceeded:Q', title='Days PM2.5 > 60 µg/m³'), tooltip=['Year:N','Days Exceeded:Q'] ).properties(title='Days Tripura Exceeded Indian PM2.5 Standard (60 µg/m³) per Year', width=450, height=300) return chart " 3041,Show a monthly breakdown table of average PM10 for Delhi in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Delhi'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3042,Plot the top 5 states by average PM2.5 in 2022 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2022] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(5, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 5 States by Average PM2.5 in 2022', width=500, height=300) return chart " 3043,Show the monthly average PM10 trend for Korba from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Korba'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Korba (2019–2024)', width=600, height=300) return chart " 3044,"Create a grouped bar chart comparing the average PM2.5 for Chandigarh, Assam, and Puducherry across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chandigarh', 'Assam', 'Puducherry'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 3045,"Plot the yearly average PM2.5 trends for Manipur, Madhya Pradesh, and Haryana from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Manipur', 'Madhya Pradesh', 'Haryana'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Manipur vs Madhya Pradesh vs Haryana', width=550, height=320) return chart " 3046,Create a month-wise PM2.5 breakdown table across cities in Kerala for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Thiruvananthapuram']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3047,Report the station that had the lowest 75th percentile of PM10 in December 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 3048,Show a cumulative area chart of PM2.5 readings for Ajmer across 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ajmer') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Ajmer 2022', width=600, height=300) return chart " 3049,Show PM2.5 exceedances above the Indian standard (60 µg/m³) per year as a bar chart for Himachal Pradesh.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Himachal Pradesh'].dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 60].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby('Year')['Timestamp'].nunique().reset_index() df.columns = ['Year','Days Exceeded'] chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('Year:N', title='Year'), y=alt.Y('Days Exceeded:Q', title='Days PM2.5 > 60 µg/m³'), tooltip=['Year:N','Days Exceeded:Q'] ).properties(title='Days Himachal Pradesh Exceeded Indian PM2.5 Standard (60 µg/m³) per Year', width=450, height=300) return chart " 3050,Show a monthly bar chart of the number of days Maharashtra exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Maharashtra') & (data['Timestamp'].dt.year == 2023)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Maharashtra Exceeded WHO PM2.5 Guideline per Month – 2023', width=500, height=300) return chart " 3051,Tabulate the yearly average PM2.5 trend for Solapur across all years.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Solapur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3052,Report the station with the lowest median PM2.5 in February 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 3053,Report the state with the 2nd highest median PM10 in November 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 3054,Show the monthly average PM2.5 for Dausa in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Dausa') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Dausa 2019', width=450, height=280) " 3055,"Considering all years, which September was associated with the minimum 25th percentile of PM2.5 levels?"," [{'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'Timestamp'}}] " 3056,Show the monthly average PM10 trend for Aurangabad from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Aurangabad'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Aurangabad (2017–2022)', width=600, height=300) return chart " 3057,Create a table showing annual mean PM10 levels for Madhya Pradesh (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3058,Which station recorded the 3rd lowest 75th percentile of PM10 in the Winter season of 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 3059,Determine the state with the highest 25th percentile of PM10 in May 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 3060,Tabulate the 10 states with the least PM2.5 pollution in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 3061,Tabulate the yearly average PM10 trend for Ahmedabad across all years.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Ahmedabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3062,Show the number of days each state exceeded a PM10 threshold of 150 µg/m³ in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3063,Show annual average PM2.5 for Bhilai as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Bhilai'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3064,Tabulate the 5 worst citys for average PM10 in 2018 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 3065,"Compare the monthly average PM2.5 of Pali, Yamuna Nagar, and Badlapur in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Pali', 'Yamuna Nagar', 'Badlapur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Pali vs Yamuna Nagar vs Badlapur – 2024', width=550, height=320) return chart " 3066,List all states with their average PM10 and population for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3067,Which state showed the 2nd highest 25th percentile for PM10 in the Winter season of 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 3068,Report which city experienced the 2nd most minimal median PM10 throughout the Monsoon season of 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 3069,"Plot the yearly average PM2.5 trends for West Bengal, Manipur, and Meghalaya from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['West Bengal', 'Manipur', 'Meghalaya'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: West Bengal vs Manipur vs Meghalaya', width=550, height=320) return chart " 3070,Generate a city × month cross-tab of mean PM10 for Punjab in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Amritsar', 'Ludhiana', 'Mandi Gobindgarh']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3071,Create a ranked table of the 5 best-performing citys by PM10 in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 3072,Show a pivot table of monthly average PM2.5 by city for Karnataka in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Bengaluru']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3073,Determine the station exhibiting the 2nd most minimal 75th percentile of PM10 over the Summer season of 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 3074,Show average PM10 per state in 2022 with area in km².," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3075,"Create a grouped bar chart comparing the average PM2.5 for Bihar, Puducherry, and Madhya Pradesh across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Bihar', 'Puducherry', 'Madhya Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 3076,Show annual average PM10 for Bengaluru as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Bengaluru'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3077,Show a monthly bar chart of the number of days Madhya Pradesh exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Madhya Pradesh') & (data['Timestamp'].dt.year == 2018)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Madhya Pradesh Exceeded WHO PM2.5 Guideline per Month – 2018', width=500, height=300) return chart " 3078,List all states with their average PM2.5 and population for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3079,Show a table of the 15 cleanest citys by average PM2.5 in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 3080,"For August 2020 relative to August 2019, which state had the most substantial increase in its 75th percentile PM2.5 level?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 3081,Report which station possessed the third highest 25th percentile of PM2.5 throughout the Post-Monsoon season of 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 3082,"Create a grouped bar chart comparing the average PM2.5 for Delhi, Chhattisgarh, and Haryana across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Delhi', 'Chhattisgarh', 'Haryana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 3083,"Compare the monthly average PM2.5 of Jabalpur, Kochi, and Karwar in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Jabalpur', 'Kochi', 'Karwar'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Jabalpur vs Kochi vs Karwar – 2023', width=550, height=320) return chart " 3084,"Considering 2019, what week number displayed the second-highest 75th percentile for PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'week'}}] " 3085,Plot the monthly average PM2.5 trend for Odisha from 2017 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Odisha'].copy() df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly Average PM2.5 Trend – Odisha (2017–2024)', width=600, height=300) return chart " 3086,"Considering 2021, what season (Winter, Summer, Monsoon, Post-Monsoon) displayed the third-lowest 25th percentile for PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'season'}}] " 3087,Create a table of PM10 per unit area for all states in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM10 per km²', 'numerator': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)', 'PM10 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3088,List average PM2.5 by month for Punjab in 2018 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3089,Show a pivot table of monthly average PM10 by city for Punjab in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Amritsar', 'Bathinda', 'Jalandhar', 'Khanna', 'Ludhiana', 'Mandi Gobindgarh', 'Patiala', 'Rupnagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3090,Identify the state that recorded the 3rd highest median PM10 value in February 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 3091,"Taking all years into account, which February experienced the highest 25th percentile of PM2.5 concentration?"," [{'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'Timestamp'}}] " 3092,Show the monthly average PM2.5 for Angul in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Angul') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Angul 2018', width=450, height=280) " 3093,"Visualize the monthly average PM10 for Nagaland, Madhya Pradesh, and Madhya Pradesh in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Nagaland', 'Madhya Pradesh', 'Madhya Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Nagaland, Madhya Pradesh, UP – 2023', width=550, height=320) return chart " 3094,"Comparing December 2019 to October 2019, which city showed the least significant drop in median PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 3095,"Plot the yearly average PM2.5 trends for Chandigarh, Kerala, and Tamil Nadu from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chandigarh', 'Kerala', 'Tamil Nadu'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Chandigarh vs Kerala vs Tamil Nadu', width=550, height=320) return chart " 3096,Show the monthly average PM10 trend for Delhi from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Delhi'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Delhi (2017–2022)', width=600, height=300) return chart " 3097,Tabulate average and median PM2.5 for all citys in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3098,"In January 2022, report the station with the 2nd lowest median PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 3099,Generate a table showing the 15 most polluted citys based on mean PM2.5 for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 3100,Which 10 citys had the lowest mean PM2.5 in 2019? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 3101,"For 2018, identify the week of the year with the second-highest median PM2.5 levels."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'week'}}] " 3102,Create a table of state PM2.5 levels and geographic area for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3103,Show a cumulative area chart of PM2.5 readings for Kochi across 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Kochi') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Kochi 2024', width=600, height=300) return chart " 3104,Show the monthly average PM10 trend for Jind from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Jind'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Jind (2017–2022)', width=600, height=300) return chart " 3105,Show a monthly bar chart of the number of days Bihar exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2020.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Bihar') & (data['Timestamp'].dt.year == 2020)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Bihar Exceeded WHO PM2.5 Guideline per Month – 2020', width=500, height=300) return chart " 3106,Plot the rolling 30-day average PM2.5 for Gujarat in 2018 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Gujarat') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Gujarat 2018', width=600, height=300) " 3107,"Compare the monthly average PM2.5 of Yadgir, Rajamahendravaram, and Araria in 2020 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Yadgir', 'Rajamahendravaram', 'Araria'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2020)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Yadgir vs Rajamahendravaram vs Araria – 2020', width=550, height=320) return chart " 3108,Tabulate average PM10 for each city in Kerala across all months of 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Eloor', 'Ernakulam', 'Kochi', 'Kozhikode', 'Thiruvananthapuram']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3109,"Scatter plot PM2.5 vs PM10 for Uttarakhand stations in 2017, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Uttarakhand') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Uttarakhand Stations 2017', width=450, height=350) " 3110,Generate a city × month cross-tab of mean PM10 for West Bengal in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'West Bengal'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Asansol', 'Durgapur', 'Howrah', 'Kolkata', 'Siliguri']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3111,"Compare the monthly average PM2.5 of Kolkata, Gangtok, and Ahmednagar in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Kolkata', 'Gangtok', 'Ahmednagar'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Kolkata vs Gangtok vs Ahmednagar – 2018', width=550, height=320) return chart " 3112,Tabulate both PM2.5 and PM10 averages by city for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3113,Show PM2.5 density (µg/m³ per km²) by state for 2021 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, { 'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM2.5 per km²', 'numerator': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)', 'PM2.5 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3114,"Compare the monthly average PM2.5 of Kollam, Darbhanga, and Bhiwandi in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Kollam', 'Darbhanga', 'Bhiwandi'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Kollam vs Darbhanga vs Bhiwandi – 2024', width=550, height=320) return chart " 3115,Which 20 citys had the lowest mean PM2.5 in 2020? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 3116,Create a month-wise summary of average PM10 for Prayagraj in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Prayagraj'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3117,Create a table of PM2.5 standard violations (>100 µg/m³) per city in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3118,Plot the weekly average PM2.5 for Dharwad in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Dharwad') & (data['Timestamp'].dt.year == 2024)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Dharwad 2024', width=600, height=300) return chart " 3119,Report the city with the highest median PM2.5 in March 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 3120,Identify the station that registered the maximum average PM2.5 ever.," [{'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 3121,Plot the weekly average PM2.5 for Siliguri in 2019 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Siliguri') & (data['Timestamp'].dt.year == 2019)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Siliguri 2019', width=600, height=300) return chart " 3122,List the average PM2.5 for Uttar Pradesh broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3123,Tabulate average and median PM2.5 for all citys in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3124,Determine the station that showed the 3rd lowest median PM2.5 over the Summer season of 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 3125,"Visualize the monthly average PM10 for Tamil Nadu, Odisha, and Nagaland in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Odisha', 'Nagaland'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Tamil Nadu, Odisha, UP – 2021', width=550, height=320) return chart " 3126,Report the city with the 5th highest NCAP funding relative to its median PM10 concentration in 2021 (FY 2020-21).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 3127,List the top 20 states by PM2.5 in 2022 with both PM2.5 and PM10 averages.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 3128,How many times did Muzaffarnagar city go above 45 µg/m³ of PM10 in 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 45.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 3129,Tabulate the 10 citys with the least PM10 pollution in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 3130,Plot the weekly average PM2.5 for Dharuhera in 2019 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Dharuhera') & (data['Timestamp'].dt.year == 2019)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Dharuhera 2019', width=600, height=300) return chart " 3131,"Compare the monthly average PM2.5 of Pali, Dewas, and Durgapur in 2020 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Pali', 'Dewas', 'Durgapur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2020)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Pali vs Dewas vs Durgapur – 2020', width=550, height=320) return chart " 3132,Show the monthly average PM2.5 for Nagaur in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Nagaur') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Nagaur 2018', width=450, height=280) " 3133,Which 10 states had the lowest mean PM10 in 2019? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 3134,Generate a year-by-year summary table of PM10 readings for Guwahati.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Guwahati'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3135,Create a month-wise summary of average PM10 for Ahmedabad in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Ahmedabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3136,Create a summary table ranking the top 15 states by PM10 concentration in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 3137,Show a monthly breakdown table of average PM10 for Mumbai in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Mumbai'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3138,Identify the state with the 3rd lowest 75th percentile of PM2.5 in October 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 3139,How many times did Tripura go above 30 µg/m³ of PM2.5 in 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 30.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 3140,Show a year-wise table of average PM10 for Delhi from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Delhi'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3141,Which state showed the 3rd lowest median PM2.5 in March 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 3142,"Over all years, which July registered the maximum average PM2.5 levels?"," [{'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'Timestamp'}}] " 3143,Generate a descriptive stats table for PM2.5 grouped by city in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3144,"Plot the yearly average PM2.5 trends for Uttarakhand, Arunachal Pradesh, and Andhra Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttarakhand', 'Arunachal Pradesh', 'Andhra Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Uttarakhand vs Arunachal Pradesh vs Andhra Pradesh', width=550, height=320) return chart " 3145,Show how many times PM10 exceeded 150 µg/m³ per day across citys in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3146,What count of Uttar Pradesh stations surpassed 90 µg/m³ of PM10 in 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 90.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 3147,"Create a grouped bar chart comparing the average PM2.5 for Mizoram, Manipur, and Arunachal Pradesh across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Mizoram', 'Manipur', 'Arunachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 3148,Which city displayed the 3rd lowest 75th percentile of PM10 in June 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 3149,Which station exhibited the third smallest decrease in its median PM10 levels between October and December of 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 3150,"Plot the yearly average PM2.5 trends for Uttarakhand, Andhra Pradesh, and Arunachal Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttarakhand', 'Andhra Pradesh', 'Arunachal Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Uttarakhand vs Andhra Pradesh vs Arunachal Pradesh', width=550, height=320) return chart " 3151,Plot the top 7 states by average PM2.5 in 2023 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2023] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(7, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 7 States by Average PM2.5 in 2023', width=500, height=300) return chart " 3152,Which station experienced the second least significant drop in its average PM2.5 levels between October and December 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 3153,Create a ranked table of the 15 best-performing citys by PM10 in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 3154,Which 10 citys had the lowest mean PM10 in 2017? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 3155,"Compare the monthly average PM2.5 of Tiruchirappalli, Charkhi Dadri, and Bilaspur in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Tiruchirappalli', 'Charkhi Dadri', 'Bilaspur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Tiruchirappalli vs Charkhi Dadri vs Bilaspur – 2022', width=550, height=320) return chart " 3156,Show a ranked table of the 15 most polluted states by average PM2.5 in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 3157,Which state exhibited the highest 25th percentile for PM10 during August 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 3158,Show the monthly average PM2.5 for Rajgir in 2022 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Rajgir') & (data['Timestamp'].dt.year == 2022)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Rajgir 2022', width=450, height=280) " 3159,On which date in the past four years did Dewas record its minimum PM10 level?," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 4}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'Timestamp'}}] " 3160,Which station recorded the 3rd lowest 25th percentile for PM10 in the Monsoon season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 3161,Identify the station with the highest average PM10 for November 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 3162,"In January 2020, which city exhibited the 3rd highest average PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 3163,"During 2024, which week saw the third-highest median PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'week'}}] " 3164,Show annual average PM10 for Gaya as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Gaya'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3165,Tabulate average PM2.5 for each city in Assam across all months of 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Assam'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Byrnihat', 'Guwahati', 'Nalbari', 'Silchar', 'Sivasagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3166,Which 5 citys recorded the highest average PM2.5 levels in 2021? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 3167,Create a table of PM2.5 per unit area for all states in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, { 'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM2.5 per km²', 'numerator': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)', 'PM2.5 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3168,Which state with NCAP funding records the highest PM2.5 concentration?," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}] " 3169,"Create a grouped bar chart comparing the average PM2.5 for Jharkhand, Tripura, and Karnataka across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Tripura', 'Karnataka'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 3170,List average PM2.5 by month for Tamil Nadu in 2019 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3171,"Visualize the monthly average PM10 for Tripura, Telangana, and Karnataka in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tripura', 'Telangana', 'Karnataka'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Tripura, Telangana, UP – 2022', width=550, height=320) return chart " 3172,Tabulate mean PM10 and land area for each state in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3173,Determine the station exhibiting the lowest 25th percentile of PM10 in November 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 3174,Identify the city that received the 3rd lowest NCAP funding with respect to its median PM2.5 concentration in 2021 (FY 2020-21).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 3175,"In May 2022, report the state with the 2nd highest median PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 3176,Which station registered the 3rd highest median PM10 during September 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 3177,"Across all recorded years, which August experienced the second-highest 25th percentile for PM2.5 levels?"," [{'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'Timestamp'}}] " 3178,"Plot the yearly average PM2.5 trends for Telangana, Chandigarh, and Nagaland from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Telangana', 'Chandigarh', 'Nagaland'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Telangana vs Chandigarh vs Nagaland', width=550, height=320) return chart " 3179,Show the monthly average PM2.5 for Tonk in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Tonk') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Tonk 2017', width=450, height=280) " 3180,"Scatter plot PM2.5 vs PM10 for Gujarat stations in 2024, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Gujarat') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Gujarat Stations 2024', width=450, height=350) " 3181,"Show descriptive statistics of PM10 (mean, median, std, min, max) per city in 2024."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'q25', 'median', 'q75']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3182,Show the monthly average PM10 trend for Nalbari from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Nalbari'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Nalbari (2019–2024)', width=600, height=300) return chart " 3183,Determine the city with the highest average PM10 in September 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 3184,Create a summary table ranking the top 20 citys by PM10 concentration in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 3185,"In the year 2024, which weekday recorded the third-highest median PM2.5 pollution levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'Timestamp'}}] " 3186,"Visualize the monthly average PM10 for Meghalaya, Chandigarh, and Chhattisgarh in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Meghalaya', 'Chandigarh', 'Chhattisgarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Meghalaya, Chandigarh, UP – 2023', width=550, height=320) return chart " 3187,"Create a grouped bar chart comparing the average PM2.5 for Chandigarh, Tamil Nadu, and Tripura across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chandigarh', 'Tamil Nadu', 'Tripura'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 3188,Determine the 2nd most polluted union territory concerning per capita PM10 exposure in 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'COMPUTE', 'params': {'new_col': 'per_capita_pm', 'numerator': 'PM10', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'per_capita_pm', 'ascending': False}}] " 3189,"Plot the yearly average PM2.5 trends for Mizoram, Odisha, and Manipur from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Mizoram', 'Odisha', 'Manipur'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Mizoram vs Odisha vs Manipur', width=550, height=320) return chart " 3190,Generate a table showing the 10 most polluted states based on mean PM10 for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 3191,Show the monthly average PM10 trend for Keonjhar from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Keonjhar'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Keonjhar (2019–2024)', width=600, height=300) return chart " 3192,Show a table of average PM10 per state in 2019 along with population.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3193,Plot the weekly average PM2.5 for Bidar in 2021 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bidar') & (data['Timestamp'].dt.year == 2021)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Bidar 2021', width=600, height=300) return chart " 3194,"Plot the yearly average PM2.5 trends for Karnataka, Tripura, and Kerala from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Karnataka', 'Tripura', 'Kerala'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Karnataka vs Tripura vs Kerala', width=550, height=320) return chart " 3195,Create a per-capita PM2.5 summary table by state for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM2.5 per million', 'numerator': 'PM2.5', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'PM2.5 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3196,"Create a grouped bar chart comparing the average PM2.5 for Manipur, Meghalaya, and Meghalaya across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Manipur', 'Meghalaya', 'Meghalaya'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 3197,List the top 5 states by PM2.5 in 2021 with both PM2.5 and PM10 averages.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 3198,Determine which union territory shows the 2nd lowest average PM10 concentration adjusted for population density.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_capita', 'numerator': 'PM10', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'pm_per_capita', 'ascending': True}}] " 3199,"Determine the city showing the minimum PM2.5 level on January 27, 2020."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 3200,Identify the year when the average PM2.5 level was at its minimum.," [{'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'Timestamp'}}] " 3201,Create a table of PM2.5 exceedance frequency above 100 µg/m³ by city for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3202,Show a monthly bar chart of the number of days Karnataka exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Karnataka') & (data['Timestamp'].dt.year == 2024)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Karnataka Exceeded WHO PM2.5 Guideline per Month – 2024', width=500, height=300) return chart " 3203,Identify the state with the 2nd highest 25th percentile of PM10 for April 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 3204,"Which season in 2018 (Winter, Summer, Monsoon, Post-Monsoon) was linked to the highest 75th percentile of PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'season'}}] " 3205,List average PM10 by month for Bihar in 2020 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Bihar'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3206,Tabulate average and median PM2.5 for all states in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3207,List the top 5 states by average PM2.5 in 2017 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 3208,"Create a grouped bar chart comparing the average PM2.5 for Madhya Pradesh, Punjab, and Chandigarh across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Madhya Pradesh', 'Punjab', 'Chandigarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 3209,Identify the state with the 3rd highest median PM2.5 for April 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 3210,Plot the weekly average PM2.5 for Mandideep in 2019 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Mandideep') & (data['Timestamp'].dt.year == 2019)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Mandideep 2019', width=600, height=300) return chart " 3211,List citys with their PM2.5 violation count and rate (>60 µg/m³) in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3212,Show the monthly average PM2.5 for Parbhani in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Parbhani') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Parbhani 2019', width=450, height=280) " 3213,Report which station registered the 3rd highest 25th percentile of PM10 throughout the Monsoon season of 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 3214,"Identify the state with the minimum average PM2.5 on March 31, 2022."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 3215,Name the state with the lowest average PM10 reading for December 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 3216,"Create a table showing top 15 citys ranked by PM2.5 in 2018, also showing PM10."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 3217,How many times did Delhi exceed the Indian guideline for PM10 in 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 60.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 3218,Show a ranked table of the 5 most polluted states by average PM2.5 in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 3219,"Create a grouped bar chart comparing the average PM2.5 for Haryana, Maharashtra, and Kerala across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Maharashtra', 'Kerala'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 3220,List the top 5 states by average PM10 in 2017 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 3221,"Plot the yearly average PM2.5 trends for Jammu and Kashmir, Sikkim, and Tamil Nadu from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jammu and Kashmir', 'Sikkim', 'Tamil Nadu'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Jammu and Kashmir vs Sikkim vs Tamil Nadu', width=550, height=320) return chart " 3222,"Plot the yearly average PM2.5 trends for Punjab, Haryana, and Bihar from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Punjab', 'Haryana', 'Bihar'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Punjab vs Haryana vs Bihar', width=550, height=320) return chart " 3223,Plot the weekly average PM2.5 for Jind in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Jind') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Jind 2023', width=600, height=300) return chart " 3224,"Create a grouped bar chart comparing the average PM2.5 for Jharkhand, Punjab, and Madhya Pradesh across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Punjab', 'Madhya Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 3225,List citys with their PM10 violation count and rate (>150 µg/m³) in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 150'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3226,"Plot the yearly average PM2.5 trends for Punjab, Chandigarh, and Nagaland from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Punjab', 'Chandigarh', 'Nagaland'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Punjab vs Chandigarh vs Nagaland', width=550, height=320) return chart " 3227,Report the city with the 2nd highest 25th percentile of PM10 in January 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 3228,Which union territory was the most polluted based on per capita PM2.5 exposure during 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'per_capita_pm', 'numerator': 'PM2.5', 'denominator': 'population'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'per_capita_pm', 'ascending': False}}] " 3229,"Create a grouped bar chart comparing the average PM2.5 for Uttarakhand, Andhra Pradesh, and Delhi across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttarakhand', 'Andhra Pradesh', 'Delhi'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 3230,Visualize the bottom 13 states with the lowest average PM2.5 in 2018 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2018] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(13, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 13 States by Average PM2.5 in 2018', width=500, height=300) return chart " 3231,Show the monthly average PM2.5 for Palkalaiperur in 2024 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Palkalaiperur') & (data['Timestamp'].dt.year == 2024)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Palkalaiperur 2024', width=450, height=280) " 3232,Report which city experienced the most minimal 25th percentile of PM2.5 throughout the Winter season of 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 3233,Which city recorded the peak 25th percentile of PM10 during the Monsoon season of 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 3234,Create a table showing annual mean PM10 levels for Jammu and Kashmir (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Jammu and Kashmir'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3235,"Plot the yearly average PM2.5 trends for Jammu and Kashmir, Sikkim, and Delhi from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jammu and Kashmir', 'Sikkim', 'Delhi'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Jammu and Kashmir vs Sikkim vs Delhi', width=550, height=320) return chart " 3236,Show a table of the 5 cleanest citys by average PM2.5 in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 3237,Create a table of PM2.5 standard violations (>60 µg/m³) per city in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3238,"On January 14, 2021, which station experienced the second-lowest PM10 readings?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 3239,Show a heatmap of average PM2.5 for the top 5 most polluted states by month for 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(5).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 5 Polluted States by Month (2018)', width=500, height=300) return chart " 3240,"Plot the yearly average PM2.5 trends for Odisha, Rajasthan, and Himachal Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Odisha', 'Rajasthan', 'Himachal Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Odisha vs Rajasthan vs Himachal Pradesh', width=550, height=320) return chart " 3241,Tabulate the yearly average PM10 trend for Aurangabad across all years.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Aurangabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3242,Show a monthly breakdown table of average PM2.5 for Hyderabad in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Hyderabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3243,Plot the monthly average PM2.5 trend for Madhya Pradesh from 2017 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Madhya Pradesh'].copy() df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly Average PM2.5 Trend – Madhya Pradesh (2017–2024)', width=600, height=300) return chart " 3244,Show a table of average PM2.5 and PM10 for all states in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3245,Identify the state with the 3rd highest 75th percentile of PM2.5 in March 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 3246,List the average PM10 for Punjab broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3247,"Visualize the monthly average PM10 for Uttarakhand, Andhra Pradesh, and Haryana in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttarakhand', 'Andhra Pradesh', 'Haryana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Uttarakhand, Andhra Pradesh, UP – 2023', width=550, height=320) return chart " 3248,Show a bar chart of the top 7 cities by median PM2.5 in 2020.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2020] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(7, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 7 Cities by Median PM2.5 in 2020', width=500, height=300) return chart " 3249,Generate a year-by-year summary table of PM10 readings for Delhi.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Delhi'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3250,Identify the state with the 2nd highest 75th percentile of PM10 in November 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 3251,"Plot the yearly average PM2.5 trends for Tripura, Manipur, and West Bengal from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tripura', 'Manipur', 'West Bengal'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Tripura vs Manipur vs West Bengal', width=550, height=320) return chart " 3252,Which city registered the 3rd lowest median PM2.5 during June 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 3253,List average PM10 by month for Mumbai in 2023 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Mumbai'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3254,Show the monthly average PM10 trend for Sawai Madhopur from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Sawai Madhopur'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Sawai Madhopur (2019–2024)', width=600, height=300) return chart " 3255,Generate a monthly average PM2.5 table for Jodhpur for the year 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Jodhpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3256,Plot the rolling 30-day average PM2.5 for Chandigarh in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Chandigarh') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Chandigarh 2023', width=600, height=300) " 3257,Tabulate the yearly average PM2.5 trend for Aurangabad across all years.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Aurangabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3258,Which state recorded the 3rd highest median PM2.5 in April 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 3259,"In February 2018, which city displayed the 2nd lowest 25th percentile of PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 3260,Create a ranked table of the 10 best-performing states by PM2.5 in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 3261,Plot the top 6 states by average PM2.5 in 2018 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2018] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(6, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 6 States by Average PM2.5 in 2018', width=500, height=300) return chart " 3262,Identify the city that registered the third lowest median PM10 during the Winter season of 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 3263,Show a cumulative area chart of PM2.5 readings for Bulandshahr across 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bulandshahr') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Bulandshahr 2024', width=600, height=300) return chart " 3264,Which station displayed the lowest 25th percentile of PM10 in August 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 3265,Show a monthly breakdown table of average PM2.5 for Aurangabad in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Aurangabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3266,Which city possessed the 2nd lowest 25th percentile for PM2.5 in the Summer season of 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 3267,Tabulate the monthly mean PM2.5 levels for Haryana during 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Haryana'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3268,Show PM10 exceedance count and rate (%) above 150 µg/m³ per state in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 150'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3269,Plot the top 14 states by average PM2.5 in 2024 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2024] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(14, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 14 States by Average PM2.5 in 2024', width=500, height=300) return chart " 3270,Report the city with the 2nd lowest median PM2.5 in October 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 3271,Show a pivot table of monthly average PM10 by state for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Delhi', 'Haryana', 'Jharkhand', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Odisha', 'Punjab', 'Rajasthan', 'Telangana', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3272,"On January 5, 2024, which city showed the second-highest average PM2.5 level?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 3273,Find a week exhibiting Parbhani's 3rd minimum PM10 levels for all specified years.," [{'op': 'FILTER', 'params': {'field': 'city', 'value': 'Parbhani'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'week'}}] " 3274,"Visualize the monthly average PM10 for Chhattisgarh, Jammu and Kashmir, and Odisha in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chhattisgarh', 'Jammu and Kashmir', 'Odisha'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Chhattisgarh, Jammu and Kashmir, UP – 2017', width=550, height=320) return chart " 3275,Tabulate the 15 worst citys for average PM2.5 in 2023 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 3276,"Which state having a land area exceeding 50,000 km² registers the 2nd minimum PM10 level, based on its standard deviation of PM10 level?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'std', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}] " 3277,"Create a grouped bar chart comparing the average PM2.5 for Rajasthan, Rajasthan, and Kerala across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Rajasthan', 'Kerala'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 3278,"Compare the monthly average PM2.5 of Araria, Milupara, and Yamuna Nagar in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Araria', 'Milupara', 'Yamuna Nagar'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Araria vs Milupara vs Yamuna Nagar – 2019', width=550, height=320) return chart " 3279,Determine the station with the highest 75th percentile of PM10 in December 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 3280,Show the monthly average PM10 trend for Tensa from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Tensa'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Tensa (2017–2022)', width=600, height=300) return chart " 3281,"In the COVID-19 lockdown period of April 2020, which city experienced the third-highest PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 3282,"Which union territory with a land area below 1,000 km² shows the highest PM10 level, based on its total PM10 level?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'sum', 'col': 'PM10'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}] " 3283,Show a cumulative area chart of PM2.5 readings for Gurugram across 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Gurugram') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Gurugram 2021', width=600, height=300) return chart " 3284,Determine which city got the 3rd lowest NCAP funding with respect to its average PM10 concentration in 2022 (FY 2021-22).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2022_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 3285,Identify the weekday in 2022 that registered the highest 25th percentile of PM10 pollution levels.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'Timestamp'}}] " 3286,"Compare the monthly average PM2.5 of Byrnihat, Saharsa, and Khurja in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Byrnihat', 'Saharsa', 'Khurja'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Byrnihat vs Saharsa vs Khurja – 2022', width=550, height=320) return chart " 3287,Show the monthly average PM2.5 for Coimbatore in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Coimbatore') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Coimbatore 2017', width=450, height=280) " 3288,"Show the top 13 states by average PM10 in 2018 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2018] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(13, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 13 States by Average PM10 in 2018', width=500, height=300) return chart " 3289,Show a pivot table of monthly average PM2.5 by city for Odisha in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Odisha'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Talcher']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3290,Plot the weekly average PM2.5 for Sonipat in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Sonipat') & (data['Timestamp'].dt.year == 2024)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Sonipat 2024', width=600, height=300) return chart " 3291,Plot the weekly average PM2.5 for Eloor in 2019 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Eloor') & (data['Timestamp'].dt.year == 2019)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Eloor 2019', width=600, height=300) return chart " 3292,Plot the top 7 states by average PM2.5 in 2019 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2019] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(7, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 7 States by Average PM2.5 in 2019', width=500, height=300) return chart " 3293,"Plot the yearly average PM2.5 trends for Jammu and Kashmir, Kerala, and Punjab from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jammu and Kashmir', 'Kerala', 'Punjab'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Jammu and Kashmir vs Kerala vs Punjab', width=550, height=320) return chart " 3294,"Visualize the monthly average PM10 for Arunachal Pradesh, Meghalaya, and Andhra Pradesh in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Arunachal Pradesh', 'Meghalaya', 'Andhra Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Arunachal Pradesh, Meghalaya, UP – 2018', width=550, height=320) return chart " 3295,Find a week exhibiting Thrissur's 2nd minimum PM2.5 levels for all specified years.," [{'op': 'FILTER', 'params': {'field': 'city', 'value': 'Thrissur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'week'}}] " 3296,"Create a grouped bar chart comparing the average PM2.5 for Jammu and Kashmir, Gujarat, and Gujarat across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jammu and Kashmir', 'Gujarat', 'Gujarat'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 3297,"Show descriptive statistics of PM10 (mean, median, std, min, max) per state in 2018."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'q25', 'median', 'q75']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3298,Determine the state that showed the highest average PM10 over the Winter season of 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 3299,Plot the rolling 30-day average PM2.5 for Uttarakhand in 2017 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Uttarakhand') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Uttarakhand 2017', width=600, height=300) " 3300,Show the monthly average PM2.5 for Tumidih in 2023 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Tumidih') & (data['Timestamp'].dt.year == 2023)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Tumidih 2023', width=450, height=280) " 3301,Tabulate average PM2.5 for each city in Andhra Pradesh across all months of 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Amaravati', 'Rajamahendravaram', 'Tirupati', 'Visakhapatnam']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3302,"Visualize the monthly average PM10 for Andhra Pradesh, Telangana, and Kerala in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Telangana', 'Kerala'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Andhra Pradesh, Telangana, UP – 2024', width=550, height=320) return chart " 3303,Show the monthly average PM10 trend for Manguraha from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Manguraha'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Manguraha (2019–2024)', width=600, height=300) return chart " 3304,Identify the city that recorded the peak 75th percentile of PM2.5 during the Post-Monsoon season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 3305,Which city registered the 3rd highest 75th percentile of PM10 during March 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 3306,Show a cumulative area chart of PM2.5 readings for Sikar across 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Sikar') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Sikar 2023', width=600, height=300) return chart " 3307,How many times did Sonipat city surpass the WHO guideline for PM10 in 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 15.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 3308,"Plot the yearly average PM2.5 trends for Haryana, Tamil Nadu, and Nagaland from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Tamil Nadu', 'Nagaland'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Haryana vs Tamil Nadu vs Nagaland', width=550, height=320) return chart " 3309,Tabulate the 10 citys with the least PM2.5 pollution in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 3310,Tabulate mean PM2.5 and land area for each state in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3311,"Visualize the monthly average PM10 for Chandigarh, West Bengal, and Meghalaya in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chandigarh', 'West Bengal', 'Meghalaya'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Chandigarh, West Bengal, UP – 2019', width=550, height=320) return chart " 3312,"Show the variability of PM10 across citys in 2017 using mean, median, and standard deviation."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3313,"Create a table showing top 20 states ranked by PM2.5 in 2019, also showing PM10."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 3314,Show the monthly average PM2.5 for Cuttack in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Cuttack') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Cuttack 2017', width=450, height=280) " 3315,Plot the weekly average PM2.5 for Pathardih in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Pathardih') & (data['Timestamp'].dt.year == 2024)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Pathardih 2024', width=600, height=300) return chart " 3316,"In 2024, which state ranked with the third largest decrease in 75th percentile PM2.5 levels from October to December?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 3317,Plot the monthly average PM2.5 trend for Gujarat from 2017 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Gujarat'].copy() df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly Average PM2.5 Trend – Gujarat (2017–2024)', width=600, height=300) return chart " 3318,Show the monthly average PM10 trend for Mandideep from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Mandideep'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Mandideep (2019–2024)', width=600, height=300) return chart " 3319,Show the number of days each state exceeded a PM2.5 threshold of 60 µg/m³ in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3320,Which 20 citys recorded the highest average PM10 levels in 2017? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 3321,Tabulate average and median PM2.5 for all states in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3322,Show the monthly average PM2.5 for Korba in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Korba') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Korba 2017', width=450, height=280) " 3323,Which city had the lowest average PM2.5 in October 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 3324,"Create a faceted bar chart showing top 7 states by average PM2.5 per year for 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year.isin([2017,2018,2019,2020])].copy() df['Year'] = df['Timestamp'].dt.year agg = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() top = agg.groupby('Year').apply(lambda x: x.nlargest(7,'PM2.5')).reset_index(drop=True) chart = alt.Chart(top).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Avg PM2.5'), y=alt.Y('state:N', sort='-x'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet(facet='Year:O', columns=2).properties(title='Top 7 States by PM2.5 per Year') return chart " 3325,"Which state (excluding Union Territories) possesses the 2nd smallest land area among the top 10 most polluted states, based on the standard deviation of PM10 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'std', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 10, 'ret': 'state'}}] " 3326,Tabulate average PM10 for each state across all months in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Arunachal Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Chhattisgarh', 'Delhi', 'Gujarat', 'Haryana', 'Himachal Pradesh', 'Jammu and Kashmir', 'Jharkhand', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Manipur', 'Meghalaya', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh', 'Uttarakhand', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3327,Which station registered the 3rd lowest median PM2.5 during March 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 3328,Generate a monthly average PM2.5 table for Delhi for the year 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Delhi'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3329,Which city recorded the 2nd lowest 75th percentile of PM2.5 in January 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 3330,Determine the city exhibiting the lowest 75th percentile of PM2.5 in August 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 3331,Determine the station with the minimum 25th percentile for PM2.5 in December 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 3332,What count of Rajasthan stations surpassed the WHO guideline for PM10 in 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 15.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 3333,Show a monthly breakdown table of average PM10 for Telangana in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Telangana'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3334,"Create a grouped bar chart comparing the average PM2.5 for Himachal Pradesh, Assam, and Uttar Pradesh across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Himachal Pradesh', 'Assam', 'Uttar Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 3335,Show the monthly average PM2.5 for Nandesari in 2023 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Nandesari') & (data['Timestamp'].dt.year == 2023)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Nandesari 2023', width=450, height=280) " 3336,"Compare the monthly average PM2.5 of Surat, Chittorgarh, and Bathinda in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Surat', 'Chittorgarh', 'Bathinda'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Surat vs Chittorgarh vs Bathinda – 2023', width=550, height=320) return chart " 3337,"Plot the yearly average PM2.5 trends for Jammu and Kashmir, Chhattisgarh, and Manipur from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jammu and Kashmir', 'Chhattisgarh', 'Manipur'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Jammu and Kashmir vs Chhattisgarh vs Manipur', width=550, height=320) return chart " 3338,"Compare the monthly average PM2.5 of Buxar, Prayagraj, and Ghaziabad in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Buxar', 'Prayagraj', 'Ghaziabad'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Buxar vs Prayagraj vs Ghaziabad – 2024', width=550, height=320) return chart " 3339,"Which city showed the second-highest median PM10 on March 31, 2019?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 3340,"Which state with a land area greater than 50,000 km² shows the 3rd lowest PM10 level, according to its 75th percentile PM10 level?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}] " 3341,"Plot the yearly average PM2.5 trends for Sikkim, Chhattisgarh, and Tamil Nadu from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Sikkim', 'Chhattisgarh', 'Tamil Nadu'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Sikkim vs Chhattisgarh vs Tamil Nadu', width=550, height=320) return chart " 3342,"Create a grouped bar chart comparing the average PM2.5 for Madhya Pradesh, Odisha, and Uttarakhand across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Madhya Pradesh', 'Odisha', 'Uttarakhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 3343,Which state registered the 2nd minimum median PM10 in the Summer season of 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 3344,Which state showed the lowest average PM2.5 in February 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 3345,"Which city recorded the second-lowest PM10 values on January 14, 2022?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 3346,Show a heatmap of average PM2.5 for the top 15 most polluted states by month for 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(15).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 15 Polluted States by Month (2022)', width=500, height=300) return chart " 3347,"Compare the monthly average PM2.5 of Prayagraj, Narnaul, and Udupi in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Prayagraj', 'Narnaul', 'Udupi'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Prayagraj vs Narnaul vs Udupi – 2024', width=550, height=320) return chart " 3348,"Visualize the monthly average PM10 for Sikkim, Bihar, and Tamil Nadu in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Sikkim', 'Bihar', 'Tamil Nadu'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Sikkim, Bihar, UP – 2022', width=550, height=320) return chart " 3349,"Identify the city with the third-highest 75th percentile for PM10 on March 31, 2022."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 3350,Show the number of days each state exceeded a PM2.5 threshold of 100 µg/m³ in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3351,Tabulate both PM2.5 and PM10 averages by state for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3352,"Visualize the monthly average PM10 for Jharkhand, Nagaland, and Madhya Pradesh in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Nagaland', 'Madhya Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Jharkhand, Nagaland, UP – 2021', width=550, height=320) return chart " 3353,Plot the top 8 states by average PM2.5 in 2024 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2024] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(8, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 8 States by Average PM2.5 in 2024', width=500, height=300) return chart " 3354,"Create a grouped bar chart comparing the average PM2.5 for Rajasthan, Telangana, and Arunachal Pradesh across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Telangana', 'Arunachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 3355,Which 20 citys recorded the highest average PM2.5 levels in 2019? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 3356,"Create a grouped bar chart comparing the average PM2.5 for Jharkhand, Sikkim, and Nagaland across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Sikkim', 'Nagaland'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 3357,Plot the rolling 30-day average PM2.5 for Mizoram in 2017 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Mizoram') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Mizoram 2017', width=600, height=300) " 3358,How many times did Sawai Madhopur city go above 45 µg/m³ of PM10 in 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 45.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 3359,Create a ranked table of the 10 best-performing states by PM2.5 in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 3360,"On March 31, 2019, which station had the minimum median PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 3361,How many times did Brajrajnagar city go above the WHO guideline for PM10 in 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 15.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 3362,On which date in the past three years did Bagalkot register its 2nd minimum PM10 level?," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 3}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'Timestamp'}}] " 3363,Tabulate days with PM10 > 150 µg/m³ and exceedance percentage per city in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 150'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3364,"Create a grouped bar chart comparing the average PM2.5 for Arunachal Pradesh, Jammu and Kashmir, and West Bengal across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Arunachal Pradesh', 'Jammu and Kashmir', 'West Bengal'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 3365,List the average PM10 for Tamil Nadu broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3366,Which station registered the 2nd maximum 75th percentile of PM2.5 during the Post-Monsoon season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 3367,Create a ranked table of the 10 best-performing citys by PM2.5 in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 3368,Plot the distribution of PM2.5 values in Bihar across all years using a histogram.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Bihar'].dropna(subset=['PM2.5']) df = df[['PM2.5']] chart = alt.Chart(df).mark_bar(color='steelblue', opacity=0.75).encode( x=alt.X('PM2\.5:Q', bin=alt.Bin(maxbins=40), title='PM2.5 (µg/m³)'), y=alt.Y('count()', title='Number of Observations'), tooltip=[alt.Tooltip('PM2\.5:Q', bin=True), 'count()'] ).properties(title='PM2.5 Distribution – Bihar (All Years)', width=500, height=300) return chart " 3369,Determine the median PM2.5 level on Saturdays in Arunachal Pradesh.," [{'op': 'FILTER', 'params': {'field': 'state', 'value': 'Arunachal Pradesh'}}] " 3370,List the bottom 15 states with the lowest average PM2.5 in 2023 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 3371,"Compare the monthly average PM2.5 of Latur, Dharwad, and Balasore in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Latur', 'Dharwad', 'Balasore'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Latur vs Dharwad vs Balasore – 2022', width=550, height=320) return chart " 3372,Show the monthly average PM2.5 for Belgaum in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Belgaum') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Belgaum 2019', width=450, height=280) " 3373,"Create a grouped bar chart comparing the average PM2.5 for Rajasthan, Sikkim, and Mizoram across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Sikkim', 'Mizoram'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 3374,Which city had the second-lowest 75th percentile for PM10 in August 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 3375,Plot the rolling 30-day average PM2.5 for Odisha in 2017 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Odisha') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Odisha 2017', width=600, height=300) " 3376,Generate a monthly average PM2.5 table for Meerut for the year 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Meerut'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3377,Show a table of average PM2.5 and PM10 for all citys in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3378,Which state had the lowest 75th percentile of PM2.5 in July 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 3379,Which city recorded the minimum 25th percentile of PM2.5 during the Summer season of 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 3380,Which state experienced the highest rise in median PM2.5 levels between January 2019 and January 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 3381,List all citys with their average PM2.5 and PM10 levels in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3382,What is the mean PM10 value on Fridays in Manipur?," [{'op': 'FILTER', 'params': {'field': 'state', 'value': 'Manipur'}}] " 3383,Create a table of PM10 standard violations (>100 µg/m³) per city in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3384,How many times did Samastipur city exceed 30 µg/m³ of PM10 in the year 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 30.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 3385,Determine the state exhibiting the 3rd highest 25th percentile of PM10 in April 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 3386,Show a cumulative area chart of PM2.5 readings for Jhunjhunu across 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Jhunjhunu') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Jhunjhunu 2023', width=600, height=300) return chart " 3387,Show a ranked table of the 5 most polluted states by average PM10 in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 3388,Identify the state that received the 2nd lowest NCAP funding relative to its median PM10 concentration in 2022 (FY 2021-22).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2022_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 3389,"Show the mean, median and standard deviation of PM10 per city in 2021 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3390,Show a year-wise table of average PM10 for Howrah from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Howrah'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3391,"Compare the monthly average PM2.5 of Ariyalur, Bahadurgarh, and Kalyan in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Ariyalur', 'Bahadurgarh', 'Kalyan'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Ariyalur vs Bahadurgarh vs Kalyan – 2019', width=550, height=320) return chart " 3392,Which city experienced the most significant drop in its 25th percentile PM2.5 levels between October and December 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 3393,"Identify the city with the third-highest median PM10 on March 31, 2024."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 3394,Tabulate average PM10 for each city in Madhya Pradesh across all months of 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Dewas', 'Mandideep', 'Pithampur', 'Singrauli', 'Ujjain']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3395,"Compare the monthly average PM2.5 of Bhilai, Kanpur, and Ballabgarh in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Bhilai', 'Kanpur', 'Ballabgarh'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Bhilai vs Kanpur vs Ballabgarh – 2023', width=550, height=320) return chart " 3396,"Which state with a land area greater than 50,000 km² shows the 5th lowest PM2.5 level, according to its average PM2.5 level?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}] " 3397,Identify the state with the lowest median PM2.5 for December 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 3398,Identify the station with the 2nd lowest 25th percentile of PM10 in December 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 3399,Plot the weekly average PM2.5 for Pune in 2021 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Pune') & (data['Timestamp'].dt.year == 2021)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Pune 2021', width=600, height=300) return chart " 3400,Show a cumulative area chart of PM2.5 readings for Pali across 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Pali') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Pali 2023', width=600, height=300) return chart " 3401,"Report the state (excluding UTs) having the 2nd smallest population among the top 10 most polluted states, when pollution is measured by average PM10 levels."," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 10, 'ret': 'state'}}] " 3402,"Create a grouped bar chart comparing the average PM2.5 for Jharkhand, Arunachal Pradesh, and Tripura across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Arunachal Pradesh', 'Tripura'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 3403,"In 2023, which station ranked third for the most substantial fall in 75th percentile PM10 levels from October to December?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 3404,"Scatter plot PM2.5 vs PM10 for Haryana stations in 2024, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Haryana') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Haryana Stations 2024', width=450, height=350) " 3405,Create a month-wise PM10 breakdown table across cities in Madhya Pradesh for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Bhopal', 'Damoh', 'Dewas', 'Gwalior', 'Indore', 'Jabalpur', 'Katni', 'Maihar', 'Mandideep', 'Pithampur', 'Ratlam', 'Sagar', 'Satna', 'Singrauli', 'Ujjain']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3406,List states with their PM2.5 violation count and rate (>100 µg/m³) in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3407,"Plot the yearly average PM2.5 trends for Manipur, Uttarakhand, and Puducherry from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Manipur', 'Uttarakhand', 'Puducherry'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Manipur vs Uttarakhand vs Puducherry', width=550, height=320) return chart " 3408,"Identify the state that had the third-highest PM10 values on January 14, 2024."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 3409,Plot the weekly average PM2.5 for Gaya in 2018 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Gaya') & (data['Timestamp'].dt.year == 2018)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Gaya 2018', width=600, height=300) return chart " 3410,"Create a grouped bar chart comparing the average PM2.5 for Assam, Telangana, and Nagaland across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Assam', 'Telangana', 'Nagaland'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 3411,Which 20 states recorded the highest average PM2.5 levels in 2018? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 3412,Which state registered the 3rd minimum average PM2.5 during the Post-Monsoon season of 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 3413,Which 10 states had the lowest mean PM10 in 2018? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 3414,Create a table showing annual mean PM10 levels for Agra (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Agra'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3415,"Create a grouped bar chart comparing the average PM2.5 for Rajasthan, Madhya Pradesh, and Uttar Pradesh across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Madhya Pradesh', 'Uttar Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 3416,"Show the mean, median and standard deviation of PM10 per state in 2019 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3417,Show a table of the top 15 states by average PM2.5 in 2022 including their PM10 levels too.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 3418,Which station recorded the minimum 75th percentile of PM2.5 during the Monsoon season of 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 3419,"On March 31, 2021, which city recorded the third-highest 25th percentile for PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 3420,Show the monthly average PM2.5 for Brajrajnagar in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Brajrajnagar') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Brajrajnagar 2020', width=450, height=280) " 3421,Show the monthly average PM2.5 for Katni in 2024 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Katni') & (data['Timestamp'].dt.year == 2024)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Katni 2024', width=450, height=280) " 3422,"Visualize the monthly average PM10 for Jharkhand, Puducherry, and Chhattisgarh in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Puducherry', 'Chhattisgarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Jharkhand, Puducherry, UP – 2023', width=550, height=320) return chart " 3423,Show a pivot table of monthly average PM10 by city for Karnataka in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Bagalkot', 'Bengaluru', 'Bidar', 'Chamarajanagar', 'Chikkaballapur', 'Chikkamagaluru', 'Davanagere', 'Gadag', 'Hubballi', 'Kalaburagi', 'Kolar', 'Koppal', 'Madikeri', 'Mysuru', 'Raichur', 'Ramanagara', 'Shivamogga', 'Vijayapura', 'Yadgir']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3424,"Plot the yearly average PM2.5 trends for Himachal Pradesh, Haryana, and Punjab from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Himachal Pradesh', 'Haryana', 'Punjab'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Himachal Pradesh vs Haryana vs Punjab', width=550, height=320) return chart " 3425,Tabulate the yearly average PM2.5 trend for Gujarat across all years.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Gujarat'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3426,"Plot the yearly average PM2.5 trends for West Bengal, Arunachal Pradesh, and Bihar from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['West Bengal', 'Arunachal Pradesh', 'Bihar'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: West Bengal vs Arunachal Pradesh vs Bihar', width=550, height=320) return chart " 3427,Identify the city with the lowest NCAP funding considering its total PM2.5 concentration in 2022 (FY 2021-22).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'sum', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2022_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 3428,Create a table of PM10 standard violations (>150 µg/m³) per city in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3429,"Compare the monthly average PM2.5 of Bikaner, Thane, and Howrah in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Bikaner', 'Thane', 'Howrah'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Bikaner vs Thane vs Howrah – 2024', width=550, height=320) return chart " 3430,How many times did Suakati city go above the WHO guideline for PM10 in 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 15.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 3431,"Tabulate the distribution of PM10 per state in 2022 including mean, median, and std."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3432,Show the monthly average PM10 trend for Kadapa from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Kadapa'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Kadapa (2019–2024)', width=600, height=300) return chart " 3433,Plot the rolling 30-day average PM2.5 for Manipur in 2019 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Manipur') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Manipur 2019', width=600, height=300) " 3434,"Show the top 7 states by average PM10 in 2022 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2022] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(7, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 7 States by Average PM10 in 2022', width=500, height=300) return chart " 3435,Create a heatmap showing the average PM2.5 by month (x-axis) and year (y-axis) for Jharkhand.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Jharkhand'].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Year:N', title='Year'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='Avg PM2.5'), tooltip=['Year:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Jharkhand (Month × Year)', width=500, height=280) return chart " 3436,Which station showed the 2nd highest average PM2.5 in June 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 3437,"Which state (excluding Union Territories) possesses the smallest land area among the top 10 most polluted states, based on average PM2.5 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 10, 'ret': 'state'}}] " 3438,Which station had the 2nd lowest 75th percentile of PM10 in May 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 3439,Tabulate the 5 states with the least PM2.5 pollution in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 3440,Tabulate the top 10 states for PM2.5 in 2023 along with their corresponding PM10 values.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 3441,"Create a grouped bar chart comparing the average PM2.5 for Madhya Pradesh, Mizoram, and Meghalaya across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Madhya Pradesh', 'Mizoram', 'Meghalaya'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 3442,Identify the station with the 2nd highest 75th percentile of PM10 in October 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 3443,Show the monthly average PM10 trend for Lucknow from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Lucknow'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Lucknow (2017–2022)', width=600, height=300) return chart " 3444,Identify the least polluted state concerning per capita PM2.5 exposure in 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'per_capita_pm', 'numerator': 'PM2.5', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'per_capita_pm', 'ascending': True}}] " 3445,Which state recorded the peak 75th percentile of PM10 during the Summer season of 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 3446,Show the monthly average PM2.5 for Kochi in 2022 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Kochi') & (data['Timestamp'].dt.year == 2022)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Kochi 2022', width=450, height=280) " 3447,How many times did Bangalore city go above the WHO guideline for PM10 in 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 15.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 3448,"Identify the city that showed the third-highest average PM2.5 concentration on January 5, 2023."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 3449,Name the city showing the highest 25th percentile of PM10 for March 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 3450,Generate a monthly average PM2.5 table for Bihar for the year 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Bihar'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3451,Show average PM10 per capita by state in 2018 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM10 per million', 'numerator': 'PM10', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'PM10 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3452,Show a pivot table of monthly average PM10 by state for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Delhi', 'Karnataka', 'Maharashtra', 'Telangana', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3453,"Visualize the monthly average PM10 for Tamil Nadu, Nagaland, and Odisha in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Nagaland', 'Odisha'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Tamil Nadu, Nagaland, UP – 2018', width=550, height=320) return chart " 3454,Show a cumulative area chart of PM2.5 readings for Surat across 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Surat') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Surat 2022', width=600, height=300) return chart " 3455,"In March 2020, which city recorded the highest median PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 3456,Which station had the 3rd lowest median PM2.5 in May 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 3457,Report the state that had the lowest median PM2.5 in July 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 3458,"Which state (excluding Union Territories) possesses the 3rd smallest land area among the top 10 most polluted states, based on the variance of PM2.5 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'var', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 10, 'ret': 'state'}}] " 3459,"In 2018, which week of the year was associated with the third-highest 75th percentile for PM10 concentrations?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'week'}}] " 3460,Generate a year-by-year summary table of PM10 readings for Gandhinagar.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Gandhinagar'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3461,Show the monthly average PM10 trend for Yadgir from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Yadgir'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Yadgir (2019–2024)', width=600, height=300) return chart " 3462,"Within the last five years in Nanded, on what date was the PM2.5 level the second highest?"," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 5}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'Timestamp'}}] " 3463,Show a pivot table of monthly average PM10 by city for Kerala in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Eloor', 'Kollam', 'Thiruvananthapuram', 'Thrissur']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3464,"Visualize the monthly average PM10 for Kerala, Delhi, and Assam in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Kerala', 'Delhi', 'Assam'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Kerala, Delhi, UP – 2024', width=550, height=320) return chart " 3465,Show a cumulative area chart of PM2.5 readings for Bareilly across 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bareilly') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Bareilly 2023', width=600, height=300) return chart " 3466,Show the monthly average PM2.5 for Damoh in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Damoh') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Damoh 2019', width=450, height=280) " 3467,"Show mean, median, minimum, and maximum PM2.5 for each state in 2024 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3468,Which station registered the 2nd minimum average PM2.5 during the Post-Monsoon season of 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 3469,Which station showed the third-highest 75th percentile for PM10 in September 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 3470,Report which state experienced the third lowest median PM10 throughout the Summer season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 3471,Generate a city × month cross-tab of mean PM10 for Assam in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Assam'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Byrnihat', 'Guwahati', 'Nagaon', 'Nalbari', 'Silchar', 'Sivasagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3472,Identify the state with the 2nd lowest 25th percentile of PM10 in July 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 3473,Which state showed the 2nd highest average PM10 in the Winter season of 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 3474,Generate a city × month cross-tab of mean PM2.5 for Tamil Nadu in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Chennai', 'Gummidipoondi']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3475,"Visualize the monthly average PM10 for Puducherry, Maharashtra, and Bihar in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'Maharashtra', 'Bihar'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Puducherry, Maharashtra, UP – 2018', width=550, height=320) return chart " 3476,"Plot the yearly average PM2.5 trends for Jammu and Kashmir, Bihar, and Puducherry from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jammu and Kashmir', 'Bihar', 'Puducherry'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Jammu and Kashmir vs Bihar vs Puducherry', width=550, height=320) return chart " 3477,Create a month-wise summary of average PM2.5 for Noida in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Noida'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3478,"Create a grouped bar chart comparing the average PM2.5 for Arunachal Pradesh, Rajasthan, and Haryana across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Arunachal Pradesh', 'Rajasthan', 'Haryana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 3479,Create a table showing PM2.5 spread (min to max) and central tendency per city for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3480,Show how average PM10 varied month by month for Kolkata in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Kolkata'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3481,Identify the state that saw the least significant fall in median PM2.5 levels when comparing December 2020 to October 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 3482,"In 2022, which of the defined seasons (Winter, Summer, Monsoon, Post-Monsoon) showed the second-highest average PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'season'}}] " 3483,Find a week exhibiting Jalore's maximum PM2.5 levels for all specified years.," [{'op': 'FILTER', 'params': {'field': 'city', 'value': 'Jalore'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'week'}}] " 3484,List the bottom 5 citys with the lowest average PM2.5 in 2021 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 3485,"Create a grouped bar chart comparing the average PM2.5 for Madhya Pradesh, Odisha, and Puducherry across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Madhya Pradesh', 'Odisha', 'Puducherry'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 3486,Determine which city got the 5th lowest NCAP funding with respect to the standard deviation of its PM10 concentration in 2021 (FY 2020-21).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'std', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 3487,Visualize the bottom 10 states with the lowest average PM2.5 in 2018 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2018] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(10, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 10 States by Average PM2.5 in 2018', width=500, height=300) return chart " 3488,Identify the station that showed the second lowest average PM10 during the Winter season of 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 3489,Show a year-wise table of average PM10 for Moradabad from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Moradabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3490,Show a year-wise table of average PM2.5 for Ghaziabad from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Ghaziabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3491,Generate a table showing the 20 most polluted citys based on mean PM10 for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 3492,Report which state possessed the 2nd highest 25th percentile of PM10 throughout the Post-Monsoon season of 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 3493,"Comparing December 2020 to October 2020, which city showed the second most significant drop in 25th percentile PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 3494,List states ranked by PM2.5 concentration relative to their area in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, { 'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM2.5 per km²', 'numerator': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)', 'PM2.5 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3495,Report which state registered the 3rd most minimal 75th percentile of PM2.5 throughout the Summer season of 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 3496,"Compare the monthly average PM2.5 of Hanumangarh, Jhalawar, and Noida in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Hanumangarh', 'Jhalawar', 'Noida'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Hanumangarh vs Jhalawar vs Noida – 2018', width=550, height=320) return chart " 3497,"For the period October to December 2020, which state had the largest decrease in 25th percentile PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 3498,Show how average PM2.5 varied month by month for Telangana in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Telangana'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3499,Report the state with the lowest 75th percentile of PM2.5 in September 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 3500,List the bottom 20 citys with the lowest average PM2.5 in 2018 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 3501,Which city recorded the lowest 25th percentile PM2.5 value in June 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 3502,Show annual average PM10 for Faridabad as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Faridabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3503,Determine the state exhibiting the 3rd most minimal average PM10 over the Post-Monsoon season of 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 3504,"In 2024, which state will rank with the smallest reduction in median PM10 levels from October to December?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 3505,"Show descriptive statistics of PM2.5 (mean, median, std, min, max) per state in 2023."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3506,Show a ranked table of the 15 most polluted citys by average PM10 in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 3507,Plot the monthly average PM2.5 trend for Assam from 2017 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Assam'].copy() df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly Average PM2.5 Trend – Assam (2017–2024)', width=600, height=300) return chart " 3508,Which station had the 2nd highest average PM2.5 in December 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 3509,Show a pivot table of monthly average PM2.5 by city for Karnataka in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Bagalkot', 'Belgaum', 'Bengaluru', 'Bidar', 'Chamarajanagar', 'Chikkaballapur', 'Chikkamagaluru', 'Davanagere', 'Dharwad', 'Gadag', 'Hassan', 'Haveri', 'Hubballi', 'Kalaburagi', 'Karwar', 'Koppal', 'Madikeri', 'Mangalore', 'Mysuru', 'Raichur', 'Ramanagara', 'Shivamogga', 'Vijayapura', 'Yadgir']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3510,Plot the monthly average PM2.5 trend for Nagaland from 2017 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Nagaland'].copy() df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly Average PM2.5 Trend – Nagaland (2017–2024)', width=600, height=300) return chart " 3511,Tabulate mean PM10 alongside state population figures for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3512,Identify the state with the highest average PM10 concentration for May 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 3513,Plot the distribution of PM2.5 values in Nagaland across all years using a histogram.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Nagaland'].dropna(subset=['PM2.5']) df = df[['PM2.5']] chart = alt.Chart(df).mark_bar(color='steelblue', opacity=0.75).encode( x=alt.X('PM2\.5:Q', bin=alt.Bin(maxbins=40), title='PM2.5 (µg/m³)'), y=alt.Y('count()', title='Number of Observations'), tooltip=[alt.Tooltip('PM2\.5:Q', bin=True), 'count()'] ).properties(title='PM2.5 Distribution – Nagaland (All Years)', width=500, height=300) return chart " 3514,Report the station with the 3rd lowest average PM2.5 in May 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 3515,Visualize the bottom 10 states with the lowest average PM2.5 in 2020 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2020] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(10, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 10 States by Average PM2.5 in 2020', width=500, height=300) return chart " 3516,Generate a descriptive stats table for PM10 grouped by city in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3517,Determine the station with the 2nd highest 25th percentile of PM2.5 in February 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 3518,List how many days each city breached the PM2.5 limit of 60 µg/m³ in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3519,Identify the state with the 3rd lowest average PM2.5 for January 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 3520,"Scatter plot PM2.5 vs PM10 for Kerala stations in 2024, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Kerala') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Kerala Stations 2024', width=450, height=350) " 3521,Show the monthly average PM10 trend for Amaravati from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Amaravati'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Amaravati (2019–2024)', width=600, height=300) return chart " 3522,Create a table of state PM10 levels and geographic area for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3523,Show the monthly average PM2.5 for Suakati in 2022 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Suakati') & (data['Timestamp'].dt.year == 2022)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Suakati 2022', width=450, height=280) " 3524,"In February 2023, report the station with the 2nd lowest 25th percentile of PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 3525,Show how many times PM2.5 exceeded 60 µg/m³ per day across states in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3526,"Compare the monthly average PM2.5 of Amritsar, Khanna, and Tonk in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Amritsar', 'Khanna', 'Tonk'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Amritsar vs Khanna vs Tonk – 2022', width=550, height=320) return chart " 3527,List the top 15 states by average PM2.5 in 2023 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 3528,Create a summary table ranking the top 15 citys by PM2.5 concentration in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 3529,"Create a grouped bar chart comparing the average PM2.5 for Bihar, Delhi, and Manipur across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Bihar', 'Delhi', 'Manipur'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 3530,Create a statistical summary table of PM2.5 readings by city for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3531,"In August 2022, which city registered the highest average PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 3532,Identify the city with the 3rd highest median PM10 in December 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 3533,Show a heatmap of average PM2.5 for the top 13 most polluted states by month for 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(13).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 13 Polluted States by Month (2018)', width=500, height=300) return chart " 3534,Tabulate average PM2.5 for each city in Maharashtra across all months of 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Aurangabad', 'Chandrapur', 'Nagpur', 'Nashik', 'Thane']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3535,On which date in the last three years did Kollam record its 2nd highest PM2.5 level?," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 3}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'Timestamp'}}] " 3536,"Visualize the monthly average PM10 for Gujarat, Nagaland, and Telangana in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Gujarat', 'Nagaland', 'Telangana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Gujarat, Nagaland, UP – 2024', width=550, height=320) return chart " 3537,Show a scatter plot of total NCAP funding vs average PM2.5 (2021) per state.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): pm = data[data['Timestamp'].dt.year == 2021].groupby('state')['PM2.5'].mean().reset_index() funding = ncap_funding_data.groupby('state')['Total fund released'].sum().reset_index() df = pm.merge(funding, on='state').dropna() chart = alt.Chart(df).mark_point(filled=True, size=100).encode( x=alt.X('Total fund released:Q', title='Total NCAP Funding (Cr)'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 – 2021 (µg/m³)'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('Total fund released:Q', format='.1f')] ).properties(title='NCAP Funding vs Average PM2.5 by State (2021)', width=450, height=350) return chart " 3538,Plot the weekly average PM2.5 for Rohtak in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Rohtak') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Rohtak 2023', width=600, height=300) return chart " 3539,"In 2021, which week of the year corresponded to the second-highest average PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'week'}}] " 3540,Tabulate the yearly average PM10 trend for Maharashtra across all years.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3541,Which state had the highest 75th percentile of PM10 in February 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 3542,Show the monthly average PM2.5 for Thrissur in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Thrissur') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Thrissur 2017', width=450, height=280) " 3543,"Identify the state that had the second-lowest PM10 concentrations on August 15, 2023."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 3544,Which state had the highest median PM2.5 in July 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 3545,List the top 5 citys by average PM2.5 in 2018 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 3546,Show a pivot table of monthly average PM10 by city for Punjab in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Amritsar', 'Bathinda', 'Jalandhar', 'Khanna', 'Ludhiana', 'Mandi Gobindgarh', 'Patiala', 'Rupnagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3547,Report the state that had the 3rd highest 75th percentile of PM2.5 in January 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 3548,Determine which state had the highest NCAP funding relative to its 75th percentile of PM2.5 concentration in 2021 (FY 2020-21).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 3549,"Compare the monthly average PM2.5 of Kanchipuram, Bhubaneswar, and Vatva in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Kanchipuram', 'Bhubaneswar', 'Vatva'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Kanchipuram vs Bhubaneswar vs Vatva – 2019', width=550, height=320) return chart " 3550,Which 5 citys recorded the highest average PM2.5 levels in 2020? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 3551,Show the monthly average PM2.5 for Pimpri-Chinchwad in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Pimpri-Chinchwad') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Pimpri-Chinchwad 2020', width=450, height=280) " 3552,Tabulate mean PM2.5 alongside state population figures for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3553,Which station had the highest median PM2.5 in May 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 3554,"Plot the yearly average PM2.5 trends for Odisha, Bihar, and Bihar from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Odisha', 'Bihar', 'Bihar'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Odisha vs Bihar vs Bihar', width=550, height=320) return chart " 3555,"Plot the yearly average PM2.5 trends for Odisha, Tamil Nadu, and Himachal Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Odisha', 'Tamil Nadu', 'Himachal Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Odisha vs Tamil Nadu vs Himachal Pradesh', width=550, height=320) return chart " 3556,Report the station that had the 2nd lowest average PM2.5 in April 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 3557,Determine which state had the highest NCAP funding relative to the variance of its PM10 concentration in 2022 (FY 2021-22).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'var', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2022_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 3558,Create a table of PM10 exceedance frequency above 150 µg/m³ by city for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 150'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3559,Report which city possessed the 2nd most minimal 75th percentile of PM10 throughout the Winter season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 3560,Tabulate days with PM2.5 > 100 µg/m³ and exceedance percentage per city in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3561,Identify the city with the 3rd highest average PM2.5 in December 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 3562,Which city had the highest median PM10 in September 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 3563,Report which station possessed the 2nd most minimal 25th percentile of PM2.5 throughout the Post-Monsoon season of 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 3564,Show a monthly bar chart of the number of days Odisha exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Odisha') & (data['Timestamp'].dt.year == 2022)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Odisha Exceeded WHO PM2.5 Guideline per Month – 2022', width=500, height=300) return chart " 3565,"Show the mean, median and standard deviation of PM10 per state in 2022 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3566,"Tabulate PM2.5 levels, population, and land area per state in 2017."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': { 'map': { 'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3567,"Create a faceted bar chart showing top 6 states by average PM2.5 per year for 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year.isin([2021,2022,2023,2024])].copy() df['Year'] = df['Timestamp'].dt.year agg = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() top = agg.groupby('Year').apply(lambda x: x.nlargest(6,'PM2.5')).reset_index(drop=True) chart = alt.Chart(top).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Avg PM2.5'), y=alt.Y('state:N', sort='-x'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet(facet='Year:O', columns=2).properties(title='Top 6 States by PM2.5 per Year') return chart " 3568,"Report which state documented the minimum PM10 level on January 27, 2023."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 3569,Determine the state with the third-lowest median PM10 reading for October 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 3570,"Show the mean, median and standard deviation of PM10 per city in 2018 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3571,Show the monthly average PM10 trend for Mysuru from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Mysuru'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Mysuru (2017–2022)', width=600, height=300) return chart " 3572,"Create a grouped bar chart comparing the average PM2.5 for Jharkhand, Uttarakhand, and Delhi across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Uttarakhand', 'Delhi'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 3573,Tabulate the 20 citys with the least PM10 pollution in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 3574,Show a year-wise table of average PM10 for Mizoram from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Mizoram'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3575,List states with their PM2.5 violation count and rate (>60 µg/m³) in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3576,Plot the rolling 30-day average PM2.5 for Jammu and Kashmir in 2018 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Jammu and Kashmir') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Jammu and Kashmir 2018', width=600, height=300) " 3577,Identify the state that recorded the second highest 75th percentile of PM2.5 during the Summer season of 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 3578,Identify the station that saw the third least significant fall in average PM10 levels when comparing December 2020 to October 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 3579,"For the year 2019, which weekday had the third-highest 75th percentile of PM10 pollution levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'Timestamp'}}] " 3580,Show annual average PM10 for Nashik as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Nashik'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3581,Identify the city that registered the second highest 25th percentile for PM10 during the Post-Monsoon season of 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 3582,Plot the rolling 30-day average PM2.5 for Nagaland in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Nagaland') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Nagaland 2024', width=600, height=300) " 3583,"Compare the monthly average PM2.5 of Jalandhar, Ujjain, and Thanjavur in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Jalandhar', 'Ujjain', 'Thanjavur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Jalandhar vs Ujjain vs Thanjavur – 2019', width=550, height=320) return chart " 3584,Show how many times PM2.5 exceeded 60 µg/m³ per day across states in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3585,"In February 2019, identify the state with the 2nd highest median PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 3586,Show the monthly average PM2.5 for Keonjhar in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Keonjhar') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Keonjhar 2018', width=450, height=280) " 3587,Generate a cross-tab of state vs month for average PM2.5 in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Arunachal Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Chhattisgarh', 'Delhi', 'Gujarat', 'Haryana', 'Himachal Pradesh', 'Jammu and Kashmir', 'Jharkhand', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Manipur', 'Meghalaya', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh', 'Uttarakhand', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3588,"In January 2019, identify the state with the 2nd lowest 75th percentile of PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 3589,Show the monthly average PM2.5 for Boisar in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Boisar') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Boisar 2018', width=450, height=280) " 3590,Which state had the lowest average PM2.5 in December 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 3591,Show a table of average PM10 per state in 2024 along with population.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3592,Tabulate the monthly mean PM2.5 levels for Assam during 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Assam'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3593,"Visualize the monthly average PM10 for Manipur, Andhra Pradesh, and Uttarakhand in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Manipur', 'Andhra Pradesh', 'Uttarakhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Manipur, Andhra Pradesh, UP – 2018', width=550, height=320) return chart " 3594,"In February 2022, report the city with the 2nd lowest median PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 3595,"Compare the monthly average PM2.5 of Munger, Nagpur, and Hisar in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Munger', 'Nagpur', 'Hisar'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Munger vs Nagpur vs Hisar – 2022', width=550, height=320) return chart " 3596,"Tabulate the distribution of PM10 per city in 2020 including mean, median, and std."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'q25', 'median', 'q75']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3597,Show a table of the top 5 states by average PM2.5 in 2020 including their PM10 levels too.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 3598,Which station showed the 2nd highest 25th percentile of PM2.5 in August 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 3599,Show NCAP total funding released per state as a table.," [ {'op': 'SOURCE', 'params': {'table': 'ncap'}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'Total fund released', 'fn': 'sum'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Total fund released'}}, {'op': 'RENAME', 'params': {'map': {'Total fund released': 'Total Fund Released (Cr)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3600,Tabulate the 10 worst citys for average PM10 in 2023 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 3601,Create a table of PM2.5 standard violations (>100 µg/m³) per state in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3602,Determine which city was granted the 4th lowest NCAP funding considering its 25th percentile of PM2.5 concentration in 2022 (FY 2021-22).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2022_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 3603,Which station recorded the 3rd highest 75th percentile for PM10 in the Winter season of 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 3604,"Create a grouped bar chart comparing the average PM2.5 for Haryana, Jharkhand, and Meghalaya across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Jharkhand', 'Meghalaya'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 3605,"Compare the monthly average PM2.5 of Mandideep, Gurugram, and Kaithal in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Mandideep', 'Gurugram', 'Kaithal'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Mandideep vs Gurugram vs Kaithal – 2023', width=550, height=320) return chart " 3606,Which city shows the 5th smallest difference between allocated NCAP funding and its actual use by June 2022?," [{'op': 'AGG', 'params': {'by': 'city', 'fn': 'sum', 'col': 'Difference'}}, {'op': 'SORT', 'params': {'col': 'Difference', 'ascending': True}}] " 3607,Create a table showing annual mean PM10 levels for Nagaland (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Nagaland'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3608,"In Navi Mumbai, which date in the previous five years showed the lowest PM10 concentration?"," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 5}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'Timestamp'}}] " 3609,Identify the station with the 3rd lowest average PM10 in October 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 3610,"Plot the yearly average PM2.5 trends for Jammu and Kashmir, Punjab, and Gujarat from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jammu and Kashmir', 'Punjab', 'Gujarat'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Jammu and Kashmir vs Punjab vs Gujarat', width=550, height=320) return chart " 3611,Which state recorded the lowest median PM10 reading for March 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 3612,"Create a grouped bar chart comparing the average PM2.5 for Madhya Pradesh, Karnataka, and Rajasthan across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Madhya Pradesh', 'Karnataka', 'Rajasthan'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 3613,Show PM10 averages in a state × month matrix for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Arunachal Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Chhattisgarh', 'Delhi', 'Gujarat', 'Haryana', 'Jammu and Kashmir', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Meghalaya', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3614,"Determine which union territory has the smallest population within the top 2 most polluted union territories, based on total PM2.5 levels."," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'sum', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 2, 'ret': 'state'}}] " 3615,"Comparing December 2022 to October 2022, which state showed the second most significant drop in median PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 3616,"Compare the monthly average PM2.5 of Byrnihat, Rairangpur, and Bhiwadi in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Byrnihat', 'Rairangpur', 'Bhiwadi'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Byrnihat vs Rairangpur vs Bhiwadi – 2019', width=550, height=320) return chart " 3617,Tabulate the monthly mean PM2.5 levels for Bihar during 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Bihar'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3618,Report the city with the 2nd lowest average PM10 in July 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 3619,"Visualize the monthly average PM10 for Uttarakhand, Mizoram, and Maharashtra in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttarakhand', 'Mizoram', 'Maharashtra'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Uttarakhand, Mizoram, UP – 2017', width=550, height=320) return chart " 3620,List average PM2.5 by month for Nashik in 2023 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Nashik'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3621,Which city recorded the 2nd lowest average for PM2.5 in the Summer season of 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 3622,Which state experienced the highest rise in its 25th percentile PM2.5 level between August 2019 and August 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 3623,Determine the station with the 2nd highest 25th percentile of PM10 in January 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 3624,"Scatter plot PM2.5 vs PM10 for Maharashtra stations in 2017, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Maharashtra') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Maharashtra Stations 2017', width=450, height=350) " 3625,Create a month-by-state breakdown table of mean PM10 for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Delhi', 'Gujarat', 'Haryana', 'Jharkhand', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3626,Tabulate mean PM10 and land area for each state in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3627,Show average PM2.5 per capita by state in 2021 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM2.5 per million', 'numerator': 'PM2.5', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'PM2.5 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3628,Which week in 2021 was linked to the second-lowest 25th percentile for PM2.5 levels?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'week'}}] " 3629,Which state recorded the highest 75th percentile of PM2.5 in March 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 3630,"Over all years, which April was associated with the highest average PM10 levels?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'Timestamp'}}] " 3631,"Plot the yearly average PM2.5 trends for Sikkim, Uttar Pradesh, and Kerala from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Sikkim', 'Uttar Pradesh', 'Kerala'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Sikkim vs Uttar Pradesh vs Kerala', width=550, height=320) return chart " 3632,Plot the rolling 30-day average PM2.5 for Bihar in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Bihar') & (data['Timestamp'].dt.year == 2020)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Bihar 2020', width=600, height=300) " 3633,List citys with their PM2.5 violation count and rate (>100 µg/m³) in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3634,Create a per-capita PM2.5 summary table by state for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM2.5 per million', 'numerator': 'PM2.5', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'PM2.5 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3635,"Plot the yearly average PM2.5 trends for Andhra Pradesh, Nagaland, and West Bengal from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Nagaland', 'West Bengal'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Andhra Pradesh vs Nagaland vs West Bengal', width=550, height=320) return chart " 3636,How many times did Bangalore city exceed the Indian guideline for PM10 in the year 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 60.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 3637,Show the monthly average PM10 trend for Ballabgarh from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Ballabgarh'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Ballabgarh (2017–2022)', width=600, height=300) return chart " 3638,Plot the weekly average PM2.5 for Rajgir in 2021 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Rajgir') & (data['Timestamp'].dt.year == 2021)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Rajgir 2021', width=600, height=300) return chart " 3639,"Show the top 13 states by average PM10 in 2020 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2020] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(13, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 13 States by Average PM10 in 2020', width=500, height=300) return chart " 3640,Generate a table showing the 20 most polluted states based on mean PM10 for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 3641,Visualize the bottom 5 states with the lowest average PM2.5 in 2023 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2023] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(5, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 5 States by Average PM2.5 in 2023', width=500, height=300) return chart " 3642,Create a statistical summary table of PM2.5 readings by state for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3643,Show the monthly average PM2.5 for Sawai Madhopur in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Sawai Madhopur') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Sawai Madhopur 2019', width=450, height=280) " 3644,"Compare the monthly average PM2.5 of Jaipur, Satna, and Brajrajnagar in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Jaipur', 'Satna', 'Brajrajnagar'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Jaipur vs Satna vs Brajrajnagar – 2018', width=550, height=320) return chart " 3645,Identify the city with the 2nd highest 25th percentile of PM2.5 for January 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 3646,Show a cumulative area chart of PM2.5 readings for Bidar across 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bidar') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Bidar 2021', width=600, height=300) return chart " 3647,Generate a monthly average PM2.5 table for Indore for the year 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Indore'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3648,Create a table showing PM10 spread (min to max) and central tendency per state for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'q25', 'median', 'q75']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3649,Tabulate population-adjusted PM10 levels for each state in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM10 per million', 'numerator': 'PM10', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'PM10 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3650,List all states with their average PM10 and population for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3651,Generate a monthly average PM2.5 table for Lucknow for the year 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Lucknow'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3652,"In April 2021, which state exhibited the 3rd lowest 25th percentile of PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 3653,Which city registered the 2nd lowest 25th percentile of PM2.5 during October 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 3654,"Which city recorded the third-lowest average PM10 concentration on January 5, 2022?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 3655,List all citys with their average PM2.5 and PM10 levels in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3656,Create a per-capita PM2.5 summary table by state for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM2.5 per million', 'numerator': 'PM2.5', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'PM2.5 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3657,"Visualize the monthly average PM10 for Gujarat, Telangana, and Arunachal Pradesh in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Gujarat', 'Telangana', 'Arunachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Gujarat, Telangana, UP – 2018', width=550, height=320) return chart " 3658,"Plot the yearly average PM2.5 trends for Assam, Nagaland, and Tamil Nadu from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Assam', 'Nagaland', 'Tamil Nadu'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Assam vs Nagaland vs Tamil Nadu', width=550, height=320) return chart " 3659,Plot the weekly average PM2.5 for Ramanathapuram in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ramanathapuram') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Ramanathapuram 2023', width=600, height=300) return chart " 3660,Which 5 citys had the lowest mean PM10 in 2021? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 3661,Which station recorded the 3rd highest 75th percentile of PM10 in October 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 3662,Show the monthly average PM2.5 for Navi Mumbai in 2022 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Navi Mumbai') & (data['Timestamp'].dt.year == 2022)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Navi Mumbai 2022', width=450, height=280) " 3663,"Visualize the monthly average PM10 for Haryana, Tripura, and Sikkim in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Tripura', 'Sikkim'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Haryana, Tripura, UP – 2017', width=550, height=320) return chart " 3664,Create a ranked table of the 5 best-performing states by PM2.5 in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 3665,Show a monthly breakdown table of average PM2.5 for Gaya in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Gaya'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3666,Create a month-wise summary of average PM2.5 for Asansol in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Asansol'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3667,Tabulate daily PM10 exceedances (above 100 µg/m³) per city for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3668,Identify the city with the 3rd highest 75th percentile of PM2.5 in November 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 3669,Plot the median PM10 for each state in summer 2022 (April–June) as a sorted bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['Timestamp'].dt.year == 2022) & (data['Timestamp'].dt.month.isin([4,5,6]))] df = df.groupby('state')['PM10'].median().reset_index().dropna() df = df.sort_values('PM10', ascending=False) chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Median PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='yelloworangered'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Median PM10 by State – Summer 2022 (Apr–Jun)', width=500, height=400) return chart " 3670,"Compare the monthly average PM2.5 of Rishikesh, Bengaluru, and Samastipur in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Rishikesh', 'Bengaluru', 'Samastipur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Rishikesh vs Bengaluru vs Samastipur – 2019', width=550, height=320) return chart " 3671,List states by PM2.5 concentration per million inhabitants in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM2.5 per million', 'numerator': 'PM2.5', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'PM2.5 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3672,Show how average PM10 varied month by month for Tamil Nadu in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3673,Show the monthly average PM2.5 for Ratlam in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ratlam') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Ratlam 2017', width=450, height=280) " 3674,Tabulate population-adjusted PM10 levels for each state in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM10 per million', 'numerator': 'PM10', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'PM10 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3675,Show the monthly average PM2.5 for Karnal in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Karnal') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Karnal 2018', width=450, height=280) " 3676,Identify the city with the lowest 75th percentile of PM2.5 for January 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 3677,Determine the state which was the 3rd least polluted concerning per capita PM2.5 exposure in 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'per_capita_pm', 'numerator': 'PM2.5', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'per_capita_pm', 'ascending': True}}] " 3678,Identify the state with NCAP funding having the 4th lowest PM10 concentration.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}] " 3679,Show the monthly average PM2.5 for Lucknow in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Lucknow') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Lucknow 2018', width=450, height=280) " 3680,Show the monthly average PM2.5 for Sivasagar in 2023 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Sivasagar') & (data['Timestamp'].dt.year == 2023)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Sivasagar 2023', width=450, height=280) " 3681,"Which state showed the second-lowest 75th percentile for PM2.5 on March 31, 2023?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 3682,Tabulate daily PM10 exceedances (above 100 µg/m³) per state for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3683,Tabulate average PM10 for each city in Bihar across all months of 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Bihar'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Patna']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3684,"Visualize the monthly average PM10 for Jammu and Kashmir, Mizoram, and Chhattisgarh in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jammu and Kashmir', 'Mizoram', 'Chhattisgarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Jammu and Kashmir, Mizoram, UP – 2024', width=550, height=320) return chart " 3685,Determine a week with Kurukshetra 's 3rd highest PM10 levels over all these years.," [{'op': 'FILTER', 'params': {'field': 'city', 'value': 'Kurukshetra '}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'week'}}] " 3686,Show how many times PM2.5 exceeded 100 µg/m³ per day across citys in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3687,"Plot the yearly average PM2.5 trends for Telangana, Nagaland, and Kerala from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Telangana', 'Nagaland', 'Kerala'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Telangana vs Nagaland vs Kerala', width=550, height=320) return chart " 3688,Create a heatmap showing the average PM2.5 by month (x-axis) and year (y-axis) for Chandigarh.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Chandigarh'].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Year:N', title='Year'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='Avg PM2.5'), tooltip=['Year:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Chandigarh (Month × Year)', width=500, height=280) return chart " 3689,Show PM2.5 exceedance count and rate (%) above 100 µg/m³ per state in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3690,Generate a descriptive stats table for PM10 grouped by city in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3691,Identify the state with the 3rd lowest average PM10 in June 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 3692,Show a bar chart of the top 5 cities by median PM2.5 in 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2023] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(5, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 5 Cities by Median PM2.5 in 2023', width=500, height=300) return chart " 3693,Show a heatmap of average PM2.5 for the top 9 most polluted states by month for 2017.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(9).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 9 Polluted States by Month (2017)', width=500, height=300) return chart " 3694,"Compare the monthly average PM2.5 of Navi Mumbai, Bhubaneswar, and Asansol in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Navi Mumbai', 'Bhubaneswar', 'Asansol'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Navi Mumbai vs Bhubaneswar vs Asansol – 2018', width=550, height=320) return chart " 3695,"On January 5, 2023, which state showed the minimum average PM10 reading?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 3696,"Visualize the monthly average PM10 for Punjab, Odisha, and Andhra Pradesh in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Punjab', 'Odisha', 'Andhra Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Punjab, Odisha, UP – 2018', width=550, height=320) return chart " 3697,"Compare the monthly average PM2.5 of Koppal, Bhubaneswar, and Muzaffarnagar in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Koppal', 'Bhubaneswar', 'Muzaffarnagar'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Koppal vs Bhubaneswar vs Muzaffarnagar – 2023', width=550, height=320) return chart " 3698,"Comparing December 2019 to October 2019, which state showed the third least significant drop in average PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 3699,Create a table of PM2.5 standard violations (>60 µg/m³) per city in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3700,Show the monthly average PM10 trend for Rourkela from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Rourkela'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Rourkela (2019–2024)', width=600, height=300) return chart " 3701,Create a table showing annual mean PM2.5 levels for Madhya Pradesh (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3702,"In May 2024, report the city with the 3rd highest average PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 3703,Show the monthly average PM2.5 for Badlapur in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Badlapur') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Badlapur 2018', width=450, height=280) " 3704,Identify the station that registered the second lowest 25th percentile for PM10 during the Summer season of 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 3705,"Create a grouped bar chart comparing the average PM2.5 for Haryana, Punjab, and Andhra Pradesh across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Punjab', 'Andhra Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 3706,Identify the station that recorded the 3rd highest median PM10 value in November 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 3707,"Visualize the monthly average PM10 for Haryana, Manipur, and Nagaland in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Manipur', 'Nagaland'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Haryana, Manipur, UP – 2019', width=550, height=320) return chart " 3708,How many times did Jodhpur city exceed 30 µg/m³ of PM2.5 in the year 2017?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 30.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 3709,Create a table of PM2.5 standard violations (>60 µg/m³) per state in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3710,List states with their PM10 violation count and rate (>100 µg/m³) in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3711,Report the city with the lowest NCAP funding considering its total PM10 concentration in 2020 (FY 2019-20).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'sum', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2020_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 3712,"Visualize the monthly average PM10 for Kerala, Sikkim, and Telangana in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Kerala', 'Sikkim', 'Telangana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Kerala, Sikkim, UP – 2023', width=550, height=320) return chart " 3713,Show the monthly average PM2.5 for Jharkhand across each year from 2017 to 2024 as small multiples (faceted by year).," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Jharkhand'].copy() df['Year'] = df['Timestamp'].dt.year df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5'), tooltip=['Year:O','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet( facet=alt.Facet('Year:O', title='Year'), columns=4 ).properties(title='Monthly PM2.5 in Jharkhand by Year (2017–2024)') return chart " 3714,Show how average PM2.5 varied month by month for Kolkata in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Kolkata'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3715,Show a pivot table of monthly average PM10 by city for Maharashtra in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Aurangabad', 'Chandrapur', 'Nagpur', 'Nashik', 'Navi Mumbai', 'Solapur', 'Thane']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3716,"On March 31, 2021, which state recorded the second-lowest median PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 3717,"Plot the yearly average PM2.5 trends for Andhra Pradesh, Meghalaya, and Haryana from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Meghalaya', 'Haryana'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Andhra Pradesh vs Meghalaya vs Haryana', width=550, height=320) return chart " 3718,Generate a monthly average PM2.5 table for Uttar Pradesh for the year 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3719,Generate a year-by-year summary table of PM10 readings for Jaipur.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Jaipur'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3720,Generate a table showing the 10 most polluted states based on mean PM2.5 for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 3721,Create a month-wise summary of average PM10 for Aurangabad in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Aurangabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3722,List the average PM10 for Delhi broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Delhi'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3723,Identify the city with the highest 75th percentile of PM2.5 for November 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 3724,"Compare the monthly average PM2.5 of Hubballi, Tumakuru, and Sikar in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Hubballi', 'Tumakuru', 'Sikar'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Hubballi vs Tumakuru vs Sikar – 2024', width=550, height=320) return chart " 3725,Show a ranked table of the 15 most polluted states by average PM10 in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 3726,Tabulate average and median PM10 for all states in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3727,"Plot the yearly average PM2.5 trends for Jharkhand, Jharkhand, and Karnataka from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Jharkhand', 'Karnataka'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Jharkhand vs Jharkhand vs Karnataka', width=550, height=320) return chart " 3728,Which city noted the peak median PM10 in the Post-Monsoon season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 3729,Show a monthly breakdown table of average PM10 for Uttar Pradesh in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3730,"Scatter plot PM2.5 vs PM10 for Telangana stations in 2024, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Telangana') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Telangana Stations 2024', width=450, height=350) " 3731,"In Sikkim, what is the median PM10 concentration on Thursdays?"," [{'op': 'FILTER', 'params': {'field': 'state', 'value': 'Sikkim'}}] " 3732,Which station possessed the highest 25th percentile for PM2.5 in the Summer season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 3733,Plot the rolling 30-day average PM2.5 for Rajasthan in 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Rajasthan') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Rajasthan 2022', width=600, height=300) " 3734,List average PM10 by month for Rajasthan in 2024 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3735,Tabulate average PM2.5 for each city in Karnataka across all months of 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Bengaluru']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3736,How many times did Mangalore city go above 30 µg/m³ of PM2.5 in 2017?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 30.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 3737,Identify the city exhibiting the 2nd lowest 25th percentile of PM2.5 during the Monsoon season of 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 3738,"Plot the yearly average PM2.5 trends for Tamil Nadu, Kerala, and Arunachal Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Kerala', 'Arunachal Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Tamil Nadu vs Kerala vs Arunachal Pradesh', width=550, height=320) return chart " 3739,How many times did Ambala city surpass the Indian guideline for PM10 in 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 60.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 3740,"On August 15, 2023, which city recorded the minimum PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 3741,Which state was the 5th least polluted regarding per capita PM2.5 exposure in 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'per_capita_pm', 'numerator': 'PM2.5', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'per_capita_pm', 'ascending': True}}] " 3742,Create a month-wise PM10 breakdown table across cities in Assam for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Assam'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Guwahati']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3743,Show a table of the 20 cleanest states by average PM10 in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 3744,Tabulate the 15 worst states for average PM10 in 2022 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 3745,Show a monthly bar chart of the number of days Chandigarh exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Chandigarh') & (data['Timestamp'].dt.year == 2021)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Chandigarh Exceeded WHO PM2.5 Guideline per Month – 2021', width=500, height=300) return chart " 3746,List the average PM10 for Chandigarh broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Chandigarh'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3747,Show a monthly bar chart of the number of days Haryana exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Haryana') & (data['Timestamp'].dt.year == 2024)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Haryana Exceeded WHO PM2.5 Guideline per Month – 2024', width=500, height=300) return chart " 3748,Show the monthly average PM10 trend for Dehradun from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Dehradun'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Dehradun (2017–2022)', width=600, height=300) return chart " 3749,"Create a grouped bar chart comparing the average PM2.5 for West Bengal, Andhra Pradesh, and Chhattisgarh across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['West Bengal', 'Andhra Pradesh', 'Chhattisgarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 3750,"Identify the state (excluding UTs) having the 2nd largest population among the top 10 most polluted states, based on 25th percentile of PM10 levels."," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 10, 'ret': 'state'}}] " 3751,Which state registered the highest median PM2.5 during February 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 3752,Report the city that was granted the 2nd highest NCAP funding with respect to its 75th percentile of PM2.5 concentration in 2020 (FY 2019-20).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2020_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 3753,Show a pivot table of monthly average PM2.5 by city for Madhya Pradesh in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Dewas', 'Mandideep', 'Pithampur', 'Singrauli', 'Ujjain']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3754,"Identify the station with the third-highest 75th percentile for PM2.5 on March 31, 2024."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 3755,Show PM2.5 density (µg/m³ per km²) by state for 2023 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, { 'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM2.5 per km²', 'numerator': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)', 'PM2.5 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3756,Show the monthly average PM2.5 for Jaisalmer in 2024 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Jaisalmer') & (data['Timestamp'].dt.year == 2024)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Jaisalmer 2024', width=450, height=280) " 3757,Show how average PM2.5 varied month by month for West Bengal in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'West Bengal'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3758,Identify the city that recorded the highest average PM2.5 value in November 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 3759,Show how average PM2.5 varied month by month for Bihar in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Bihar'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3760,Which station had the 3rd highest 25th percentile of PM2.5 in May 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 3761,List the average PM10 for Nashik broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Nashik'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3762,Tabulate average PM2.5 for each city in Uttar Pradesh across all months of 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Agra', 'Bulandshahr', 'Ghaziabad', 'Greater Noida', 'Hapur', 'Kanpur', 'Lucknow', 'Meerut', 'Moradabad', 'Muzaffarnagar', 'Noida', 'Varanasi']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3763,Determine which station exhibited the 2nd lowest 75th percentile of PM10 over the Post-Monsoon season of 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 3764,"In Andhra Pradesh, what is the average PM10 concentration on Sundays?"," [{'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}] " 3765,Show the monthly average PM2.5 for Pathardih in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Pathardih') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Pathardih 2018', width=450, height=280) " 3766,Which city recorded the highest 75th percentile of PM10 in April 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 3767,Show annual average PM2.5 for Haryana as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Haryana'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3768,"Scatter plot PM2.5 vs PM10 for Assam stations in 2024, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Assam') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Assam Stations 2024', width=450, height=350) " 3769,"Create a grouped bar chart comparing the average PM2.5 for Assam, Meghalaya, and Tamil Nadu across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Assam', 'Meghalaya', 'Tamil Nadu'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 3770,Visualize the bottom 12 states with the lowest average PM2.5 in 2024 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2024] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(12, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 12 States by Average PM2.5 in 2024', width=500, height=300) return chart " 3771,"Scatter plot PM2.5 vs PM10 for Puducherry stations in 2024, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Puducherry') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Puducherry Stations 2024', width=450, height=350) " 3772,Show a pivot table of monthly average PM2.5 by city for Gujarat in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Gujarat'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Ahmedabad']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3773,"Over all years, which December had the third-lowest average PM2.5 concentration?"," [{'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'Timestamp'}}] " 3774,"Scatter plot PM2.5 vs PM10 for Sikkim stations in 2018, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Sikkim') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Sikkim Stations 2018', width=450, height=350) " 3775,Show the monthly average PM2.5 for Karnal in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Karnal') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Karnal 2017', width=450, height=280) " 3776,"In February 2018, identify the station with the highest 25th percentile of PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 3777,"In 2018, which weekday experienced the second-lowest median PM10 pollution concentrations?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'Timestamp'}}] " 3778,Which city noted the 2nd minimum average PM2.5 during the Monsoon season of 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 3779,"Plot the yearly average PM2.5 trends for Mizoram, Madhya Pradesh, and Sikkim from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Mizoram', 'Madhya Pradesh', 'Sikkim'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Mizoram vs Madhya Pradesh vs Sikkim', width=550, height=320) return chart " 3780,"Scatter plot PM2.5 vs PM10 for Chhattisgarh stations in 2017, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Chhattisgarh') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Chhattisgarh Stations 2017', width=450, height=350) " 3781,"Scatter plot PM2.5 vs PM10 for Arunachal Pradesh stations in 2020, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Arunachal Pradesh') & (data['Timestamp'].dt.year == 2020)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Arunachal Pradesh Stations 2020', width=450, height=350) " 3782,Show a monthly breakdown table of average PM10 for Nagaland in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Nagaland'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3783,Which city recorded the minimum median PM10 during the Post-Monsoon season of 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 3784,Tabulate the 15 worst citys for average PM10 in 2024 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 3785,Which 5 citys had the lowest mean PM10 in 2023? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 3786,Show a heatmap of average PM2.5 for the top 5 most polluted states by month for 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(5).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 5 Polluted States by Month (2023)', width=500, height=300) return chart " 3787,"Create a grouped bar chart comparing the average PM2.5 for Jharkhand, Karnataka, and Sikkim across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Karnataka', 'Sikkim'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 3788,How many times did Bangalore city exceed 75 µg/m³ of PM10 in the year 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 75.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 3789,"Plot the yearly average PM2.5 trends for Mizoram, Himachal Pradesh, and Chandigarh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Mizoram', 'Himachal Pradesh', 'Chandigarh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Mizoram vs Himachal Pradesh vs Chandigarh', width=550, height=320) return chart " 3790,"Plot the yearly average PM2.5 trends for Jammu and Kashmir, Tamil Nadu, and Himachal Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jammu and Kashmir', 'Tamil Nadu', 'Himachal Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Jammu and Kashmir vs Tamil Nadu vs Himachal Pradesh', width=550, height=320) return chart " 3791,"Create a grouped bar chart comparing the average PM2.5 for Jharkhand, Tamil Nadu, and Rajasthan across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Tamil Nadu', 'Rajasthan'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 3792,List average PM2.5 by month for Kota in 2019 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Kota'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3793,Show a table of the 5 cleanest states by average PM2.5 in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 3794,Show the monthly average PM2.5 for Samastipur in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Samastipur') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Samastipur 2018', width=450, height=280) " 3795,Tabulate both PM2.5 and PM10 averages by city for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3796,"Which state (excluding Union Territories) has the 2nd lowest PM2.5 concentration per square kilometer, based on average PM2.5 values?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_km2', 'numerator': 'PM2.5', 'denominator': 'area (km2)'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'pm_per_km2', 'ascending': True}}] " 3797,Report which state registered the 2nd highest 75th percentile of PM10 throughout the Summer season of 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 3798,"In 2020, which state will rank with the smallest reduction in 25th percentile PM2.5 levels from October to December?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 3799,Show a cumulative area chart of PM2.5 readings for Asansol across 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Asansol') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Asansol 2024', width=600, height=300) return chart " 3800,Tabulate days with PM2.5 > 100 µg/m³ and exceedance percentage per city in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3801,Which station had the lowest 75th percentile of PM10 in January 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 3802,Create a table showing PM10 spread (min to max) and central tendency per city for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3803,"Plot the yearly average PM2.5 trends for Mizoram, Mizoram, and Madhya Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Mizoram', 'Mizoram', 'Madhya Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Mizoram vs Mizoram vs Madhya Pradesh', width=550, height=320) return chart " 3804,Tabulate the 10 worst citys for average PM10 in 2017 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 3805,"Visualize the monthly average PM10 for Arunachal Pradesh, Tamil Nadu, and Assam in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Arunachal Pradesh', 'Tamil Nadu', 'Assam'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Arunachal Pradesh, Tamil Nadu, UP – 2019', width=550, height=320) return chart " 3806,"Create a grouped bar chart comparing the average PM2.5 for Telangana, Sikkim, and Kerala across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Telangana', 'Sikkim', 'Kerala'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 3807,"Which station experienced the second-highest PM2.5 values on January 14, 2018?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 3808,"Create a grouped bar chart comparing the average PM2.5 for Andhra Pradesh, Mizoram, and Assam across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Mizoram', 'Assam'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 3809,Which city had the 2nd lowest median PM10 in July 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 3810,"Visualize the monthly average PM10 for Manipur, Gujarat, and West Bengal in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Manipur', 'Gujarat', 'West Bengal'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Manipur, Gujarat, UP – 2022', width=550, height=320) return chart " 3811,Determine the state exhibiting the 3rd highest 75th percentile of PM10 in December 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 3812,"Taking all years into account, which January registered the third-lowest 25th percentile of PM2.5 levels?"," [{'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'Timestamp'}}] " 3813,Show a bar chart of the top 9 cities by median PM2.5 in 2017.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2017] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(9, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 9 Cities by Median PM2.5 in 2017', width=500, height=300) return chart " 3814,"On August 15, 2018, which state showed the third-highest PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 3815,"Tabulate PM10 statistics (mean, std, min, max) for each state in 2017."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3816,Plot the rolling 30-day average PM2.5 for Uttar Pradesh in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Uttar Pradesh') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Uttar Pradesh 2024', width=600, height=300) " 3817,Show the monthly average PM2.5 for Rohtak in 2022 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Rohtak') & (data['Timestamp'].dt.year == 2022)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Rohtak 2022', width=450, height=280) " 3818,"Compare the monthly average PM2.5 of Angul, Thiruvananthapuram, and Jalore in 2020 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Angul', 'Thiruvananthapuram', 'Jalore'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2020)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Angul vs Thiruvananthapuram vs Jalore – 2020', width=550, height=320) return chart " 3819,Show the monthly average PM2.5 for Rourkela in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Rourkela') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Rourkela 2019', width=450, height=280) " 3820,Visualize the bottom 7 states with the lowest average PM2.5 in 2022 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2022] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(7, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 7 States by Average PM2.5 in 2022', width=500, height=300) return chart " 3821,Which station recorded the highest average PM2.5 in March 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 3822,Which state had the 2nd highest 75th percentile of PM10 in September 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 3823,"Compare the monthly average PM2.5 of Jalgaon, Latur, and Thrissur in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Jalgaon', 'Latur', 'Thrissur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Jalgaon vs Latur vs Thrissur – 2024', width=550, height=320) return chart " 3824,"For the year 2024, identify the weekday with the highest median PM2.5 pollution levels."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'Timestamp'}}] " 3825,"In 2022, which season (Winter, Summer, Monsoon, Post-Monsoon) was associated with the second-lowest 75th percentile of PM10 concentrations?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'season'}}] " 3826,Show how average PM10 varied month by month for Haryana in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Haryana'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3827,Which union territory exhibits the 2nd highest average PM2.5 concentration relative to its population density?," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_capita', 'numerator': 'PM2.5', 'denominator': 'population'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'pm_per_capita', 'ascending': False}}] " 3828,Show how average PM10 varied month by month for Jaipur in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Jaipur'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3829,Visualize the bottom 10 states with the lowest average PM2.5 in 2022 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2022] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(10, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 10 States by Average PM2.5 in 2022', width=500, height=300) return chart " 3830,"Create a grouped bar chart comparing the average PM2.5 for Odisha, Assam, and Chandigarh across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Odisha', 'Assam', 'Chandigarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 3831,Show a heatmap of average PM2.5 for the top 15 most polluted states by month for 2017.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(15).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 15 Polluted States by Month (2017)', width=500, height=300) return chart " 3832,Show a monthly bar chart of the number of days Nagaland exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Nagaland') & (data['Timestamp'].dt.year == 2023)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Nagaland Exceeded WHO PM2.5 Guideline per Month – 2023', width=500, height=300) return chart " 3833,Create a month-wise summary of average PM10 for Gandhinagar in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Gandhinagar'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3834,Plot the top 6 states by average PM2.5 in 2024 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2024] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(6, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 6 States by Average PM2.5 in 2024', width=500, height=300) return chart " 3835,Generate a city × month cross-tab of mean PM10 for Odisha in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Odisha'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Brajrajnagar', 'Talcher']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3836,Which city showed the 2nd highest 25th percentile for PM2.5 in the Summer season of 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 3837,Plot the top 6 states by average PM2.5 in 2021 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2021] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(6, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 6 States by Average PM2.5 in 2021', width=500, height=300) return chart " 3838,Show a table of average PM2.5 and PM10 for all citys in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3839,Show PM2.5 exceedance count and rate (%) above 60 µg/m³ per city in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3840,"Create a grouped bar chart comparing the average PM2.5 for Uttarakhand, Nagaland, and Delhi across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttarakhand', 'Nagaland', 'Delhi'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 3841,Determine the state that recorded the minimum 25th percentile for PM2.5 ever.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 3842,"Plot the yearly average PM2.5 trends for Madhya Pradesh, Maharashtra, and Jharkhand from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Madhya Pradesh', 'Maharashtra', 'Jharkhand'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Madhya Pradesh vs Maharashtra vs Jharkhand', width=550, height=320) return chart " 3843,"Tabulate PM10 statistics (mean, std, min, max) for each state in 2024."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3844,"Create a grouped bar chart comparing the average PM2.5 for Puducherry, Sikkim, and Himachal Pradesh across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'Sikkim', 'Himachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 3845,"Visualize the monthly average PM10 for Rajasthan, Tamil Nadu, and Mizoram in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Tamil Nadu', 'Mizoram'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Rajasthan, Tamil Nadu, UP – 2018', width=550, height=320) return chart " 3846,Plot the top 15 states by average PM2.5 in 2023 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2023] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(15, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 15 States by Average PM2.5 in 2023', width=500, height=300) return chart " 3847,Identify the state with the lowest 75th percentile of PM10 for February 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 3848,"During 2024, which weekday saw the third-highest 75th percentile of PM2.5 pollution levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'Timestamp'}}] " 3849,List states with their PM2.5 violation count and rate (>60 µg/m³) in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3850,Show the monthly average PM10 trend for Kanchipuram from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Kanchipuram'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Kanchipuram (2019–2024)', width=600, height=300) return chart " 3851,"Compare the monthly average PM2.5 of Gadag, Noida, and Vapi in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Gadag', 'Noida', 'Vapi'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Gadag vs Noida vs Vapi – 2022', width=550, height=320) return chart " 3852,Show the monthly average PM10 trend for Jhunjhunu from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Jhunjhunu'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Jhunjhunu (2019–2024)', width=600, height=300) return chart " 3853,Show average PM2.5 per capita by state in 2017 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM2.5 per million', 'numerator': 'PM2.5', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'PM2.5 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3854,"Compare the monthly average PM2.5 of Bilaspur, Rajsamand, and Thane in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Bilaspur', 'Rajsamand', 'Thane'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Bilaspur vs Rajsamand vs Thane – 2017', width=550, height=320) return chart " 3855,Create a summary table ranking the top 5 citys by PM10 concentration in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 3856,"Visualize the monthly average PM10 for Nagaland, Sikkim, and Madhya Pradesh in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Nagaland', 'Sikkim', 'Madhya Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Nagaland, Sikkim, UP – 2017', width=550, height=320) return chart " 3857,Which city recorded the 2nd lowest average PM2.5 in the Monsoon season of 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 3858,Tabulate the 5 states with the least PM2.5 pollution in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 3859,"Show the top 6 states by average PM10 in 2020 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2020] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(6, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 6 States by Average PM10 in 2020', width=500, height=300) return chart " 3860,Report the city with the 2nd highest NCAP funding considering the variance of its PM2.5 concentration in 2021 (FY 2020-21).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'var', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 3861,Report the state that was granted the 3rd highest NCAP funding with respect to the variance of its PM2.5 concentration in 2021 (FY 2020-21).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'var', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 3862,Which station had the third-lowest PM10 readings during the April 2020 COVID-19 lockdown?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 3863,Which station had the 3rd highest median PM2.5 in April 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 3864,"On January 27, 2021, which state showed the second lowest PM10 level?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 3865,"Plot the yearly average PM2.5 trends for Manipur, Andhra Pradesh, and Nagaland from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Manipur', 'Andhra Pradesh', 'Nagaland'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Manipur vs Andhra Pradesh vs Nagaland', width=550, height=320) return chart " 3866,Plot the rolling 30-day average PM2.5 for Mizoram in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Mizoram') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Mizoram 2024', width=600, height=300) " 3867,"On August 15, 2021, which state experienced the minimum PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 3868,Which state exhibited the highest median PM2.5 during April 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 3869,Create a heatmap showing the average PM2.5 by month (x-axis) and year (y-axis) for Nagaland.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Nagaland'].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Year:N', title='Year'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='Avg PM2.5'), tooltip=['Year:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Nagaland (Month × Year)', width=500, height=280) return chart " 3870,Show the monthly average PM2.5 for Kalyan in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Kalyan') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Kalyan 2017', width=450, height=280) " 3871,Which city experienced the 2nd highest 75th percentile for PM2.5 in the Post-Monsoon season of 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 3872,"Plot the yearly average PM2.5 trends for Delhi, Maharashtra, and Kerala from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Delhi', 'Maharashtra', 'Kerala'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Delhi vs Maharashtra vs Kerala', width=550, height=320) return chart " 3873,"Compare the monthly average PM2.5 of Durgapur, Chikkaballapur, and Vellore in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Durgapur', 'Chikkaballapur', 'Vellore'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Durgapur vs Chikkaballapur vs Vellore – 2019', width=550, height=320) return chart " 3874,Show the monthly average PM10 trend for Bareilly from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Bareilly'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Bareilly (2017–2022)', width=600, height=300) return chart " 3875,"In July 2022, identify the station with the lowest 75th percentile of PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 3876,"Compare the monthly average PM2.5 of Muzaffarpur, Kalyan, and Hubballi in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Muzaffarpur', 'Kalyan', 'Hubballi'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Muzaffarpur vs Kalyan vs Hubballi – 2019', width=550, height=320) return chart " 3877,"On March 31, 2019, which station had the second-lowest median PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 3878,Which state had the 3rd highest average PM2.5 in January 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 3879,Create a month-wise PM10 breakdown table across cities in Tamil Nadu for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Chennai', 'Coimbatore']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3880,List all states with their average PM2.5 and PM10 levels in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3881,Identify the city that ranks third for the highest 75th percentile of PM10 in February 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 3882,"In August 2019, report the city with the 3rd highest median PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 3883,"Which state (excluding Union Territories) possesses the 3rd smallest land area among the top 3 most polluted states, based on the 25th percentile of PM2.5 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 3, 'ret': 'state'}}] " 3884,Identify the state exhibiting the peak median PM10 during the Post-Monsoon season of 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 3885,Show the monthly average PM2.5 for Pudukottai in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Pudukottai') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Pudukottai 2020', width=450, height=280) " 3886,Create a statistical summary table of PM10 readings by city for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3887,"Identify the station with the third-lowest 75th percentile for PM10 on March 31, 2022."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 3888,Show the monthly average PM10 trend for Parbhani from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Parbhani'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Parbhani (2019–2024)', width=600, height=300) return chart " 3889,Identify the year associated with the third-lowest median PM2.5.," [{'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'Timestamp'}}] " 3890,Show a cumulative area chart of PM2.5 readings for Sawai Madhopur across 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Sawai Madhopur') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Sawai Madhopur 2024', width=600, height=300) return chart " 3891,Plot the top 14 states by average PM2.5 in 2019 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2019] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(14, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 14 States by Average PM2.5 in 2019', width=500, height=300) return chart " 3892,List all states with their average PM10 and population for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3893,Determine the station with the 3rd lowest 25th percentile of PM2.5 in April 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 3894,Plot the distribution of PM2.5 values in Uttar Pradesh across all years using a histogram.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Uttar Pradesh'].dropna(subset=['PM2.5']) df = df[['PM2.5']] chart = alt.Chart(df).mark_bar(color='steelblue', opacity=0.75).encode( x=alt.X('PM2\.5:Q', bin=alt.Bin(maxbins=40), title='PM2.5 (µg/m³)'), y=alt.Y('count()', title='Number of Observations'), tooltip=[alt.Tooltip('PM2\.5:Q', bin=True), 'count()'] ).properties(title='PM2.5 Distribution – Uttar Pradesh (All Years)', width=500, height=300) return chart " 3895,Show the monthly average PM2.5 for Dharwad in 2023 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Dharwad') & (data['Timestamp'].dt.year == 2023)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Dharwad 2023', width=450, height=280) " 3896,Visualize the bottom 10 states with the lowest average PM2.5 in 2019 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2019] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(10, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 10 States by Average PM2.5 in 2019', width=500, height=300) return chart " 3897,"Create a grouped bar chart comparing the average PM2.5 for Jammu and Kashmir, Meghalaya, and Uttar Pradesh across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jammu and Kashmir', 'Meghalaya', 'Uttar Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 3898,"Show mean, median, minimum, and maximum PM10 for each state in 2019 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3899,Which city experienced the 3rd lowest median for PM10 in the Post-Monsoon season of 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 3900,Which state registered the 2nd highest 75th percentile of PM2.5 during May 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 3901,Create a month-by-state breakdown table of mean PM10 for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Delhi', 'Haryana', 'Jharkhand', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Odisha', 'Punjab', 'Rajasthan', 'Telangana', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3902,Which city recorded the 2nd highest median PM10 in the Winter season of 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 3903,Show average PM2.5 per state in 2020 with area in km².," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3904,"Tabulate PM2.5 statistics (mean, std, min, max) for each city in 2020."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3905,Report the state ranking 3rd highest in pollution from per capita PM10 exposure for 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'per_capita_pm', 'numerator': 'PM10', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'per_capita_pm', 'ascending': False}}] " 3906,Generate a dual-pollutant summary table (PM2.5 and PM10) by state for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3907,"Plot the yearly average PM2.5 trends for Himachal Pradesh, Manipur, and Puducherry from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Himachal Pradesh', 'Manipur', 'Puducherry'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Himachal Pradesh vs Manipur vs Puducherry', width=550, height=320) return chart " 3908,"Compare the monthly average PM2.5 of Ghaziabad, Pudukottai, and Jalna in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Ghaziabad', 'Pudukottai', 'Jalna'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Ghaziabad vs Pudukottai vs Jalna – 2023', width=550, height=320) return chart " 3909,Which state had the 2nd highest average PM10 in February 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 3910,Report the state with the highest 75th percentile of PM2.5 in June 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 3911,Identify the station with the lowest 75th percentile of PM10 for July 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 3912,"Show mean, median, minimum, and maximum PM2.5 for each state in 2021 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3913,"Create a grouped bar chart comparing the average PM2.5 for Chhattisgarh, Meghalaya, and Delhi across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chhattisgarh', 'Meghalaya', 'Delhi'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 3914,"Create a grouped bar chart comparing the average PM2.5 for Punjab, Nagaland, and Kerala across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Punjab', 'Nagaland', 'Kerala'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 3915,"Plot the yearly average PM2.5 trends for Odisha, Jammu and Kashmir, and Jammu and Kashmir from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Odisha', 'Jammu and Kashmir', 'Jammu and Kashmir'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Odisha vs Jammu and Kashmir vs Jammu and Kashmir', width=550, height=320) return chart " 3916,"Create a table showing top 20 citys ranked by PM2.5 in 2020, also showing PM10."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 3917,On which date in the last three years did Palkalaiperur register its peak PM10 level?," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 3}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'Timestamp'}}] " 3918,"Create a faceted bar chart showing top 8 states by average PM2.5 per year for 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year.isin([2017,2018,2019,2020])].copy() df['Year'] = df['Timestamp'].dt.year agg = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() top = agg.groupby('Year').apply(lambda x: x.nlargest(8,'PM2.5')).reset_index(drop=True) chart = alt.Chart(top).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Avg PM2.5'), y=alt.Y('state:N', sort='-x'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet(facet='Year:O', columns=2).properties(title='Top 8 States by PM2.5 per Year') return chart " 3919,Identify the state with the lowest 25th percentile of PM10 for February 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 3920,Tabulate daily PM2.5 exceedances (above 100 µg/m³) per city for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3921,Which state registered the peak median PM2.5 in the Monsoon season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 3922,Tabulate days with PM10 > 100 µg/m³ and exceedance percentage per state in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3923,Create a summary table comparing mean PM2.5 and PM10 across citys in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3924,Tabulate the 5 worst states for average PM10 in 2020 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 3925,Show the monthly average PM10 trend for Agartala from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Agartala'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Agartala (2019–2024)', width=600, height=300) return chart " 3926,Generate a table showing the 15 most polluted citys based on mean PM10 for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 3927,List states with their average PM10 and area for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3928,Which station registered the 3rd highest 75th percentile of PM2.5 during October 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 3929,Tabulate the 5 worst citys for average PM10 in 2020 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 3930,"Plot the yearly average PM2.5 trends for Nagaland, Arunachal Pradesh, and Chandigarh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Nagaland', 'Arunachal Pradesh', 'Chandigarh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Nagaland vs Arunachal Pradesh vs Chandigarh', width=550, height=320) return chart " 3931,Create a ranked table of the 20 best-performing citys by PM10 in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 3932,"Visualize the monthly average PM10 for Mizoram, Maharashtra, and Karnataka in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Mizoram', 'Maharashtra', 'Karnataka'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Mizoram, Maharashtra, UP – 2019', width=550, height=320) return chart " 3933,List the bottom 5 citys with the lowest average PM2.5 in 2024 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 3934,Generate a city × month cross-tab of mean PM10 for Bihar in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Bihar'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Araria', 'Arrah', 'Bettiah', 'Bhagalpur', 'Bihar Sharif', 'Chhapra', 'Darbhanga', 'Gaya', 'Hajipur', 'Katihar', 'Kishanganj', 'Manguraha', 'Motihari', 'Munger', 'Muzaffarpur', 'Patna', 'Purnia', 'Rajgir', 'Saharsa', 'Sasaram', 'Siwan']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3935,Show average PM10 per capita by state in 2024 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM10 per million', 'numerator': 'PM10', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'PM10 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3936,Show a table of average PM10 per state in 2018 along with population.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3937,Identify the city that registered the second most minimal PM2.5 level on 27 January 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 3938,Show a cumulative area chart of PM2.5 readings for Vatva across 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Vatva') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Vatva 2022', width=600, height=300) return chart " 3939,Report the state with the 2nd lowest 25th percentile of PM10 in September 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 3940,Identify the station with the 3rd highest 75th percentile of PM10 in December 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 3941,"In 2022, which city will rank with the smallest reduction in 75th percentile PM2.5 levels from October to December?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 3942,"Show mean, median, minimum, and maximum PM10 for each city in 2017 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3943,"Visualize the monthly average PM10 for Odisha, Tripura, and Punjab in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Odisha', 'Tripura', 'Punjab'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Odisha, Tripura, UP – 2019', width=550, height=320) return chart " 3944,"Show the mean, median and standard deviation of PM10 per state in 2020 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3945,"Visualize the monthly average PM10 for Gujarat, Telangana, and Maharashtra in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Gujarat', 'Telangana', 'Maharashtra'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Gujarat, Telangana, UP – 2024', width=550, height=320) return chart " 3946,Determine the city exhibiting the 2nd lowest average PM10 in October 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 3947,Determine the state exhibiting the 2nd highest 75th percentile of PM2.5 over the Post-Monsoon season of 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 3948,Create a table with mean and standard deviation of PM10 by state in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3949,"Visualize the monthly average PM10 for Punjab, Madhya Pradesh, and Gujarat in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Punjab', 'Madhya Pradesh', 'Gujarat'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Punjab, Madhya Pradesh, UP – 2017', width=550, height=320) return chart " 3950,Which state showed the highest 75th percentile for PM2.5 in the Post-Monsoon season of 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 3951,Generate a city × month cross-tab of mean PM2.5 for Madhya Pradesh in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Bhopal', 'Dewas', 'Gwalior', 'Indore', 'Jabalpur', 'Katni', 'Maihar', 'Mandideep', 'Pithampur', 'Ratlam', 'Sagar', 'Satna', 'Singrauli', 'Ujjain']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3952,List the top 15 citys by average PM2.5 in 2020 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 3953,Report the state with the 4th highest NCAP funding relative to its average PM10 concentration in 2022 (FY 2021-22).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2022_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 3954,"Which station showed the minimum 75th percentile for PM10 on March 31, 2022?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 3955,"Identify the station with the second-lowest 25th percentile for PM10 on March 31, 2022."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 3956,Show how many times PM2.5 exceeded 100 µg/m³ per day across states in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3957,"Show descriptive statistics of PM2.5 (mean, median, std, min, max) per city in 2021."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3958,Which state recorded the second-highest 75th percentile of PM10 for February 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 3959,List the bottom 10 states with the lowest average PM2.5 in 2023 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 3960,Tabulate the monthly mean PM2.5 levels for Tamil Nadu during 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3961,Report which state possessed the third most minimal median PM2.5 throughout the Monsoon season of 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 3962,Show a cumulative area chart of PM2.5 readings for Bettiah across 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bettiah') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Bettiah 2024', width=600, height=300) return chart " 3963,Identify the city with the 3rd lowest median PM10 in July 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 3964,Show a pivot table of monthly average PM2.5 by city for Bihar in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Bihar'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Muzaffarpur', 'Patna']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3965,Which state recorded the 3rd highest 25th percentile of PM10 in March 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 3966,Show a table of the top 20 states by average PM2.5 in 2020 including their PM10 levels too.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 3967,Show the monthly average PM10 trend for Patna from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Patna'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Patna (2017–2022)', width=600, height=300) return chart " 3968,Generate a descriptive stats table for PM2.5 grouped by state in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3969,"In 2018, what season (Winter, Summer, Monsoon, Post-Monsoon) was linked to the third-lowest median PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'season'}}] " 3970,List how many days each state breached the PM10 limit of 100 µg/m³ in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3971,What date during the last five years noted Pali's 3rd maximum PM2.5 reading?," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 5}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'Timestamp'}}] " 3972,Show PM10 averages in a state × month matrix for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Delhi', 'Karnataka', 'Maharashtra', 'Telangana', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3973,Show a heatmap of average PM2.5 for the top 13 most polluted states by month for 2019.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(13).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 13 Polluted States by Month (2019)', width=500, height=300) return chart " 3974,Tabulate the monthly mean PM10 levels for Meerut during 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Meerut'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3975,"Visualize the monthly average PM10 for Punjab, Delhi, and Arunachal Pradesh in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Punjab', 'Delhi', 'Arunachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Punjab, Delhi, UP – 2024', width=550, height=320) return chart " 3976,Show a cumulative area chart of PM2.5 readings for Bhagalpur across 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bhagalpur') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Bhagalpur 2024', width=600, height=300) return chart " 3977,Show the number of days each city exceeded a PM2.5 threshold of 100 µg/m³ in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3978,"Visualize the monthly average PM10 for Rajasthan, Madhya Pradesh, and Chandigarh in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Madhya Pradesh', 'Chandigarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Rajasthan, Madhya Pradesh, UP – 2018', width=550, height=320) return chart " 3979,Which state possessed the highest 75th percentile for PM10 in the Winter season of 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 3980,Identify the city that recorded the 2nd highest 75th percentile of PM10 value in August 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 3981,Tabulate the 15 states with the least PM10 pollution in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 3982,Which state experienced the most significant drop in its 25th percentile PM2.5 levels between October and December 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 3983,"Which state registered the third-highest average PM2.5 reading on January 5, 2023?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 3984,"Identify the city with the minimum median PM2.5 on March 31, 2018."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 3985,Create a heatmap showing the average PM2.5 by month (x-axis) and year (y-axis) for Maharashtra.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Maharashtra'].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Year:N', title='Year'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='Avg PM2.5'), tooltip=['Year:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Maharashtra (Month × Year)', width=500, height=280) return chart " 3986,"In August 2020, identify the station with the 3rd lowest median PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 3987,Determine the station with the highest average PM10 in February 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 3988,Create a month-wise summary of average PM10 for Moradabad in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Moradabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3989,"Plot the yearly average PM2.5 trends for Puducherry, Andhra Pradesh, and Uttarakhand from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'Andhra Pradesh', 'Uttarakhand'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Puducherry vs Andhra Pradesh vs Uttarakhand', width=550, height=320) return chart " 3990,Which state registered the minimum 25th percentile of PM10 in the Summer season of 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 3991,Plot the top 6 states by average PM2.5 in 2022 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2022] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(6, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 6 States by Average PM2.5 in 2022', width=500, height=300) return chart " 3992,List the top 20 citys by average PM10 in 2019 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 3993,"Compare the monthly average PM2.5 of Brajrajnagar, Bahadurgarh, and Tumidih in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Brajrajnagar', 'Bahadurgarh', 'Tumidih'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Brajrajnagar vs Bahadurgarh vs Tumidih – 2024', width=550, height=320) return chart " 3994,Tabulate average PM10 for each city in Andhra Pradesh across all months of 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Amaravati', 'Anantapur', 'Chittoor', 'Kadapa', 'Rajamahendravaram', 'Tirupati', 'Vijayawada', 'Visakhapatnam']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3995,Create a month-wise PM10 breakdown table across cities in Punjab for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Amritsar', 'Bathinda', 'Jalandhar', 'Khanna', 'Ludhiana', 'Mandi Gobindgarh', 'Patiala', 'Rupnagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3996,"Create a grouped bar chart comparing the average PM2.5 for Delhi, Puducherry, and Himachal Pradesh across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Delhi', 'Puducherry', 'Himachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 3997,List average PM10 by month for Chandigarh in 2024 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Chandigarh'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 3998,Name the state with the third-lowest median PM2.5 concentration in August 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 3999,"Scatter plot PM2.5 vs PM10 for Odisha stations in 2019, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Odisha') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Odisha Stations 2019', width=450, height=350) " 4000,"Show descriptive statistics of PM10 (mean, median, std, min, max) per city in 2018."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'q25', 'median', 'q75']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4001,Show the monthly average PM2.5 for Nandesari in 2022 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Nandesari') & (data['Timestamp'].dt.year == 2022)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Nandesari 2022', width=450, height=280) " 4002,Tabulate days with PM2.5 > 100 µg/m³ and exceedance percentage per state in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4003,"Plot the yearly average PM2.5 trends for Jharkhand, Puducherry, and Himachal Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Puducherry', 'Himachal Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Jharkhand vs Puducherry vs Himachal Pradesh', width=550, height=320) return chart " 4004,What number of Uttarakhand stations exceeded 45 µg/m³ of PM2.5 in 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 45.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 4005,Tabulate the top 10 states for PM2.5 in 2018 along with their corresponding PM10 values.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 4006,"Create a bubble chart of PM2.5 vs area for each state in 2019, sized by population."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): pm = data[data['Timestamp'].dt.year == 2019].groupby('state')['PM2.5'].mean().reset_index().dropna() df = pm.merge(states_data, on='state') chart = alt.Chart(df).mark_point(filled=True, opacity=0.7).encode( x=alt.X('area (km2):Q', title='Area (km²)', axis=alt.Axis(format='~s')), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), size=alt.Size('population:Q', title='Population', scale=alt.Scale(range=[50,1500])), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('population:Q', format=','), alt.Tooltip('area (km2):Q', format=',')] ).properties(title='PM2.5 vs Area (size=Population) – 2019', width=500, height=400) return chart " 4007,"Compare the monthly average PM2.5 of Chennai, Asansol, and Kurukshetra in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Chennai', 'Asansol', 'Kurukshetra'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Chennai vs Asansol vs Kurukshetra – 2024', width=550, height=320) return chart " 4008,Show a cumulative area chart of PM2.5 readings for Shivamogga across 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Shivamogga') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Shivamogga 2022', width=600, height=300) return chart " 4009,Show PM2.5 exceedances above the Indian standard (60 µg/m³) per year as a bar chart for Bihar.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Bihar'].dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 60].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby('Year')['Timestamp'].nunique().reset_index() df.columns = ['Year','Days Exceeded'] chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('Year:N', title='Year'), y=alt.Y('Days Exceeded:Q', title='Days PM2.5 > 60 µg/m³'), tooltip=['Year:N','Days Exceeded:Q'] ).properties(title='Days Bihar Exceeded Indian PM2.5 Standard (60 µg/m³) per Year', width=450, height=300) return chart " 4010,Create a statistical summary table of PM10 readings by city for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4011,"Create a grouped bar chart comparing the average PM2.5 for Puducherry, Bihar, and Uttarakhand across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'Bihar', 'Uttarakhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 4012,"Visualize the monthly average PM10 for West Bengal, Rajasthan, and Uttar Pradesh in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['West Bengal', 'Rajasthan', 'Uttar Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: West Bengal, Rajasthan, UP – 2021', width=550, height=320) return chart " 4013,List the average PM2.5 for Karnataka broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4014,"Compare the monthly average PM2.5 of Madikeri, Ahmedabad, and Nanded in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Madikeri', 'Ahmedabad', 'Nanded'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Madikeri vs Ahmedabad vs Nanded – 2023', width=550, height=320) return chart " 4015,Generate a table showing the 20 most polluted states based on mean PM10 for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 4016,"In July 2023, report the station with the 3rd lowest 75th percentile of PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 4017,Plot the rolling 30-day average PM2.5 for Meghalaya in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Meghalaya') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Meghalaya 2023', width=600, height=300) " 4018,List the average PM10 for Gurugram broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Gurugram'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4019,"Create a grouped bar chart comparing the average PM2.5 for Manipur, Arunachal Pradesh, and Jharkhand across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Manipur', 'Arunachal Pradesh', 'Jharkhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 4020,Identify the city that received the 2nd highest NCAP funding relative to its total PM2.5 concentration in 2020 (FY 2019-20).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'sum', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2020_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 4021,Identify the state that recorded the highest average PM10 value in March 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 4022,Tabulate how average PM2.5 changed year by year for each state.," [ { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Bihar', 'Delhi', 'Gujarat', 'Haryana', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Odisha', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Uttar Pradesh']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'year', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4023,Show a monthly breakdown table of average PM2.5 for Ghaziabad in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Ghaziabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4024,"On March 31, 2021, which city had the minimum average PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 4025,"Visualize the monthly average PM10 for Haryana, Karnataka, and Telangana in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Karnataka', 'Telangana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Haryana, Karnataka, UP – 2019', width=550, height=320) return chart " 4026,Tabulate daily PM2.5 exceedances (above 60 µg/m³) per state for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4027,Show a table of average PM2.5 and PM10 for all citys in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4028,"Plot the yearly average PM2.5 trends for Tripura, Tamil Nadu, and Madhya Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tripura', 'Tamil Nadu', 'Madhya Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Tripura vs Tamil Nadu vs Madhya Pradesh', width=550, height=320) return chart " 4029,Show PM2.5 averages in a state × month matrix for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Bihar', 'Delhi', 'Haryana', 'Karnataka', 'Maharashtra', 'Tamil Nadu', 'Telangana', 'Uttar Pradesh']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4030,Visualize the bottom 5 states with the lowest average PM2.5 in 2020 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2020] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(5, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 5 States by Average PM2.5 in 2020', width=500, height=300) return chart " 4031,Plot the rolling 30-day average PM2.5 for Jharkhand in 2019 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Jharkhand') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Jharkhand 2019', width=600, height=300) " 4032,Create a heatmap showing the average PM2.5 by month (x-axis) and year (y-axis) for Madhya Pradesh.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Madhya Pradesh'].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Year:N', title='Year'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='Avg PM2.5'), tooltip=['Year:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Madhya Pradesh (Month × Year)', width=500, height=280) return chart " 4033,Show average PM10 per capita by state in 2021 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM10 per million', 'numerator': 'PM10', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'PM10 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4034,"Plot the yearly average PM2.5 trends for Rajasthan, Andhra Pradesh, and Chandigarh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Andhra Pradesh', 'Chandigarh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Rajasthan vs Andhra Pradesh vs Chandigarh', width=550, height=320) return chart " 4035,Report the state that had the 3rd lowest 75th percentile of PM10 in October 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 4036,Show the monthly average PM2.5 for Nagaland across each year from 2017 to 2024 as small multiples (faceted by year).," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Nagaland'].copy() df['Year'] = df['Timestamp'].dt.year df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5'), tooltip=['Year:O','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet( facet=alt.Facet('Year:O', title='Year'), columns=4 ).properties(title='Monthly PM2.5 in Nagaland by Year (2017–2024)') return chart " 4037,Tabulate average PM2.5 for each state across all months in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Bihar', 'Delhi', 'Gujarat', 'Haryana', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4038,"Which state showed the third-lowest average PM10 on March 31, 2024?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 4039,List states by PM2.5 concentration per million inhabitants in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM2.5 per million', 'numerator': 'PM2.5', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'PM2.5 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4040,Plot the weekly average PM2.5 for Alwar in 2017 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Alwar') & (data['Timestamp'].dt.year == 2017)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Alwar 2017', width=600, height=300) return chart " 4041,Show a table of the 20 cleanest citys by average PM2.5 in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 4042,"Plot the yearly average PM2.5 trends for Assam, Uttarakhand, and Haryana from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Assam', 'Uttarakhand', 'Haryana'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Assam vs Uttarakhand vs Haryana', width=550, height=320) return chart " 4043,Which station had the 2nd lowest 75th percentile of PM10 in February 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 4044,Show the monthly average PM2.5 for Kurukshetra in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Kurukshetra ') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Kurukshetra 2018', width=450, height=280) " 4045,"Which union territory possesses the largest land area among the top 2 most polluted union territories, based on total PM10 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'sum', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 2, 'ret': 'state'}}] " 4046,List states with their PM2.5 violation count and rate (>100 µg/m³) in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4047,Determine the state that recorded the 2nd most minimal median PM10 over the Post-Monsoon season of 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 4048,Which state observed the most significant increase in median PM10 levels when comparing October 2019 to October 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 4049,"Create a grouped bar chart comparing the average PM2.5 for West Bengal, Bihar, and Uttar Pradesh across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['West Bengal', 'Bihar', 'Uttar Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 4050,"Determine which state (excluding UTs) has the 2nd smallest population within the top 10 most polluted states, based on standard deviation of PM2.5 levels."," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'std', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 10, 'ret': 'state'}}] " 4051,Show the monthly average PM2.5 for Noida in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Noida') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Noida 2017', width=450, height=280) " 4052,Which 15 citys had the lowest mean PM2.5 in 2017? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 4053,"In November 2022, which station showed the 3rd highest 25th percentile of PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 4054,Plot the median PM10 for each state in summer 2023 (April–June) as a sorted bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['Timestamp'].dt.year == 2023) & (data['Timestamp'].dt.month.isin([4,5,6]))] df = df.groupby('state')['PM10'].median().reset_index().dropna() df = df.sort_values('PM10', ascending=False) chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Median PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='yelloworangered'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Median PM10 by State – Summer 2023 (Apr–Jun)', width=500, height=400) return chart " 4055,"Create a grouped bar chart comparing the average PM2.5 for Kerala, Rajasthan, and Andhra Pradesh across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Kerala', 'Rajasthan', 'Andhra Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 4056,Plot the monthly average PM2.5 trend for Uttar Pradesh from 2017 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Uttar Pradesh'].copy() df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly Average PM2.5 Trend – Uttar Pradesh (2017–2024)', width=600, height=300) return chart " 4057,"Compare the monthly average PM2.5 of Ujjain, Hajipur, and Pratapgarh in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Ujjain', 'Hajipur', 'Pratapgarh'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Ujjain vs Hajipur vs Pratapgarh – 2022', width=550, height=320) return chart " 4058,Tabulate the monthly mean PM2.5 levels for Gurugram during 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Gurugram'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4059,List states with their PM10 violation count and rate (>150 µg/m³) in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 150'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4060,Which city had the lowest median PM10 in July 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 4061,Show the monthly average PM2.5 for Rourkela in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Rourkela') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Rourkela 2018', width=450, height=280) " 4062,Report which city registered the third lowest PM2.5 level on 27 January 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 4063,Show a pivot table of monthly average PM2.5 by city for Haryana in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Haryana'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Faridabad', 'Gurugram', 'Panchkula', 'Rohtak']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4064,Report the city with the 2nd highest 25th percentile of PM2.5 in March 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 4065,Plot the top 12 states by average PM2.5 in 2021 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2021] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(12, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 12 States by Average PM2.5 in 2021', width=500, height=300) return chart " 4066,Report the city with the 2nd lowest 25th percentile of PM2.5 in May 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 4067,Plot the rolling 30-day average PM2.5 for Maharashtra in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Maharashtra') & (data['Timestamp'].dt.year == 2020)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Maharashtra 2020', width=600, height=300) " 4068,Plot the top 9 states by average PM2.5 in 2024 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2024] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(9, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 9 States by Average PM2.5 in 2024', width=500, height=300) return chart " 4069,"Compare the monthly average PM2.5 of Bhilai, Mandikhera, and Bhiwandi in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Bhilai', 'Mandikhera', 'Bhiwandi'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Bhilai vs Mandikhera vs Bhiwandi – 2024', width=550, height=320) return chart " 4070,Generate a year-by-year summary table of PM2.5 readings for Jaipur.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Jaipur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4071,Which city had the 3rd highest median PM2.5 in September 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 4072,"Create a table showing top 15 states ranked by PM2.5 in 2018, also showing PM10."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 4073,Show a pivot table of monthly average PM2.5 by city for Rajasthan in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Ajmer', 'Alwar', 'Bhiwadi', 'Jaipur', 'Jodhpur', 'Kota', 'Pali', 'Udaipur']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4074,Show the monthly average PM10 trend for Kishanganj from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Kishanganj'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Kishanganj (2017–2022)', width=600, height=300) return chart " 4075,Plot the rolling 30-day average PM2.5 for Nagaland in 2019 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Nagaland') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Nagaland 2019', width=600, height=300) " 4076,Name the state with the highest median PM10 value in April 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 4077,"On March 31, 2021, which city recorded the second-highest average PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 4078,Tabulate the 15 states with the least PM2.5 pollution in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 4079,Determine the third-lowest PM2.5 reading from 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}] " 4080,Show the monthly average PM2.5 for Haveri in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Haveri') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Haveri 2019', width=450, height=280) " 4081,Show a bar chart of the top 15 cities by median PM2.5 in 2020.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2020] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(15, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 15 Cities by Median PM2.5 in 2020', width=500, height=300) return chart " 4082,"Show the mean, median and standard deviation of PM2.5 per state in 2023 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4083,Create a month-wise PM2.5 breakdown table across cities in Haryana for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Haryana'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Ambala', 'Bahadurgarh', 'Ballabgarh', 'Bhiwani', 'Dharuhera', 'Faridabad', 'Fatehabad', 'Gurugram', 'Hisar', 'Jind', 'Kaithal', 'Karnal', 'Kurukshetra', 'Mandikhera', 'Manesar', 'Narnaul', 'Palwal', 'Panchkula', 'Panipat', 'Rohtak', 'Sirsa', 'Sonipat', 'Yamuna Nagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4084,Identify the state with the lowest 75th percentile of PM2.5 in June 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 4085,Create a table of PM2.5 standard violations (>100 µg/m³) per state in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4086,Show the monthly average PM2.5 for Hosur in 2023 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Hosur') & (data['Timestamp'].dt.year == 2023)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Hosur 2023', width=450, height=280) " 4087,"Visualize the monthly average PM10 for Uttarakhand, Himachal Pradesh, and Jammu and Kashmir in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttarakhand', 'Himachal Pradesh', 'Jammu and Kashmir'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Uttarakhand, Himachal Pradesh, UP – 2022', width=550, height=320) return chart " 4088,Show the number of days each city exceeded a PM2.5 threshold of 100 µg/m³ in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4089,List the bottom 20 states with the lowest average PM10 in 2020 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 4090,"Identify the station with the second-lowest median PM10 on March 31, 2022."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 4091,List the top 20 states by PM2.5 in 2020 with both PM2.5 and PM10 averages.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 4092,Show the monthly average PM2.5 for Ulhasnagar in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ulhasnagar') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Ulhasnagar 2020', width=450, height=280) " 4093,"Plot the yearly average PM2.5 trends for Tripura, Madhya Pradesh, and Meghalaya from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tripura', 'Madhya Pradesh', 'Meghalaya'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Tripura vs Madhya Pradesh vs Meghalaya', width=550, height=320) return chart " 4094,"Visualize the monthly average PM10 for Assam, Karnataka, and Tamil Nadu in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Assam', 'Karnataka', 'Tamil Nadu'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Assam, Karnataka, UP – 2021', width=550, height=320) return chart " 4095,Plot the rolling 30-day average PM2.5 for Chandigarh in 2019 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Chandigarh') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Chandigarh 2019', width=600, height=300) " 4096,"Visualize the monthly average PM10 for Odisha, Maharashtra, and Punjab in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Odisha', 'Maharashtra', 'Punjab'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Odisha, Maharashtra, UP – 2023', width=550, height=320) return chart " 4097,Plot the rolling 30-day average PM2.5 for Manipur in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Manipur') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Manipur 2023', width=600, height=300) " 4098,"Show the variability of PM10 across citys in 2020 using mean, median, and standard deviation."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4099,"On August 15, 2020, which state had the third-most elevated PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 4100,Create a table showing PM2.5 levels and population for each state in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4101,Which state had the second-lowest average PM2.5 reading for January 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 4102,Identify the station with the 3rd lowest 75th percentile of PM10 in October 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 4103,Generate a monthly average PM2.5 table for Bihar for the year 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Bihar'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4104,Tabulate the monthly mean PM2.5 levels for Gujarat during 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Gujarat'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4105,Show how many times PM2.5 exceeded 100 µg/m³ per day across states in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4106,Determine the city allocated the least NCAP funding.," [] " 4107,Show the monthly average PM2.5 for Rishikesh in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Rishikesh') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Rishikesh 2018', width=450, height=280) " 4108,Create a ranked table of the 20 best-performing states by PM2.5 in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 4109,Visualize the bottom 15 states with the lowest average PM2.5 in 2017 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2017] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(15, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 15 States by Average PM2.5 in 2017', width=500, height=300) return chart " 4110,Which 10 states recorded the highest average PM2.5 levels in 2019? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 4111,"Across all recorded years, which July registered the second-lowest average PM2.5 concentration?"," [{'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'Timestamp'}}] " 4112,"Show the variability of PM2.5 across states in 2019 using mean, median, and standard deviation."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4113,Tabulate the top 5 states for PM2.5 in 2019 along with their corresponding PM10 values.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 4114,Create a month-wise PM2.5 breakdown table across cities in Punjab for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Amritsar', 'Bathinda', 'Jalandhar', 'Khanna', 'Ludhiana', 'Mandi Gobindgarh', 'Patiala', 'Rupnagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4115,Show a cumulative area chart of PM2.5 readings for Solapur across 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Solapur') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Solapur 2018', width=600, height=300) return chart " 4116,List the bottom 10 citys with the lowest average PM10 in 2020 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 4117,Show the monthly average PM2.5 for Ahmedabad in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ahmedabad') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Ahmedabad 2017', width=450, height=280) " 4118,"Visualize the monthly average PM10 for Himachal Pradesh, Kerala, and Mizoram in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Himachal Pradesh', 'Kerala', 'Mizoram'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Himachal Pradesh, Kerala, UP – 2022', width=550, height=320) return chart " 4119,"Which city showed the highest median PM10 on March 31, 2022?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 4120,Generate a monthly average PM10 table for Nagaland for the year 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Nagaland'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4121,Which 20 states had the lowest mean PM10 in 2017? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 4122,Generate a year-by-year summary table of PM2.5 readings for Chandigarh.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Chandigarh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4123,Tabulate the yearly average PM2.5 trend for Madhya Pradesh across all years.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4124,List how many days each city breached the PM2.5 limit of 60 µg/m³ in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4125,Show a year-wise table of average PM10 for Tamil Nadu from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4126,"In October 2019, which state recorded the 3rd lowest 75th percentile of PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 4127,Create a per-capita PM2.5 summary table by state for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM2.5 per million', 'numerator': 'PM2.5', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'PM2.5 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4128,Show a monthly breakdown table of average PM10 for Meerut in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Meerut'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4129,"Visualize the monthly average PM10 for Andhra Pradesh, Tripura, and Haryana in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Tripura', 'Haryana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Andhra Pradesh, Tripura, UP – 2018', width=550, height=320) return chart " 4130,"Show the top 6 states by average PM10 in 2018 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2018] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(6, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 6 States by Average PM10 in 2018', width=500, height=300) return chart " 4131,Create a summary table comparing mean PM2.5 and PM10 across states in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4132,"Show the top 10 states by average PM10 in 2019 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2019] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(10, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 10 States by Average PM10 in 2019', width=500, height=300) return chart " 4133,Create a month-wise PM10 breakdown table across cities in Maharashtra for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Ahmednagar', 'Akola', 'Amravati', 'Aurangabad', 'Badlapur', 'Belapur', 'Bhiwandi', 'Boisar', 'Chandrapur', 'Dhule', 'Jalgaon', 'Jalna', 'Kalyan', 'Kolhapur', 'Latur', 'Mahad', 'Malegaon', 'Mira-Bhayandar', 'Mumbai', 'Nagpur', 'Nanded', 'Nashik', 'Navi Mumbai', 'Parbhani', 'Pimpri-Chinchwad', 'Pune', 'Sangli', 'Solapur', 'Thane', 'Ulhasnagar', 'Virar']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4134,Show a pivot table of monthly average PM2.5 by city for Andhra Pradesh in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Tirupati']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4135,Identify the city with the 3rd lowest NCAP funding considering its 75th percentile of PM10 concentration in 2020 (FY 2019-20).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2020_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 4136,Determine the station exhibiting the 2nd highest average PM10 over the Winter season of 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 4137,Show the monthly average PM2.5 for Keonjhar in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Keonjhar') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Keonjhar 2019', width=450, height=280) " 4138,"Plot the yearly average PM2.5 trends for Telangana, Madhya Pradesh, and Jammu and Kashmir from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Telangana', 'Madhya Pradesh', 'Jammu and Kashmir'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Telangana vs Madhya Pradesh vs Jammu and Kashmir', width=550, height=320) return chart " 4139,Which 10 citys had the lowest mean PM10 in 2020? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 4140,"Visualize the monthly average PM10 for Chandigarh, Delhi, and Bihar in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chandigarh', 'Delhi', 'Bihar'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Chandigarh, Delhi, UP – 2021', width=550, height=320) return chart " 4141,Identify the state that recorded the highest median PM2.5 value in January 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 4142,"For 2018, which weekday experienced the third-lowest 25th percentile of PM10 pollution levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'Timestamp'}}] " 4143,Show a pivot table of monthly average PM10 by state for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Arunachal Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Chhattisgarh', 'Delhi', 'Gujarat', 'Haryana', 'Himachal Pradesh', 'Jammu and Kashmir', 'Jharkhand', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Manipur', 'Meghalaya', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh', 'Uttarakhand', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4144,Plot the top 13 states by average PM2.5 in 2021 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2021] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(13, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 13 States by Average PM2.5 in 2021', width=500, height=300) return chart " 4145,List average PM2.5 by month for Nagaland in 2022 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Nagaland'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4146,Which state had the 2nd highest 75th percentile of PM10 in August 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 4147,Create a summary table ranking the top 10 states by PM10 concentration in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 4148,Visualize the bottom 6 states with the lowest average PM2.5 in 2020 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2020] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(6, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 6 States by Average PM2.5 in 2020', width=500, height=300) return chart " 4149,Show the monthly average PM2.5 for Bulandshahr in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bulandshahr') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Bulandshahr 2017', width=450, height=280) " 4150,List states ranked by PM2.5 concentration relative to their area in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, { 'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM2.5 per km²', 'numerator': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)', 'PM2.5 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4151,Generate a table showing the 15 most polluted states based on mean PM2.5 for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 4152,Determine the city with the lowest average PM2.5 in May 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 4153,Tabulate days with PM10 > 100 µg/m³ and exceedance percentage per city in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4154,"In January 2018, report the city with the 2nd highest 75th percentile of PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 4155,"Create a grouped bar chart comparing the average PM2.5 for Rajasthan, Maharashtra, and Kerala across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Maharashtra', 'Kerala'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 4156,Which state recorded the 3rd highest 25th percentile of PM10 in February 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 4157,Create a ranked table of the 20 best-performing citys by PM10 in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 4158,Which 5 states had the lowest mean PM2.5 in 2021? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 4159,Show the monthly average PM10 trend for Gadag from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Gadag'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Gadag (2017–2022)', width=600, height=300) return chart " 4160,"Plot the yearly average PM2.5 trends for Mizoram, Madhya Pradesh, and Arunachal Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Mizoram', 'Madhya Pradesh', 'Arunachal Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Mizoram vs Madhya Pradesh vs Arunachal Pradesh', width=550, height=320) return chart " 4161,Which state recorded the peak 75th percentile of PM10 during the Post-Monsoon season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 4162,Identify the state that showed the most minimal median PM10 during the Post-Monsoon season of 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 4163,Determine the state with the 3rd highest 25th percentile of PM10 in November 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 4164,Visualize the bottom 15 states with the lowest average PM2.5 in 2023 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2023] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(15, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 15 States by Average PM2.5 in 2023', width=500, height=300) return chart " 4165,Create a table of PM2.5 exceedance frequency above 100 µg/m³ by city for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4166,Show the monthly average PM2.5 for Jodhpur in 2022 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Jodhpur') & (data['Timestamp'].dt.year == 2022)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Jodhpur 2022', width=450, height=280) " 4167,Create a table of PM2.5 exceedance frequency above 60 µg/m³ by city for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4168,Generate a year-by-year summary table of PM10 readings for Jammu and Kashmir.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Jammu and Kashmir'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4169,"On January 5, 2020, which station showed the third-highest average PM2.5 concentration?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 4170,"Scatter plot PM2.5 vs PM10 for Puducherry stations in 2023, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Puducherry') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Puducherry Stations 2023', width=450, height=350) " 4171,"Scatter plot PM2.5 vs PM10 for Tripura stations in 2021, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Tripura') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Tripura Stations 2021', width=450, height=350) " 4172,Generate a monthly average PM10 table for Moradabad for the year 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Moradabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4173,List states with their PM2.5 violation count and rate (>100 µg/m³) in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4174,Show the monthly average PM2.5 for Ajmer in 2022 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ajmer') & (data['Timestamp'].dt.year == 2022)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Ajmer 2022', width=450, height=280) " 4175,"During 2022, determine the week number that showed the second-highest median PM2.5 levels."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'week'}}] " 4176,Which state registered the 2nd maximum average PM2.5 in the Winter season of 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 4177,Plot the rolling 30-day average PM2.5 for Andhra Pradesh in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Andhra Pradesh') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Andhra Pradesh 2024', width=600, height=300) " 4178,"Plot the yearly average PM2.5 trends for Mizoram, Meghalaya, and Andhra Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Mizoram', 'Meghalaya', 'Andhra Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Mizoram vs Meghalaya vs Andhra Pradesh', width=550, height=320) return chart " 4179,Show the monthly average PM10 trend for Gorakhpur from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Gorakhpur'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Gorakhpur (2019–2024)', width=600, height=300) return chart " 4180,Generate a monthly average PM10 table for West Bengal for the year 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'West Bengal'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4181,Which city had the highest 25th percentile of PM10 in September 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 4182,"Plot the yearly average PM2.5 trends for Telangana, Assam, and Chhattisgarh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Telangana', 'Assam', 'Chhattisgarh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Telangana vs Assam vs Chhattisgarh', width=550, height=320) return chart " 4183,"On March 31, 2018, which state recorded the second-highest average PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 4184,"In 2019, which state will rank with the second smallest reduction in 75th percentile PM2.5 levels from October to December?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 4185,Show how average PM2.5 varied month by month for Mizoram in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Mizoram'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4186,Plot the top 11 states by average PM2.5 in 2022 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2022] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(11, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 11 States by Average PM2.5 in 2022', width=500, height=300) return chart " 4187,Show the monthly average PM2.5 for Bhiwadi in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bhiwadi') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Bhiwadi 2020', width=450, height=280) " 4188,Which city recorded the lowest average PM10 in November 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 4189,"Compare the monthly average PM2.5 of Chandrapur, Jhansi, and Belapur in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Chandrapur', 'Jhansi', 'Belapur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Chandrapur vs Jhansi vs Belapur – 2022', width=550, height=320) return chart " 4190,Which station noted the 3rd minimum 25th percentile of PM2.5 during the Monsoon season of 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 4191,Create a month-wise summary of average PM2.5 for Bihar in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Bihar'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4192,"Create a grouped bar chart comparing the average PM2.5 for Jammu and Kashmir, Uttarakhand, and Assam across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jammu and Kashmir', 'Uttarakhand', 'Assam'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 4193,List the average PM2.5 for Kanpur broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Kanpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4194,"Among union territories with a population below the average, identify the one that receives the lowest per capita NCAP funding."," [{'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_capita', 'numerator': 'total_fund', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'funding_per_capita', 'ascending': True}}] " 4195,"Scatter plot PM2.5 vs PM10 for Bihar stations in 2020, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Bihar') & (data['Timestamp'].dt.year == 2020)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Bihar Stations 2020', width=450, height=350) " 4196,"Which state (excluding Union Territories) presents the lowest PM10 concentration per square kilometer, according to total PM10 values?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'sum', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_km2', 'numerator': 'PM10', 'denominator': 'area (km2)'}}, {'op': 'SORT', 'params': {'col': 'pm_per_km2', 'ascending': True}}] " 4197,"Compare the monthly average PM2.5 of Thiruvananthapuram, Tirupati, and Rourkela in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Thiruvananthapuram', 'Tirupati', 'Rourkela'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Thiruvananthapuram vs Tirupati vs Rourkela – 2023', width=550, height=320) return chart " 4198,Show the monthly average PM2.5 for Jhalawar in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Jhalawar') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Jhalawar 2018', width=450, height=280) " 4199,List average PM10 by month for Bengaluru in 2024 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Bengaluru'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4200,Generate a table showing the 20 most polluted states based on mean PM10 for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 4201,Show the monthly average PM2.5 for Bhubaneswar in 2023 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bhubaneswar') & (data['Timestamp'].dt.year == 2023)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Bhubaneswar 2023', width=450, height=280) " 4202,"Create a grouped bar chart comparing the average PM2.5 for Himachal Pradesh, Andhra Pradesh, and Kerala across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Himachal Pradesh', 'Andhra Pradesh', 'Kerala'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 4203,"Scatter plot PM2.5 vs PM10 for Manipur stations in 2023, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Manipur') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Manipur Stations 2023', width=450, height=350) " 4204,Tabulate average PM2.5 for each city in Kerala across all months of 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Eloor', 'Kannur', 'Kochi', 'Kollam', 'Thiruvananthapuram', 'Thrissur']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4205,"Compare the monthly average PM2.5 of Sirsa, Thiruvananthapuram, and Byrnihat in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Sirsa', 'Thiruvananthapuram', 'Byrnihat'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Sirsa vs Thiruvananthapuram vs Byrnihat – 2022', width=550, height=320) return chart " 4206,Show how average PM10 varied month by month for Lucknow in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Lucknow'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4207,"Plot the yearly average PM2.5 trends for Uttarakhand, Uttar Pradesh, and Punjab from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttarakhand', 'Uttar Pradesh', 'Punjab'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Uttarakhand vs Uttar Pradesh vs Punjab', width=550, height=320) return chart " 4208,"In Chandrapur, which date in the previous three years showed the lowest PM10 concentration?"," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 3}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'Timestamp'}}] " 4209,Tabulate the 20 citys with the least PM10 pollution in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 4210,During which financial year was the variance in NCAP funding release the smallest among cities?," [] " 4211,"Identify the union territory with the second smallest population among the top 2 most polluted union territories, based on variance of PM2.5 levels."," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'var', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 2, 'ret': 'state'}}] " 4212,Show a monthly bar chart of the number of days Arunachal Pradesh exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Arunachal Pradesh') & (data['Timestamp'].dt.year == 2022)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Arunachal Pradesh Exceeded WHO PM2.5 Guideline per Month – 2022', width=500, height=300) return chart " 4213,Tabulate days with PM2.5 > 100 µg/m³ and exceedance percentage per state in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4214,Tabulate the 20 worst citys for average PM2.5 in 2023 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 4215,Which 5 states recorded the highest average PM2.5 levels in 2020? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 4216,Create a heatmap showing the average PM2.5 by month (x-axis) and year (y-axis) for Meghalaya.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Meghalaya'].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Year:N', title='Year'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='Avg PM2.5'), tooltip=['Year:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Meghalaya (Month × Year)', width=500, height=280) return chart " 4217,"Create a grouped bar chart comparing the average PM2.5 for Mizoram, Telangana, and Rajasthan across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Mizoram', 'Telangana', 'Rajasthan'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 4218,Determine which state had the 5th lowest NCAP funding relative to its total PM2.5 concentration in 2021 (FY 2020-21).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'sum', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 4219,"Compare the monthly average PM2.5 of Pali, Ramanathapuram, and Ratlam in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Pali', 'Ramanathapuram', 'Ratlam'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Pali vs Ramanathapuram vs Ratlam – 2019', width=550, height=320) return chart " 4220,Show a cumulative area chart of PM2.5 readings for Brajrajnagar across 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Brajrajnagar') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Brajrajnagar 2024', width=600, height=300) return chart " 4221,Which station noted the peak average PM2.5 during the Winter season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 4222,Tabulate the yearly average PM10 trend for Madhya Pradesh across all years.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4223,Create a table of total NCAP funding by state sorted by amount.," [ {'op': 'SOURCE', 'params': {'table': 'ncap'}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'Total fund released', 'fn': 'sum'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Total fund released'}}, {'op': 'RENAME', 'params': {'map': {'Total fund released': 'Total Fund Released (Cr)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4224,Generate a city × month cross-tab of mean PM10 for Odisha in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Odisha'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Brajrajnagar', 'Talcher']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4225,Show a monthly bar chart of the number of days Delhi exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Delhi') & (data['Timestamp'].dt.year == 2023)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Delhi Exceeded WHO PM2.5 Guideline per Month – 2023', width=500, height=300) return chart " 4226,Which state showed the 3rd lowest average PM10 in February 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 4227,Tabulate average and median PM2.5 for all states in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4228,Which state receiving NCAP funding has the 3rd lowest PM10 levels?," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}] " 4229,"Create a grouped bar chart comparing the average PM2.5 for Telangana, Maharashtra, and Meghalaya across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Telangana', 'Maharashtra', 'Meghalaya'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 4230,Create a month-wise summary of average PM2.5 for Gaya in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Gaya'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4231,Identify the state that registered the second highest 25th percentile for PM10 historically.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 4232,"Scatter plot PM2.5 vs PM10 for Sikkim stations in 2023, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Sikkim') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Sikkim Stations 2023', width=450, height=350) " 4233,Show the monthly average PM2.5 for Rajsamand in 2023 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Rajsamand') & (data['Timestamp'].dt.year == 2023)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Rajsamand 2023', width=450, height=280) " 4234,Plot the weekly average PM2.5 for Araria in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Araria') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Araria 2023', width=600, height=300) return chart " 4235,Which state had the 3rd lowest median PM10 in March 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 4236,Which station showed the 3rd lowest 25th percentile of PM10 in the Winter season of 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 4237,Generate a year-by-year summary table of PM2.5 readings for Agra.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Agra'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4238,Plot the weekly average PM2.5 for Arrah in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Arrah') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Arrah 2023', width=600, height=300) return chart " 4239,"List each state's average PM2.5, PM10, and how many stations it has in 2024."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}, {'alias': 'Station Count', 'col': 'station', 'fn': 'nunique'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4240,Show a ranked table of the 5 most polluted citys by average PM10 in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 4241,Identify the station with the 3rd highest 75th percentile of PM10 for December 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 4242,"Plot the yearly average PM2.5 trends for Bihar, Rajasthan, and Gujarat from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Bihar', 'Rajasthan', 'Gujarat'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Bihar vs Rajasthan vs Gujarat', width=550, height=320) return chart " 4243,Plot the rolling 30-day average PM2.5 for Karnataka in 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Karnataka') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Karnataka 2022', width=600, height=300) " 4244,"Which union territory has the minimum land area among the top 2 most polluted union territories, according to the 25th percentile of PM10 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 2, 'ret': 'state'}}] " 4245,Report the station that had the 2nd lowest average PM10 in July 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 4246,Report the state with the 5th highest NCAP funding relative to the standard deviation of its PM2.5 concentration in 2021 (FY 2020-21).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'std', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 4247,Identify the city with the lowest average PM2.5 for November 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 4248,Show a pivot table of monthly average PM10 by city for Uttar Pradesh in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Agra', 'Baghpat', 'Bareilly', 'Bulandshahr', 'Firozabad', 'Ghaziabad', 'Gorakhpur', 'Greater Noida', 'Hapur', 'Jhansi', 'Kanpur', 'Khurja', 'Lucknow', 'Meerut', 'Moradabad', 'Muzaffarnagar', 'Noida', 'Prayagraj', 'Varanasi', 'Vrindavan']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4249,Identify the city that recorded the highest 25th percentile of PM2.5 value in January 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 4250,Report which state experienced the 2nd most minimal 75th percentile of PM10 throughout the Monsoon season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 4251,"Create a grouped bar chart comparing the average PM2.5 for Uttarakhand, Sikkim, and Arunachal Pradesh across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttarakhand', 'Sikkim', 'Arunachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 4252,Show a cumulative area chart of PM2.5 readings for Chandigarh across 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Chandigarh') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Chandigarh 2024', width=600, height=300) return chart " 4253,Which state registered the highest median PM2.5 during February 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 4254,"In 2024, which day of the week corresponded to the second-highest median PM10 pollution levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'Timestamp'}}] " 4255,"Create a grouped bar chart comparing the average PM2.5 for Telangana, Maharashtra, and Nagaland across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Telangana', 'Maharashtra', 'Nagaland'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 4256,"Plot the yearly average PM2.5 trends for Manipur, Punjab, and Haryana from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Manipur', 'Punjab', 'Haryana'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Manipur vs Punjab vs Haryana', width=550, height=320) return chart " 4257,"Plot the yearly average PM2.5 trends for Haryana, Himachal Pradesh, and Uttarakhand from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Himachal Pradesh', 'Uttarakhand'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Haryana vs Himachal Pradesh vs Uttarakhand', width=550, height=320) return chart " 4258,Create a table of PM10 standard violations (>150 µg/m³) per city in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4259,Show a year-wise table of average PM10 for Assam from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Assam'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4260,Determine the city exhibiting the 3rd most minimal 25th percentile of PM2.5 over the Post-Monsoon season of 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 4261,Create a summary table ranking the top 15 states by PM10 concentration in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 4262,Determine the city with the lowest median PM10 in March 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 4263,Which state demonstrates the highest median PM10 concentration in relation to its population density?," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_capita', 'numerator': 'PM10', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'pm_per_capita', 'ascending': False}}] " 4264,Find the station with the minimum median PM10 reading for February 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 4265,"Create a grouped bar chart comparing the average PM2.5 for Manipur, Tripura, and Bihar across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Manipur', 'Tripura', 'Bihar'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 4266,"Create a grouped bar chart comparing the average PM2.5 for Chandigarh, Tamil Nadu, and Karnataka across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chandigarh', 'Tamil Nadu', 'Karnataka'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 4267,Show a table of the 5 cleanest citys by average PM2.5 in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 4268,"Determine which union territory has the smallest population among the top 2 most polluted union territories, based on average PM2.5 levels."," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 2, 'ret': 'state'}}] " 4269,Plot the rolling 30-day average PM2.5 for Maharashtra in 2018 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Maharashtra') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Maharashtra 2018', width=600, height=300) " 4270,"Visualize the monthly average PM10 for Kerala, Maharashtra, and Bihar in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Kerala', 'Maharashtra', 'Bihar'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Kerala, Maharashtra, UP – 2023', width=550, height=320) return chart " 4271,"Scatter plot PM2.5 vs PM10 for Bihar stations in 2019, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Bihar') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Bihar Stations 2019', width=450, height=350) " 4272,Create a table showing annual mean PM2.5 levels for Prayagraj (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Prayagraj'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4273,"Which union territory with a land area greater than 1,000 km² shows the 2nd lowest PM2.5 level, based on its standard deviation of PM2.5 level?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'std', 'col': 'PM2.5'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}] " 4274,"Create a grouped bar chart comparing the average PM2.5 for Himachal Pradesh, Jharkhand, and West Bengal across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Himachal Pradesh', 'Jharkhand', 'West Bengal'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 4275,Show a bar chart of the top 12 cities by median PM2.5 in 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2018] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(12, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 12 Cities by Median PM2.5 in 2018', width=500, height=300) return chart " 4276,"Create a grouped bar chart comparing the average PM2.5 for Tamil Nadu, Rajasthan, and Telangana across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Rajasthan', 'Telangana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 4277,Show a monthly bar chart of the number of days Jammu and Kashmir exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Jammu and Kashmir') & (data['Timestamp'].dt.year == 2024)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Jammu and Kashmir Exceeded WHO PM2.5 Guideline per Month – 2024', width=500, height=300) return chart " 4278,"Visualize the monthly average PM10 for Delhi, Meghalaya, and Karnataka in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Delhi', 'Meghalaya', 'Karnataka'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Delhi, Meghalaya, UP – 2023', width=550, height=320) return chart " 4279,Tabulate the monthly mean PM2.5 levels for Muzaffarpur during 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Muzaffarpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4280,"Determine which union territory has the second largest population within the top 4 most polluted union territories, based on total PM10 levels."," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'sum', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 4, 'ret': 'state'}}] " 4281,Create a table showing annual mean PM10 levels for Andhra Pradesh (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4282,"Visualize the monthly average PM10 for Assam, Uttarakhand, and Haryana in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Assam', 'Uttarakhand', 'Haryana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Assam, Uttarakhand, UP – 2024', width=550, height=320) return chart " 4283,Show a monthly bar chart of the number of days Assam exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Assam') & (data['Timestamp'].dt.year == 2023)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Assam Exceeded WHO PM2.5 Guideline per Month – 2023', width=500, height=300) return chart " 4284,Which state registered the lowest average PM10 during December 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 4285,Create a table showing annual mean PM2.5 levels for Kanpur (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Kanpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4286,"In May 2022, which station exhibited the 3rd highest median PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 4287,Determine the state exhibiting the highest 75th percentile of PM10 over the Monsoon season of 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 4288,Show the number of days each city exceeded a PM10 threshold of 100 µg/m³ in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4289,What number of Nagaland stations surpassed 75 µg/m³ of PM2.5 in 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 75.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 4290,Generate a cross-tab of state vs month for average PM2.5 in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Bihar', 'Delhi', 'Gujarat', 'Haryana', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Odisha', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4291,Create a month-wise PM2.5 breakdown table across cities in Karnataka for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Bagalkot', 'Bengaluru', 'Chikkaballapur', 'Chikkamagaluru', 'Mysuru', 'Ramanagara', 'Shivamogga']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4292,"Show the mean, median and standard deviation of PM10 per city in 2017 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4293,"Identify the season in 2018 (Winter, Summer, Monsoon, Post-Monsoon) that registered the second-highest 75th percentile of PM2.5 levels."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'season'}}] " 4294,"Considering all years, which January showed the maximum median PM10 concentration?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'Timestamp'}}] " 4295,Determine the station with the minimum 25th percentile for PM2.5 in August 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 4296,Show the monthly average PM2.5 for Davanagere in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Davanagere') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Davanagere 2018', width=450, height=280) " 4297,How many times did Alwar city surpass 30 µg/m³ of PM10 in 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 30.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 4298,Show PM10 averages in a state × month matrix for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Delhi', 'Gujarat', 'Haryana', 'Jharkhand', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4299,Show the monthly average PM2.5 for Pimpri-Chinchwad in 2022 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Pimpri-Chinchwad') & (data['Timestamp'].dt.year == 2022)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Pimpri-Chinchwad 2022', width=450, height=280) " 4300,Show annual average PM10 for Kanpur as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Kanpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4301,"Visualize the monthly average PM10 for Punjab, Sikkim, and Maharashtra in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Punjab', 'Sikkim', 'Maharashtra'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Punjab, Sikkim, UP – 2017', width=550, height=320) return chart " 4302,"Comparing December 2023 to October 2023, which station showed the second least significant drop in 75th percentile PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 4303,Generate a cross-tab of state vs month for average PM10 in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Arunachal Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Chhattisgarh', 'Delhi', 'Gujarat', 'Haryana', 'Himachal Pradesh', 'Jammu and Kashmir', 'Jharkhand', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Manipur', 'Meghalaya', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh', 'Uttarakhand', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4304,List the average PM10 for Telangana broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Telangana'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4305,Generate a monthly average PM2.5 table for Madhya Pradesh for the year 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4306,"Identify the state, from those with a population less than the 25th percentile, which receives the lowest per capita NCAP funding."," [{'op': 'COMPUTE', 'params': {'new_col': 'funding_per_capita', 'numerator': 'total_fund', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'funding_per_capita', 'ascending': True}}] " 4307,Show how average PM10 varied month by month for Maharashtra in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4308,Report which state possessed the peak average PM2.5 throughout the Summer season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 4309,Show a cumulative area chart of PM2.5 readings for Kishanganj across 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Kishanganj') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Kishanganj 2021', width=600, height=300) return chart " 4310,Create a table showing annual mean PM10 levels for Maharashtra (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4311,Which city got the 5th highest NCAP funding considering its 25th percentile of PM10 concentration in 2022 (FY 2021-22)?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2022_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 4312,"Create a grouped bar chart comparing the average PM2.5 for Meghalaya, Jharkhand, and Assam across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Meghalaya', 'Jharkhand', 'Assam'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 4313,Identify the state that registered the peak median PM10 during the Winter season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 4314,Which station had the 2nd highest 75th percentile of PM10 in February 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 4315,Show a monthly bar chart of the number of days Arunachal Pradesh exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Arunachal Pradesh') & (data['Timestamp'].dt.year == 2021)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Arunachal Pradesh Exceeded WHO PM2.5 Guideline per Month – 2021', width=500, height=300) return chart " 4316,Show the monthly average PM10 trend for Barbil from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Barbil'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Barbil (2019–2024)', width=600, height=300) return chart " 4317,Tabulate population-adjusted PM2.5 levels for each state in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM2.5 per million', 'numerator': 'PM2.5', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'PM2.5 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4318,"Visualize the monthly average PM10 for Karnataka, Nagaland, and Himachal Pradesh in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Karnataka', 'Nagaland', 'Himachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Karnataka, Nagaland, UP – 2021', width=550, height=320) return chart " 4319,Tabulate the monthly mean PM10 levels for Maharashtra during 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4320,"Compare the monthly average PM2.5 of Solapur, Pithampur, and Rajsamand in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Solapur', 'Pithampur', 'Rajsamand'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Solapur vs Pithampur vs Rajsamand – 2017', width=550, height=320) return chart " 4321,What number of Chhattisgarh stations exceeded 30 µg/m³ of PM10 in 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 30.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 4322,Show average PM10 per capita by state in 2022 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM10 per million', 'numerator': 'PM10', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'PM10 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4323,"Plot the yearly average PM2.5 trends for Gujarat, Telangana, and Jammu and Kashmir from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Gujarat', 'Telangana', 'Jammu and Kashmir'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Gujarat vs Telangana vs Jammu and Kashmir', width=550, height=320) return chart " 4324,"Which union territory with a land area greater than 1,000 km² shows the lowest PM2.5 level, based on its average PM2.5 level?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}] " 4325,"Create a bubble chart of PM2.5 vs area for each state in 2023, sized by population."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): pm = data[data['Timestamp'].dt.year == 2023].groupby('state')['PM2.5'].mean().reset_index().dropna() df = pm.merge(states_data, on='state') chart = alt.Chart(df).mark_point(filled=True, opacity=0.7).encode( x=alt.X('area (km2):Q', title='Area (km²)', axis=alt.Axis(format='~s')), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), size=alt.Size('population:Q', title='Population', scale=alt.Scale(range=[50,1500])), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('population:Q', format=','), alt.Tooltip('area (km2):Q', format=',')] ).properties(title='PM2.5 vs Area (size=Population) – 2023', width=500, height=400) return chart " 4326,List the bottom 15 states with the lowest average PM10 in 2020 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 4327,Tabulate mean PM2.5 and PM10 along with station coverage per state in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}, {'alias': 'Station Count', 'col': 'station', 'fn': 'nunique'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4328,Create a table of state PM2.5 levels and geographic area for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4329,Which city registered the 2nd minimum average PM10 during the Summer season of 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 4330,"During 2024, which weekday saw the third-highest median PM10 pollution levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'Timestamp'}}] " 4331,Show a cumulative area chart of PM2.5 readings for Katni across 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Katni') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Katni 2022', width=600, height=300) return chart " 4332,Report the total land area of the union territory showing the 3rd maximum combined PM2.5 and PM10 concentrations.," [{'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'combined', 'ascending': False}}] " 4333,Show a heatmap of average PM2.5 for the top 7 most polluted states by month for 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(7).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 7 Polluted States by Month (2022)', width=500, height=300) return chart " 4334,Create a month-wise summary of average PM2.5 for Puducherry in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Puducherry'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4335,Which state registered the 2nd lowest 25th percentile of PM2.5 during January 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 4336,Show a heatmap of average PM2.5 for the top 13 most polluted states by month for 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(13).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 13 Polluted States by Month (2022)', width=500, height=300) return chart " 4337,"Across all recorded years, which May showed the second-lowest average PM2.5 concentration?"," [{'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'Timestamp'}}] " 4338,Tabulate the 5 worst states for average PM2.5 in 2020 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 4339,"Create a grouped bar chart comparing the average PM2.5 for Sikkim, Gujarat, and Himachal Pradesh across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Sikkim', 'Gujarat', 'Himachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 4340,"Show a table of average PM10, population, and area for all states in 2024."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4341,Identify the city that registered the second highest stable PM2.5 level.," [{'op': 'AGG', 'params': {'by': 'city', 'fn': 'std', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 4342,Which city was second in terms of highest average PM10 for January 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 4343,Tabulate the yearly average PM10 trend for Mizoram across all years.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Mizoram'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4344,Tabulate average PM2.5 for each state across all months in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Bihar', 'Delhi', 'Gujarat', 'Haryana', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Odisha', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4345,"For the period October to December 2020, which city had the second smallest decrease in 25th percentile PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 4346,"Show mean, median, minimum, and maximum PM2.5 for each city in 2019 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'q25', 'median', 'q75']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4347,"Plot the yearly average PM2.5 trends for Assam, Nagaland, and Manipur from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Assam', 'Nagaland', 'Manipur'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Assam vs Nagaland vs Manipur', width=550, height=320) return chart " 4348,Show a box plot of PM2.5 distribution for each state in 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2022].dropna(subset=['PM2.5']) df = df[['state','PM2.5']] state_order = df.groupby('state')['PM2.5'].median().sort_values(ascending=False).index.tolist() chart = alt.Chart(df).mark_boxplot(extent='min-max').encode( x=alt.X('PM2\.5:Q', title='PM2.5 (µg/m³)'), y=alt.Y('state:N', sort=state_order, title='State'), color=alt.Color('state:N', legend=None) ).properties(title='PM2.5 Distribution by State – 2022', width=500, height=450) return chart " 4349,Show the monthly average PM10 trend for Dholpur from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Dholpur'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Dholpur (2019–2024)', width=600, height=300) return chart " 4350,Report which state possessed the third highest average PM2.5 throughout the Monsoon season of 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 4351,"Plot the yearly average PM2.5 trends for Himachal Pradesh, Tamil Nadu, and Andhra Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Himachal Pradesh', 'Tamil Nadu', 'Andhra Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Himachal Pradesh vs Tamil Nadu vs Andhra Pradesh', width=550, height=320) return chart " 4352,Identify the city that recorded the 3rd lowest 25th percentile of PM10 value in November 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 4353,"Scatter plot PM2.5 vs PM10 for Uttar Pradesh stations in 2017, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Uttar Pradesh') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Uttar Pradesh Stations 2017', width=450, height=350) " 4354,"Compare the monthly average PM2.5 of Alwar, Chandigarh, and Agra in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Alwar', 'Chandigarh', 'Agra'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Alwar vs Chandigarh vs Agra – 2018', width=550, height=320) return chart " 4355,Create a month-wise PM10 breakdown table across cities in Odisha for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Odisha'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Brajrajnagar', 'Talcher']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4356,Create a table of PM2.5 standard violations (>60 µg/m³) per city in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4357,Show a heatmap of average PM2.5 for the top 12 most polluted states by month for 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(12).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 12 Polluted States by Month (2021)', width=500, height=300) return chart " 4358,"Across all recorded years, which September was associated with the third-highest 75th percentile of PM10 levels?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'Timestamp'}}] " 4359,"Visualize the monthly average PM10 for Jammu and Kashmir, Jharkhand, and Manipur in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jammu and Kashmir', 'Jharkhand', 'Manipur'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Jammu and Kashmir, Jharkhand, UP – 2019', width=550, height=320) return chart " 4360,Show a table of the 20 cleanest citys by average PM10 in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 4361,Determine the city exhibiting the 2nd lowest 75th percentile of PM10 in September 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 4362,Report the state that had the lowest 25th percentile of PM10 in June 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 4363,Show a cumulative area chart of PM2.5 readings for Kolkata across 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Kolkata') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Kolkata 2023', width=600, height=300) return chart " 4364,Create a month-wise PM10 breakdown table across cities in Andhra Pradesh for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Tirupati']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4365,Which union territory in India has the lowest count of monitoring stations when considering its population?," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'nunique', 'col': 'station'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'COMPUTE', 'params': {'new_col': 'stations_per_million', 'numerator': 'station', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'stations_per_million', 'ascending': True}}] " 4366,Report the state with the 3rd lowest average PM2.5 in November 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 4367,Create a month-wise PM10 breakdown table across cities in Tamil Nadu for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Chennai', 'Coimbatore', 'Gummidipoondi', 'Thoothukudi']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4368,"On March 31, 2018, which state had the third-lowest 25th percentile for PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 4369,Which state registered the highest 75th percentile of PM10 during March 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 4370,Show the monthly average PM2.5 for Sonipat in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Sonipat') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Sonipat 2018', width=450, height=280) " 4371,"Compare the monthly average PM2.5 of Badlapur, Ooty, and Ajmer in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Badlapur', 'Ooty', 'Ajmer'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Badlapur vs Ooty vs Ajmer – 2022', width=550, height=320) return chart " 4372,"Create a grouped bar chart comparing the average PM2.5 for Haryana, Gujarat, and Karnataka across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Gujarat', 'Karnataka'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 4373,List the top 10 states by average PM2.5 in 2020 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 4374,Show the monthly average PM10 trend for Gangtok from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Gangtok'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Gangtok (2017–2022)', width=600, height=300) return chart " 4375,"Identify the city with the second-lowest 25th percentile for PM10 on March 31, 2019."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 4376,List how many days each state breached the PM2.5 limit of 60 µg/m³ in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4377,Generate a city × month cross-tab of mean PM10 for Odisha in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Odisha'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Brajrajnagar', 'Talcher']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4378,"Plot the yearly average PM2.5 trends for Puducherry, Jharkhand, and Andhra Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'Jharkhand', 'Andhra Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Puducherry vs Jharkhand vs Andhra Pradesh', width=550, height=320) return chart " 4379,"Considering 2018, which day of the week had the third-highest average PM10 pollution levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'Timestamp'}}] " 4380,Report the state that had the 3rd lowest median PM10 in October 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 4381,Generate a city × month cross-tab of mean PM10 for Maharashtra in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Aurangabad', 'Chandrapur', 'Kalyan', 'Mumbai', 'Nagpur', 'Nashik', 'Navi Mumbai', 'Pune', 'Solapur', 'Thane']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4382,"Plot the yearly average PM2.5 trends for West Bengal, Jammu and Kashmir, and Odisha from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['West Bengal', 'Jammu and Kashmir', 'Odisha'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: West Bengal vs Jammu and Kashmir vs Odisha', width=550, height=320) return chart " 4383,Determine which city was granted the 2nd lowest NCAP funding considering its 75th percentile of PM10 concentration in 2020 (FY 2019-20).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2020_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 4384,Identify the city with the 3rd highest median PM2.5 for February 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 4385,Which state had the highest average PM10 in June 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 4386,Plot the top 10 states by average PM2.5 in 2017 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2017] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(10, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 10 States by Average PM2.5 in 2017', width=500, height=300) return chart " 4387,"Create a grouped bar chart comparing the average PM2.5 for Madhya Pradesh, Meghalaya, and Mizoram across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Madhya Pradesh', 'Meghalaya', 'Mizoram'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 4388,Create a month-wise summary of average PM10 for Meerut in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Meerut'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4389,Tabulate mean PM10 alongside state population figures for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4390,"Tabulate PM2.5 levels, population, and land area per state in 2018."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': { 'map': { 'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4391,Create a month-wise PM2.5 breakdown table across cities in Haryana for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Haryana'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Ambala', 'Bahadurgarh', 'Ballabgarh', 'Bhiwani', 'Charkhi Dadri', 'Dharuhera', 'Faridabad', 'Fatehabad', 'Gurugram', 'Hisar', 'Jind', 'Kaithal', 'Karnal', 'Kurukshetra ', 'Mandikhera', 'Manesar', 'Narnaul', 'Palwal ', 'Panchkula', 'Panipat', 'Rohtak', 'Sirsa', 'Sonipat', 'Yamuna Nagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4392,Show the number of days each city exceeded a PM2.5 threshold of 60 µg/m³ in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4393,List average PM10 by month for Meghalaya in 2020 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Meghalaya'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4394,Report the city with the 3rd lowest median PM2.5 in November 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 4395,Show PM2.5 exceedances above the Indian standard (60 µg/m³) per year as a bar chart for Chhattisgarh.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Chhattisgarh'].dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 60].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby('Year')['Timestamp'].nunique().reset_index() df.columns = ['Year','Days Exceeded'] chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('Year:N', title='Year'), y=alt.Y('Days Exceeded:Q', title='Days PM2.5 > 60 µg/m³'), tooltip=['Year:N','Days Exceeded:Q'] ).properties(title='Days Chhattisgarh Exceeded Indian PM2.5 Standard (60 µg/m³) per Year', width=450, height=300) return chart " 4396,Create a state × year breakdown table of mean PM2.5 from 2017 to 2024.," [ { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Bihar', 'Delhi', 'Gujarat', 'Haryana', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Odisha', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Uttar Pradesh']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'year', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4397,Show a heatmap of average PM2.5 for the top 8 most polluted states by month for 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(8).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 8 Polluted States by Month (2024)', width=500, height=300) return chart " 4398,"On January 14, 2023, which city experienced the highest PM10 values?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 4399,Tabulate the yearly average PM2.5 trend for Thiruvananthapuram across all years.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Thiruvananthapuram'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4400,Show a monthly bar chart of the number of days Telangana exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Telangana') & (data['Timestamp'].dt.year == 2024)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Telangana Exceeded WHO PM2.5 Guideline per Month – 2024', width=500, height=300) return chart " 4401,"In August 2022, report the station with the 3rd highest 25th percentile of PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 4402,Which state registered the 3rd highest 75th percentile of PM10 during June 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 4403,Tabulate daily PM2.5 exceedances (above 60 µg/m³) per city for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4404,List average PM2.5 by month for Gaya in 2021 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Gaya'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4405,Plot the weekly average PM2.5 for Jalgaon in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Jalgaon') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Jalgaon 2023', width=600, height=300) return chart " 4406,"Compare the monthly average PM2.5 of Udaipur, Chamarajanagar, and Sirsa in 2020 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Udaipur', 'Chamarajanagar', 'Sirsa'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2020)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Udaipur vs Chamarajanagar vs Sirsa – 2020', width=550, height=320) return chart " 4407,Create a table of PM2.5 standard violations (>100 µg/m³) per city in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4408,Create a table of PM2.5 standard violations (>100 µg/m³) per city in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4409,"Compare the monthly average PM2.5 of Jodhpur, Firozabad, and Narnaul in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Jodhpur', 'Firozabad', 'Narnaul'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Jodhpur vs Firozabad vs Narnaul – 2024', width=550, height=320) return chart " 4410,Show the monthly average PM2.5 for Amaravati in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Amaravati') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Amaravati 2017', width=450, height=280) " 4411,Which 15 states had the lowest mean PM2.5 in 2020? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 4412,List the bottom 15 states with the lowest average PM2.5 in 2021 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 4413,"Visualize the monthly average PM10 for Haryana, Chandigarh, and Delhi in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Chandigarh', 'Delhi'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Haryana, Chandigarh, UP – 2017', width=550, height=320) return chart " 4414,Show a cumulative area chart of PM2.5 readings for Singrauli across 2019.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Singrauli') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Singrauli 2019', width=600, height=300) return chart " 4415,"Compare the monthly average PM2.5 of Boisar, Surat, and Durgapur in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Boisar', 'Surat', 'Durgapur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Boisar vs Surat vs Durgapur – 2022', width=550, height=320) return chart " 4416,List the top 20 states by average PM2.5 in 2021 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 4417,Determine which city got the lowest NCAP funding with respect to its median PM2.5 concentration in 2021 (FY 2020-21).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 4418,Create a table of PM10 exceedance frequency above 100 µg/m³ by city for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4419,Show a monthly bar chart of the number of days Rajasthan exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2020.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Rajasthan') & (data['Timestamp'].dt.year == 2020)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Rajasthan Exceeded WHO PM2.5 Guideline per Month – 2020', width=500, height=300) return chart " 4420,Determine the city exhibiting the 2nd most minimal 25th percentile of PM10 over the Monsoon season of 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 4421,Show a table of the 15 cleanest citys by average PM10 in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 4422,Identify the city that saw the third least significant fall in median PM10 levels when comparing December 2024 to October 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 4423,"Plot the yearly average PM2.5 trends for Meghalaya, Mizoram, and Meghalaya from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Meghalaya', 'Mizoram', 'Meghalaya'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Meghalaya vs Mizoram vs Meghalaya', width=550, height=320) return chart " 4424,"Which state (excluding Union Territories) possesses the smallest land area among the top 3 most polluted states, based on the 75th percentile of PM2.5 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 3, 'ret': 'state'}}] " 4425,Show a ranked table of the 15 most polluted states by average PM2.5 in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 4426,Identify the station that recorded the 2nd lowest median PM2.5 value in July 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 4427,"Create a grouped bar chart comparing the average PM2.5 for Gujarat, Mizoram, and Nagaland across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Gujarat', 'Mizoram', 'Nagaland'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 4428,Create a month-wise PM2.5 breakdown table across cities in Gujarat for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Gujarat'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Ahmedabad', 'Ankleshwar', 'Gandhinagar', 'Nandesari', 'Vatva']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4429,Report which state experienced the most minimal median PM2.5 throughout the Post-Monsoon season of 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 4430,"Compare the monthly average PM2.5 of Udaipur, Kashipur, and Pali in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Udaipur', 'Kashipur', 'Pali'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Udaipur vs Kashipur vs Pali – 2023', width=550, height=320) return chart " 4431,"Plot the yearly average PM2.5 trends for Odisha, Nagaland, and Delhi from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Odisha', 'Nagaland', 'Delhi'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Odisha vs Nagaland vs Delhi', width=550, height=320) return chart " 4432,Show a monthly bar chart of the number of days Maharashtra exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2020.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Maharashtra') & (data['Timestamp'].dt.year == 2020)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Maharashtra Exceeded WHO PM2.5 Guideline per Month – 2020', width=500, height=300) return chart " 4433,Show the monthly average PM10 trend for Hassan from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Hassan'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Hassan (2017–2022)', width=600, height=300) return chart " 4434,Show the monthly average PM2.5 for Uttarakhand across each year from 2017 to 2024 as small multiples (faceted by year).," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Uttarakhand'].copy() df['Year'] = df['Timestamp'].dt.year df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5'), tooltip=['Year:O','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet( facet=alt.Facet('Year:O', title='Year'), columns=4 ).properties(title='Monthly PM2.5 in Uttarakhand by Year (2017–2024)') return chart " 4435,"Tabulate PM2.5 statistics (mean, std, min, max) for each state in 2022."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4436,List the bottom 10 citys with the lowest average PM10 in 2022 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 4437,Which station registered the highest median PM10 during September 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 4438,How many times did Meghalaya exceed 75 µg/m³ of PM2.5 in the year 2017?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 75.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 4439,"Scatter plot PM2.5 vs PM10 for Uttarakhand stations in 2021, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Uttarakhand') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Uttarakhand Stations 2021', width=450, height=350) " 4440,Create a table of PM2.5 exceedance frequency above 100 µg/m³ by city for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4441,List how many days each city breached the PM2.5 limit of 100 µg/m³ in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4442,Report the state with the 3rd highest 75th percentile of PM2.5 in September 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 4443,Plot the weekly average PM2.5 for Guwahati in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Guwahati') & (data['Timestamp'].dt.year == 2020)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Guwahati 2020', width=600, height=300) return chart " 4444,Tabulate the yearly average PM2.5 trend for Lucknow across all years.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Lucknow'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4445,Report the state with the lowest median PM2.5 in September 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 4446,Create a summary table comparing mean PM2.5 and PM10 across states in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4447,"Visualize the monthly average PM10 for Sikkim, Kerala, and Gujarat in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Sikkim', 'Kerala', 'Gujarat'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Sikkim, Kerala, UP – 2023', width=550, height=320) return chart " 4448,What is the mean PM10 value on Thursdays in Tripura?," [{'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tripura'}}] " 4449,"Create a grouped bar chart comparing the average PM2.5 for Odisha, Rajasthan, and West Bengal across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Odisha', 'Rajasthan', 'West Bengal'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 4450,Plot the yearly average PM2.5 for the top 12 most polluted states from 2017 to 2024 as a multi-line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top5 = data.groupby('state')['PM2.5'].mean().nlargest(12).index.tolist() df = data[data['state'].isin(top5)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends – Top 12 Most Polluted States', width=600, height=350) return chart " 4451,Create a month-by-state breakdown table of mean PM2.5 for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Bihar', 'Delhi', 'Gujarat', 'Haryana', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Odisha', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4452,"In February 2019, identify the state with the 2nd lowest 25th percentile of PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 4453,Create a month-wise summary of average PM2.5 for Muzaffarpur in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Muzaffarpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4454,List states with their average PM2.5 and area for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4455,Tabulate average PM2.5 for each state across all months in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Delhi', 'Gujarat', 'Haryana', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4456,"On March 31, 2023, which state recorded the third-highest average PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 4457,Which station recorded the 3rd highest median PM10 in January 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 4458,Identify the city that recorded the absolute highest PM2.5 levels during the April 2020 COVID-19 lockdown.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 4459,Which station noted the 2nd maximum 75th percentile of PM2.5 during the Monsoon season of 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 4460,List average PM2.5 by month for Chandigarh in 2019 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Chandigarh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4461,"Which state (excluding UTs) possesses the 3rd smallest population among the top 3 most polluted states, determined by total PM2.5 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'sum', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 3, 'ret': 'state'}}] " 4462,Identify the city exhibiting the peak average PM2.5 during the Post-Monsoon season of 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 4463,Determine the station with the highest 75th percentile of PM10 in December 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 4464,Determine the city showing the second highest PM2.5 level on 27 January 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 4465,How many times did Raichur city go above the WHO guideline for PM10 in 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 15.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 4466,Find the state with the third-most minimal 25th percentile of PM2.5 in July 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 4467,Create a month-wise PM2.5 breakdown table across cities in Andhra Pradesh for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Amaravati', 'Anantapur', 'Chittoor', 'Kadapa', 'Rajamahendravaram', 'Tirupati', 'Vijayawada', 'Visakhapatnam']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4468,Show a cumulative area chart of PM2.5 readings for Maihar across 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Maihar') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Maihar 2021', width=600, height=300) return chart " 4469,List the bottom 10 states with the lowest average PM10 in 2019 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 4470,List citys with their PM2.5 violation count and rate (>60 µg/m³) in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4471,Tabulate the 15 worst citys for average PM2.5 in 2020 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 4472,List citys with their PM10 violation count and rate (>100 µg/m³) in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4473,Tabulate average PM2.5 for each city in Andhra Pradesh across all months of 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Amaravati', 'Rajamahendravaram', 'Tirupati', 'Visakhapatnam']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4474,Tabulate daily PM2.5 exceedances (above 100 µg/m³) per state for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4475,Show the monthly average PM2.5 for Palwal in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Palwal ') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Palwal 2017', width=450, height=280) " 4476,Identify the city with the 3rd highest 75th percentile of PM10 in December 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 4477,Show a cumulative area chart of PM2.5 readings for Damoh across 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Damoh') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Damoh 2024', width=600, height=300) return chart " 4478,Show annual average PM10 for Haryana as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Haryana'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4479,Generate a table showing the 20 most polluted states based on mean PM10 for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 4480,"Create a grouped bar chart comparing the average PM2.5 for Odisha, West Bengal, and Haryana across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Odisha', 'West Bengal', 'Haryana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 4481,Create a month-wise summary of average PM2.5 for Lucknow in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Lucknow'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4482,Visualize the bottom 11 states with the lowest average PM2.5 in 2017 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2017] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(11, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 11 States by Average PM2.5 in 2017', width=500, height=300) return chart " 4483,Show NCAP funding breakdown by fiscal year for each state as a table.," [ {'op': 'SOURCE', 'params': {'table': 'ncap'}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ { 'alias': 'FY 2019-20 (Cr)', 'col': 'Amount released during FY 2019-20', 'fn': 'sum'}, { 'alias': 'FY 2020-21 (Cr)', 'col': 'Amount released during FY 2020-21', 'fn': 'sum'}, { 'alias': 'FY 2021-22 (Cr)', 'col': 'Amount released during FY 2021-22', 'fn': 'sum'}, {'alias': 'Total (Cr)', 'col': 'Total fund released', 'fn': 'sum'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Total (Cr)'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4484,"Create a grouped bar chart comparing the average PM2.5 for Andhra Pradesh, Gujarat, and Jammu and Kashmir across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Gujarat', 'Jammu and Kashmir'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 4485,"Create a grouped bar chart comparing the average PM2.5 for Delhi, Rajasthan, and Tripura across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Delhi', 'Rajasthan', 'Tripura'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 4486,"Compare the monthly average PM2.5 of Thrissur, Karur, and Thane in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Thrissur', 'Karur', 'Thane'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Thrissur vs Karur vs Thane – 2018', width=550, height=320) return chart " 4487,Report which city possessed the 2nd highest 25th percentile of PM10 throughout the Monsoon season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 4488,Identify the city that recorded the lowest median PM10 value in September 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 4489,How many times did Siliguri city go above the Indian guideline for PM2.5 in 2017?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 60.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 4490,Plot the weekly average PM2.5 for Jalandhar in 2018 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Jalandhar') & (data['Timestamp'].dt.year == 2018)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Jalandhar 2018', width=600, height=300) return chart " 4491,"In 2021, which season (Winter, Summer, Monsoon, Post-Monsoon) was associated with the minimum 25th percentile of PM10 concentrations?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'season'}}] " 4492,"Which city showed the third-lowest 25th percentile for PM10 on March 31, 2024?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 4493,Create a summary table ranking the top 20 states by PM10 concentration in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 4494,"Show the variability of PM10 across citys in 2023 using mean, median, and standard deviation."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4495,Plot the weekly average PM2.5 for Sonipat in 2021 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Sonipat') & (data['Timestamp'].dt.year == 2021)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Sonipat 2021', width=600, height=300) return chart " 4496,Determine the state with the 3rd lowest 25th percentile of PM2.5 in September 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 4497,Which city got the 5th highest NCAP funding considering its median PM2.5 concentration in 2021 (FY 2020-21)?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 4498,Tabulate average PM2.5 for each city in Madhya Pradesh across all months of 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Bhopal', 'Damoh', 'Gwalior', 'Indore', 'Jabalpur', 'Katni', 'Mandideep', 'Pithampur', 'Ratlam', 'Sagar', 'Satna', 'Singrauli', 'Ujjain']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4499,"Compare the monthly average PM2.5 of Pithampur, Virudhunagar, and Meerut in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Pithampur', 'Virudhunagar', 'Meerut'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Pithampur vs Virudhunagar vs Meerut – 2018', width=550, height=320) return chart " 4500,Which state recorded the lowest median PM2.5 figure in April 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 4501,Show a bar chart of the top 10 cities by median PM2.5 in 2017.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2017] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(10, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 10 Cities by Median PM2.5 in 2017', width=500, height=300) return chart " 4502,"Which city showed the second-highest average PM10 on March 31, 2020?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 4503,Show a cumulative area chart of PM2.5 readings for Nandesari across 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Nandesari') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Nandesari 2022', width=600, height=300) return chart " 4504,Report the state that had the 2nd lowest median PM10 in November 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 4505,Show how average PM2.5 varied month by month for Rajasthan in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4506,Which station had the 2nd lowest average PM10 in March 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 4507,Identify the state with the lowest 75th percentile for PM10 in August 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 4508,Show the monthly average PM2.5 for Ahmednagar in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ahmednagar') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Ahmednagar 2017', width=450, height=280) " 4509,"For 2021, identify the season (Winter, Summer, Monsoon, Post-Monsoon) with the second-lowest median PM10 levels."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'season'}}] " 4510,Plot the distribution of PM2.5 values in Tamil Nadu across all years using a histogram.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Tamil Nadu'].dropna(subset=['PM2.5']) df = df[['PM2.5']] chart = alt.Chart(df).mark_bar(color='steelblue', opacity=0.75).encode( x=alt.X('PM2\.5:Q', bin=alt.Bin(maxbins=40), title='PM2.5 (µg/m³)'), y=alt.Y('count()', title='Number of Observations'), tooltip=[alt.Tooltip('PM2\.5:Q', bin=True), 'count()'] ).properties(title='PM2.5 Distribution – Tamil Nadu (All Years)', width=500, height=300) return chart " 4511,Create a month-wise summary of average PM2.5 for Durgapur in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Durgapur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4512,Plot the rolling 30-day average PM2.5 for Chandigarh in 2017 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Chandigarh') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Chandigarh 2017', width=600, height=300) " 4513,Plot the weekly average PM2.5 for Nagapattinam in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Nagapattinam') & (data['Timestamp'].dt.year == 2024)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Nagapattinam 2024', width=600, height=300) return chart " 4514,Which state noted the 2nd minimum 25th percentile of PM10 during the Summer season of 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 4515,Create a month-wise summary of average PM2.5 for Bengaluru in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Bengaluru'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4516,"Which union territory with a land area greater than 1,000 km² shows the 2nd highest PM2.5 level, based on its standard deviation of PM2.5 level?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'std', 'col': 'PM2.5'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}] " 4517,Create a table of PM10 exceedance frequency above 150 µg/m³ by city for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 150'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4518,"Create a grouped bar chart comparing the average PM2.5 for Puducherry, Mizoram, and Tripura across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'Mizoram', 'Tripura'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 4519,Show a monthly breakdown table of average PM10 for Haryana in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Haryana'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4520,Tabulate the monthly mean PM2.5 levels for Maharashtra during 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4521,"Create a grouped bar chart comparing the average PM2.5 for Mizoram, Nagaland, and Uttar Pradesh across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Mizoram', 'Nagaland', 'Uttar Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 4522,Identify the station that recorded the third highest 25th percentile of PM10 during the Post-Monsoon season of 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 4523,Show a monthly breakdown table of average PM10 for Jaipur in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Jaipur'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4524,List the top 5 states by average PM10 in 2020 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 4525,List average PM10 by month for Delhi in 2023 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Delhi'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4526,Which station registered the 2nd lowest median PM2.5 during October 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 4527,"Create a grouped bar chart comparing the average PM2.5 for West Bengal, Karnataka, and Jharkhand across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['West Bengal', 'Karnataka', 'Jharkhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 4528,Show how average PM10 varied month by month for Kerala in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4529,Show the monthly average PM2.5 for Nagapattinam in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Nagapattinam') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Nagapattinam 2020', width=450, height=280) " 4530,Which city with NCAP funding shows the 3rd lowest PM10 concentration?," [{'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}] " 4531,Show the monthly average PM2.5 for Asansol in 2024 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Asansol') & (data['Timestamp'].dt.year == 2024)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Asansol 2024', width=450, height=280) " 4532,Show the monthly average PM2.5 for Thanjavur in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Thanjavur') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Thanjavur 2018', width=450, height=280) " 4533,Which station possessed the 2nd lowest 25th percentile for PM2.5 in the Post-Monsoon season of 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 4534,"Create a grouped bar chart comparing the average PM2.5 for Tamil Nadu, Jharkhand, and Sikkim across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Jharkhand', 'Sikkim'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 4535,Create a summary table ranking the top 20 states by PM2.5 concentration in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 4536,Show a year-wise table of average PM10 for Kolkata from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Kolkata'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4537,Show annual average PM2.5 for Gaya as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Gaya'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4538,Plot the rolling 30-day average PM2.5 for Himachal Pradesh in 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Himachal Pradesh') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Himachal Pradesh 2022', width=600, height=300) " 4539,Create a month-wise summary of average PM10 for Tamil Nadu in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4540,Show the monthly average PM2.5 for Hanumangarh in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Hanumangarh') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Hanumangarh 2020', width=450, height=280) " 4541,Plot a heatmap of average PM10 by state (y-axis) and month (x-axis) for 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2023].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM10'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), title='Avg PM10'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='PM10 Heatmap by State and Month – 2023', width=500, height=400) return chart " 4542,"In June 2019, identify the city with the 3rd highest 75th percentile of PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 4543,Which station recorded the minimum 25th percentile for PM2.5 in November 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 4544,Tabulate the yearly average PM2.5 trend for Agra across all years.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Agra'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4545,Which state registered the 3rd maximum 25th percentile of PM2.5 in the Winter season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 4546,"Create a grouped bar chart comparing the average PM2.5 for Haryana, Maharashtra, and Manipur across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Maharashtra', 'Manipur'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 4547,Create a table showing PM10 spread (min to max) and central tendency per city for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4548,Plot the top 8 states by average PM2.5 in 2019 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2019] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(8, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 8 States by Average PM2.5 in 2019', width=500, height=300) return chart " 4549,Find the city with the highest median PM10 value in March 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 4550,Plot the rolling 30-day average PM2.5 for Tamil Nadu in 2019 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Tamil Nadu') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Tamil Nadu 2019', width=600, height=300) " 4551,Show a year-wise table of average PM10 for Hyderabad from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Hyderabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4552,"Tabulate PM2.5 statistics (mean, std, min, max) for each city in 2021."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4553,Show a monthly breakdown table of average PM2.5 for Gujarat in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Gujarat'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4554,How many times did Sikkim surpass 30 µg/m³ of PM2.5 in 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 30.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 4555,Report which station possessed the third lowest 75th percentile of PM2.5 throughout the Summer season of 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 4556,Show a monthly bar chart of the number of days Manipur exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Manipur') & (data['Timestamp'].dt.year == 2023)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Manipur Exceeded WHO PM2.5 Guideline per Month – 2023', width=500, height=300) return chart " 4557,List all citys with their average PM2.5 and PM10 levels in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4558,"Compare the monthly average PM2.5 of Khurja, Tensa, and Rajamahendravaram in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Khurja', 'Tensa', 'Rajamahendravaram'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Khurja vs Tensa vs Rajamahendravaram – 2022', width=550, height=320) return chart " 4559,"Create a grouped bar chart comparing the average PM2.5 for Himachal Pradesh, Tripura, and Odisha across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Himachal Pradesh', 'Tripura', 'Odisha'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 4560,Tabulate the top 15 citys for PM2.5 in 2021 along with their corresponding PM10 values.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 4561,"Create a grouped bar chart comparing the average PM2.5 for Chandigarh, Bihar, and Rajasthan across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chandigarh', 'Bihar', 'Rajasthan'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 4562,Which station registered the 2nd highest average PM2.5 during July 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 4563,Tabulate the 10 citys with the least PM2.5 pollution in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 4564,List the top 20 states by average PM10 in 2022 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 4565,"Which station showed the second-highest median PM10 on March 31, 2023?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 4566,Show how average PM10 varied month by month for Tripura in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tripura'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4567,Show a table of average PM2.5 per state in 2023 along with population.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4568,Create a grouped bar chart comparing the average PM2.5 in Winter vs Summer for the top 8 most polluted states.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top6 = data.groupby('state')['PM2.5'].mean().nlargest(8).index.tolist() df = data[data['state'].isin(top6)].copy() df['Season'] = df['Timestamp'].dt.month.apply( lambda m: 'Winter' if m in [12,1,2] else ('Summer' if m in [3,4,5] else None)) df = df.dropna(subset=['Season']) df = df.groupby(['state','Season'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('state:N', title='State'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('Season:N', title='Season'), xOffset='Season:N', tooltip=['state:N','Season:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Winter vs Summer PM2.5 – Top 8 Polluted States', width=550, height=320) return chart " 4569,"Create a grouped bar chart comparing the average PM2.5 for Nagaland, West Bengal, and Manipur across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Nagaland', 'West Bengal', 'Manipur'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 4570,"Show descriptive statistics of PM2.5 (mean, median, std, min, max) per state in 2024."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'q25', 'median', 'q75']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4571,"Considering all years, which September was associated with the third-lowest average PM2.5 levels?"," [{'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'Timestamp'}}] " 4572,How many times did Kerala exceed 45 µg/m³ of PM2.5 in 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 45.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 4573,"Plot the yearly average PM2.5 trends for Chhattisgarh, Andhra Pradesh, and Uttar Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chhattisgarh', 'Andhra Pradesh', 'Uttar Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Chhattisgarh vs Andhra Pradesh vs Uttar Pradesh', width=550, height=320) return chart " 4574,"Compare the monthly average PM2.5 of Chhal, Kalaburagi, and Muzaffarpur in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Chhal', 'Kalaburagi', 'Muzaffarpur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Chhal vs Kalaburagi vs Muzaffarpur – 2023', width=550, height=320) return chart " 4575,Generate a monthly average PM10 table for Indore for the year 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Indore'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4576,Tabulate the 10 worst states for average PM10 in 2019 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 4577,Create a month-wise PM10 breakdown table across cities in Karnataka for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Bengaluru', 'Chikkaballapur', 'Hubballi', 'Kalaburagi', 'Kolar']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4578,Plot the rolling 30-day average PM2.5 for Chhattisgarh in 2018 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Chhattisgarh') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Chhattisgarh 2018', width=600, height=300) " 4579,"Compare the monthly average PM2.5 of Ooty, Samastipur, and Indore in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Ooty', 'Samastipur', 'Indore'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Ooty vs Samastipur vs Indore – 2024', width=550, height=320) return chart " 4580,Determine the city that ranks third for the highest median PM2.5 in July 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 4581,Generate a city × month cross-tab of mean PM2.5 for Tamil Nadu in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Chennai']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4582,"Report the state (excluding UTs) having the 3rd largest population among the top 5 most polluted states, when pollution is measured by variance of PM10 levels."," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'var', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 5, 'ret': 'state'}}] " 4583,Report the station with the 2nd lowest median PM10 in July 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 4584,Identify the city that received the 4th highest NCAP funding relative to its median PM2.5 concentration in 2021 (FY 2020-21).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 4585,Show the number of days each state exceeded a PM10 threshold of 150 µg/m³ in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4586,"Visualize the monthly average PM10 for Kerala, Tripura, and Tripura in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Kerala', 'Tripura', 'Tripura'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Kerala, Tripura, UP – 2019', width=550, height=320) return chart " 4587,"Compare the monthly average PM2.5 of Gangtok, Rohtak, and Hubballi in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Gangtok', 'Rohtak', 'Hubballi'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Gangtok vs Rohtak vs Hubballi – 2018', width=550, height=320) return chart " 4588,Plot the rolling 30-day average PM2.5 for Telangana in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Telangana') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Telangana 2023', width=600, height=300) " 4589,Plot the weekly average PM2.5 for Yamuna Nagar in 2021 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Yamuna Nagar') & (data['Timestamp'].dt.year == 2021)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Yamuna Nagar 2021', width=600, height=300) return chart " 4590,Show annual average PM10 for Himachal Pradesh as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Himachal Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4591,Determine the city exhibiting the 2nd most minimal median PM10 over the Summer season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 4592,Create a table showing PM2.5 spread (min to max) and central tendency per state for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4593,Tabulate the monthly mean PM2.5 levels for Bihar during 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Bihar'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4594,"During 2024, which season (Winter, Summer, Monsoon, Post-Monsoon) saw the third-lowest 75th percentile of PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'season'}}] " 4595,On which date in the past five years did Badlapur record its 2nd peak PM2.5 level?," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 5}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'Timestamp'}}] " 4596,Show the monthly average PM2.5 for Byasanagar in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Byasanagar') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Byasanagar 2020', width=450, height=280) " 4597,Show the monthly average PM2.5 for Baddi in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Baddi') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Baddi 2017', width=450, height=280) " 4598,Report the station that had the highest median PM10 in May 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 4599,Show a pivot table of monthly average PM10 by city for Gujarat in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Gujarat'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Ahmedabad', 'Ankleshwar', 'Gandhinagar', 'Nandesari', 'Vapi', 'Vatva']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4600,Show a monthly breakdown table of average PM2.5 for Kerala in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4601,Tabulate the monthly mean PM10 levels for Bengaluru during 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Bengaluru'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4602,Show a year-wise table of average PM2.5 for Mumbai from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Mumbai'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4603,Show a table of the top 10 citys by average PM2.5 in 2017 including their PM10 levels too.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 4604,List average PM2.5 by month for Kanpur in 2023 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Kanpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4605,"Show mean, median, minimum, and maximum PM10 for each state in 2018 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4606,Tabulate mean PM2.5 alongside state population figures for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4607,Which state had the lowest 25th percentile of PM10 in January 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 4608,"Create a grouped bar chart comparing the average PM2.5 for Tripura, Sikkim, and Jammu and Kashmir across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tripura', 'Sikkim', 'Jammu and Kashmir'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 4609,List the average PM10 for Meerut broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Meerut'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4610,"Plot the yearly average PM2.5 trends for Chhattisgarh, Maharashtra, and Arunachal Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chhattisgarh', 'Maharashtra', 'Arunachal Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Chhattisgarh vs Maharashtra vs Arunachal Pradesh', width=550, height=320) return chart " 4611,"Compare the monthly average PM2.5 of Kolkata, Baghpat, and Nanded in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Kolkata', 'Baghpat', 'Nanded'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Kolkata vs Baghpat vs Nanded – 2019', width=550, height=320) return chart " 4612,"Create a faceted bar chart showing top 9 states by average PM2.5 per year for 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year.isin([2017,2018,2019,2020])].copy() df['Year'] = df['Timestamp'].dt.year agg = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() top = agg.groupby('Year').apply(lambda x: x.nlargest(9,'PM2.5')).reset_index(drop=True) chart = alt.Chart(top).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Avg PM2.5'), y=alt.Y('state:N', sort='-x'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet(facet='Year:O', columns=2).properties(title='Top 9 States by PM2.5 per Year') return chart " 4613,"Compare the monthly average PM2.5 of Thane, Kolar, and Hajipur in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Thane', 'Kolar', 'Hajipur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Thane vs Kolar vs Hajipur – 2018', width=550, height=320) return chart " 4614,Tabulate mean PM10 alongside state population figures for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4615,Create a month-wise summary of average PM2.5 for Delhi in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Delhi'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4616,Show the monthly average PM2.5 for Anantapur in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Anantapur') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Anantapur 2018', width=450, height=280) " 4617,Report the station that had the 3rd lowest 25th percentile of PM2.5 in April 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 4618,Plot the top 8 states by average PM2.5 in 2022 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2022] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(8, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 8 States by Average PM2.5 in 2022', width=500, height=300) return chart " 4619,Create a month-wise PM2.5 breakdown table across cities in Uttar Pradesh for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Agra', 'Ghaziabad', 'Kanpur', 'Lucknow', 'Moradabad', 'Noida', 'Varanasi']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4620,Plot the monthly average PM2.5 trend for Delhi from 2017 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Delhi'].copy() df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly Average PM2.5 Trend – Delhi (2017–2024)', width=600, height=300) return chart " 4621,"Plot average PM2.5 (2020) vs state population as a scatter plot, labeling each point with the state name."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): pm = data[data['Timestamp'].dt.year == 2020].groupby('state')['PM2.5'].mean().reset_index().dropna() df = pm.merge(states_data, on='state') points = alt.Chart(df).mark_point(filled=True, size=80).encode( x=alt.X('population:Q', title='Population', axis=alt.Axis(format='~s')), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('population:Q', format=',')] ) labels = alt.Chart(df).mark_text(align='left', dx=5, fontSize=9).encode( x='population:Q', y='PM2\.5:Q', text='state:N' ) return (points + labels).properties(title='PM2.5 vs Population by State – 2020', width=500, height=400) " 4622,Tabulate the 5 citys with the least PM2.5 pollution in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 4623,"On January 27, 2022, which station documented the peak PM2.5 level?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 4624,"For the period October to December 2024, which city had the third smallest decrease in 25th percentile PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 4625,List the bottom 20 citys with the lowest average PM2.5 in 2019 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 4626,List the top 10 states by average PM10 in 2018 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 4627,Show a bar chart comparing the 75th percentile PM2.5 of all states in winter 2019 (November–February).," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.month.isin([11,12,1,2])] df = df[df['Timestamp'].dt.year.isin([2019,2020])] df = df.groupby('state')['PM2.5'].quantile(0.75).reset_index().dropna() df.columns = ['state','PM2.5_p75'] df = df.sort_values('PM2.5_p75', ascending=False) chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5_p75:Q', title='75th Percentile PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5_p75:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5_p75:Q', format='.1f', title='P75 PM2.5')] ).properties(title='75th Percentile PM2.5 by State – Winter 2019', width=500, height=400) return chart " 4628,"In 2022, which weekday was associated with the second-highest median PM10 pollution concentrations?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'Timestamp'}}] " 4629,List the average PM10 for Jammu and Kashmir broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Jammu and Kashmir'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4630,Show a pivot table of monthly average PM2.5 by city for West Bengal in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'West Bengal'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Asansol', 'Howrah', 'Kolkata', 'Siliguri']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4631,"In April 2024, report the state with the highest 75th percentile of PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 4632,Which 15 states recorded the highest average PM2.5 levels in 2017? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 4633,Determine the state that showed the second highest 75th percentile of PM10 over the Monsoon season of 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 4634,"Which state with a land area greater than 50,000 km² shows the 3rd lowest PM2.5 level, according to its average PM2.5 level?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}] " 4635,List how many days each state breached the PM10 limit of 100 µg/m³ in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4636,"Scatter plot PM2.5 vs PM10 for Delhi stations in 2017, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Delhi') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Delhi Stations 2017', width=450, height=350) " 4637,Tabulate average PM2.5 for each city in Kerala across all months of 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Eloor', 'Kollam', 'Thiruvananthapuram', 'Thrissur']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4638,Generate a monthly average PM10 table for Nashik for the year 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Nashik'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4639,Show the monthly average PM2.5 for Tamil Nadu across each year from 2017 to 2024 as small multiples (faceted by year).," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Tamil Nadu'].copy() df['Year'] = df['Timestamp'].dt.year df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5'), tooltip=['Year:O','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet( facet=alt.Facet('Year:O', title='Year'), columns=4 ).properties(title='Monthly PM2.5 in Tamil Nadu by Year (2017–2024)') return chart " 4640,Generate a cross-tab of state vs month for average PM10 in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Delhi', 'Gujarat', 'Haryana', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Meghalaya', 'Odisha', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4641,Which city registered the 2nd highest average PM2.5 during March 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 4642,Which state experienced the second most significant drop in its average PM2.5 levels between October and December 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 4643,Which state showed the 2nd lowest average PM2.5 in June 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 4644,Show a ranked table of the 10 most polluted citys by average PM2.5 in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 4645,Which city recorded the 3rd lowest 25th percentile of PM2.5 in October 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 4646,Generate a table showing the 20 most polluted states based on mean PM10 for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 4647,Show a monthly breakdown table of average PM10 for Jaipur in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Jaipur'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4648,"Which state (excluding Union Territories) exhibits the 2nd lowest PM2.5 concentration per square kilometer, based on the standard deviation of PM2.5 values?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'std', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_km2', 'numerator': 'PM2.5', 'denominator': 'area (km2)'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'pm_per_km2', 'ascending': True}}] " 4649,Determine which state shows the highest standard deviation of PM10 concentration adjusted for population density.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'std', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_capita', 'numerator': 'PM10', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'pm_per_capita', 'ascending': False}}] " 4650,Show the monthly average PM2.5 for Navi Mumbai in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Navi Mumbai') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Navi Mumbai 2019', width=450, height=280) " 4651,"Create a grouped bar chart comparing the average PM2.5 for Chandigarh, Tripura, and Punjab across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chandigarh', 'Tripura', 'Punjab'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 4652,Tabulate mean PM2.5 and land area for each state in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4653,Show the monthly average PM2.5 for Jhunjhunu in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Jhunjhunu') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Jhunjhunu 2017', width=450, height=280) " 4654,"In the year 2021, which weekday recorded the third-lowest average PM2.5 pollution levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'Timestamp'}}] " 4655,Show the monthly average PM10 trend for Kannur from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Kannur'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Kannur (2019–2024)', width=600, height=300) return chart " 4656,Determine the station exhibiting the highest 25th percentile of PM10 in November 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 4657,Show a monthly bar chart of the number of days Maharashtra exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Maharashtra') & (data['Timestamp'].dt.year == 2018)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Maharashtra Exceeded WHO PM2.5 Guideline per Month – 2018', width=500, height=300) return chart " 4658,Tabulate the 10 worst citys for average PM2.5 in 2021 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 4659,Show a monthly breakdown table of average PM2.5 for West Bengal in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'West Bengal'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4660,List average PM2.5 by month for Bhilai in 2023 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Bhilai'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4661,"Which state having a land area less than 50,000 km² registers the 2nd maximum PM10 level, based on its variance of PM10 level?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'var', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}] " 4662,Generate a descriptive stats table for PM2.5 grouped by city in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'q25', 'median', 'q75']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4663,"Plot the yearly average PM2.5 trends for Nagaland, Uttar Pradesh, and Arunachal Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Nagaland', 'Uttar Pradesh', 'Arunachal Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Nagaland vs Uttar Pradesh vs Arunachal Pradesh', width=550, height=320) return chart " 4664,Report the state with the lowest 75th percentile of PM2.5 in February 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 4665,Report the state with the 2nd lowest 25th percentile of PM10 in June 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 4666,Determine the station exhibiting the lowest median PM2.5 in December 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 4667,Report the state that had the highest 75th percentile of PM2.5 in November 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 4668,Generate a monthly average PM2.5 table for Andhra Pradesh for the year 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4669,"In 2022, which week of the year was associated with the second-lowest 75th percentile for PM10 concentrations?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'week'}}] " 4670,Identify the city that received the 2nd lowest NCAP funding with respect to the standard deviation of its PM2.5 concentration in 2022 (FY 2021-22).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'std', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2022_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 4671,"In November 2022, which city exhibited the 3rd highest 75th percentile of PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 4672,Tabulate the 15 worst states for average PM2.5 in 2019 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 4673,Report the city that had the lowest median PM10 in June 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 4674,List citys with their PM2.5 violation count and rate (>60 µg/m³) in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4675,"Create a grouped bar chart comparing the average PM2.5 for Sikkim, Mizoram, and Chhattisgarh across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Sikkim', 'Mizoram', 'Chhattisgarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 4676,"Plot the yearly average PM2.5 trends for Chhattisgarh, Kerala, and Uttar Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chhattisgarh', 'Kerala', 'Uttar Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Chhattisgarh vs Kerala vs Uttar Pradesh', width=550, height=320) return chart " 4677,"Plot the yearly average PM2.5 trends for Andhra Pradesh, Tripura, and Odisha from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Tripura', 'Odisha'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Andhra Pradesh vs Tripura vs Odisha', width=550, height=320) return chart " 4678,Create a summary table comparing mean PM2.5 and PM10 across citys in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4679,Show the monthly average PM10 trend for Ghaziabad from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Ghaziabad'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Ghaziabad (2019–2024)', width=600, height=300) return chart " 4680,Report the city with the 3rd highest average PM2.5 in August 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 4681,Determine the city with the 2nd highest average PM10 in March 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 4682,"Show mean, median, minimum, and maximum PM2.5 for each city in 2023 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4683,"Compare the monthly average PM2.5 of Chandrapur, Kunjemura, and Mahad in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Chandrapur', 'Kunjemura', 'Mahad'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Chandrapur vs Kunjemura vs Mahad – 2024', width=550, height=320) return chart " 4684,Identify the station that recorded the peak average PM10 during the Summer season of 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 4685,"Report which state, from those with populations above the 25th percentile, receives the 3rd lowest per capita NCAP funding."," [{'op': 'COMPUTE', 'params': {'new_col': 'funding_per_capita', 'numerator': 'total_fund', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'funding_per_capita', 'ascending': True}}] " 4686,"In September 2023, identify the state with the 2nd highest average PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 4687,Create a summary table ranking the top 5 citys by PM10 concentration in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 4688,Identify the station with the 3rd lowest average PM10 in August 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 4689,"In 2019, which state will rank with the second largest reduction in average PM10 levels from October to December?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 4690,"Compare the monthly average PM2.5 of Patna, Chamarajanagar, and Kashipur in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Patna', 'Chamarajanagar', 'Kashipur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Patna vs Chamarajanagar vs Kashipur – 2023', width=550, height=320) return chart " 4691,"For the period October to December 2020, which city had the largest decrease in average PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 4692,Show a table of the 5 cleanest citys by average PM10 in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 4693,Plot the rolling 30-day average PM2.5 for Meghalaya in 2019 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Meghalaya') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Meghalaya 2019', width=600, height=300) " 4694,"Create a grouped bar chart comparing the average PM2.5 for Rajasthan, Meghalaya, and Himachal Pradesh across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Meghalaya', 'Himachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 4695,Which 20 citys recorded the highest average PM10 levels in 2024? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 4696,"Create a grouped bar chart comparing the average PM2.5 for Bihar, West Bengal, and Delhi across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Bihar', 'West Bengal', 'Delhi'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 4697,"In January 2019, report the city with the 3rd highest average PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 4698,Show a year-wise table of average PM2.5 for Nagaland from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Nagaland'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4699,Which city had the 2nd lowest 75th percentile of PM10 in January 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 4700,Which city got the 2nd highest NCAP funding considering the standard deviation of its PM10 concentration in 2022 (FY 2021-22)?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'std', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2022_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 4701,Create a table showing annual mean PM2.5 levels for Himachal Pradesh (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Himachal Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4702,Tabulate average PM2.5 for each city in Haryana across all months of 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Haryana'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Faridabad', 'Gurugram', 'Panchkula']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4703,Generate a table showing the 5 most polluted states based on mean PM2.5 for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 4704,How many stations in Katni exceeded the WHO guideline for PM10 in the year 2017?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 15.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 4705,Create a summary table ranking the top 5 citys by PM10 concentration in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 4706,Generate a cross-tab of state vs month for average PM2.5 in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Bihar', 'Delhi', 'Gujarat', 'Haryana', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4707,"Considering 2019, what day of the week had the third-highest average PM10 pollution levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'Timestamp'}}] " 4708,Generate a city × month cross-tab of mean PM2.5 for Haryana in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Haryana'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Ambala', 'Bahadurgarh', 'Ballabgarh', 'Bhiwani', 'Charkhi Dadri', 'Dharuhera', 'Faridabad', 'Fatehabad', 'Gurugram', 'Hisar', 'Jind', 'Kaithal', 'Karnal', 'Kurukshetra', 'Mandikhera', 'Manesar', 'Narnaul', 'Palwal', 'Panchkula', 'Panipat', 'Rohtak', 'Sirsa', 'Sonipat', 'Yamuna Nagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4709,"Plot the yearly average PM2.5 trends for Puducherry, Madhya Pradesh, and Sikkim from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'Madhya Pradesh', 'Sikkim'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Puducherry vs Madhya Pradesh vs Sikkim', width=550, height=320) return chart " 4710,"Tabulate the distribution of PM2.5 per state in 2022 including mean, median, and std."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4711,Which 15 states recorded the highest average PM2.5 levels in 2018? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 4712,"In 2018, which state ranked with the second largest decrease in 75th percentile PM2.5 levels from October to December?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 4713,Tabulate the 20 worst states for average PM10 in 2022 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 4714,Identify the city that showed the second lowest average PM2.5 during the Winter season of 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 4715,Show how many times PM10 exceeded 100 µg/m³ per day across states in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4716,Plot the rolling 30-day average PM2.5 for Telangana in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Telangana') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Telangana 2024', width=600, height=300) " 4717,Create a month-wise PM10 breakdown table across cities in West Bengal for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'West Bengal'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Asansol', 'Durgapur', 'Haldia', 'Howrah', 'Kolkata', 'Siliguri']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4718,Show a bar chart of the top 6 cities by median PM2.5 in 2019.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2019] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(6, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 6 Cities by Median PM2.5 in 2019', width=500, height=300) return chart " 4719,"On January 14, 2019, which station had the second-highest PM10 measurements?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 4720,Create a table showing PM2.5 spread (min to max) and central tendency per state for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4721,Tabulate the total NCAP fund released for each state.," [ {'op': 'SOURCE', 'params': {'table': 'ncap'}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'Total fund released', 'fn': 'sum'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Total fund released'}}, {'op': 'RENAME', 'params': {'map': {'Total fund released': 'Total Fund Released (Cr)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4722,How many stations in Maharashtra went above 90 µg/m³ of PM2.5 in the year 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 90.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 4723,Plot the yearly average PM2.5 for the top 5 most polluted states from 2017 to 2024 as a multi-line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top5 = data.groupby('state')['PM2.5'].mean().nlargest(5).index.tolist() df = data[data['state'].isin(top5)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends – Top 5 Most Polluted States', width=600, height=350) return chart " 4724,Tabulate the monthly mean PM2.5 levels for Kota during 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Kota'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4725,Create a table of PM2.5 exceedance frequency above 100 µg/m³ by state for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4726,Which city registered the highest 75th percentile of PM2.5 in January 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 4727,Show a monthly breakdown table of average PM10 for Prayagraj in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Prayagraj'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4728,Show the monthly average PM2.5 for Bulandshahr in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bulandshahr') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Bulandshahr 2019', width=450, height=280) " 4729,Show a monthly breakdown table of average PM10 for Mumbai in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Mumbai'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4730,Show a bar chart of the top 11 cities by median PM2.5 in 2017.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2017] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(11, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 11 Cities by Median PM2.5 in 2017', width=500, height=300) return chart " 4731,Show NCAP funding utilisation efficiency by state as a table.," [ {'op': 'SOURCE', 'params': {'table': 'ncap'}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Total Fund (Cr)', 'col': 'Total fund released', 'fn': 'sum'}, {'alias': 'Utilised (Cr)', 'col': 'Utilisation as on June 2022', 'fn': 'sum'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': {'denominator': 'Total Fund (Cr)', 'new_col': 'Utilisation %', 'numerator': 'Utilised (Cr)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Total Fund (Cr)'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4732,"Create a grouped bar chart comparing the average PM2.5 for West Bengal, Nagaland, and Himachal Pradesh across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['West Bengal', 'Nagaland', 'Himachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 4733,"On January 14, 2019, which state showed the lowest PM2.5 readings?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 4734,"On January 14, 2024, which city had the second-lowest PM2.5 measurements?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 4735,Tabulate the 15 citys with the least PM2.5 pollution in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 4736,Generate a city × month cross-tab of mean PM10 for Karnataka in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Bagalkot', 'Bengaluru', 'Chamarajanagar', 'Chikkaballapur', 'Chikkamagaluru', 'Davanagere', 'Gadag', 'Hubballi', 'Koppal', 'Madikeri', 'Mysuru', 'Raichur', 'Ramanagara', 'Shivamogga', 'Udupi', 'Vijayapura', 'Yadgir']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4737,Show how average PM10 varied month by month for Bhopal in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Bhopal'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4738,Show the monthly average PM2.5 for Chamarajanagar in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Chamarajanagar') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Chamarajanagar 2020', width=450, height=280) " 4739,Which state had the 2nd highest 25th percentile of PM2.5 in September 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 4740,Create a table of PM2.5 exceedance frequency above 60 µg/m³ by state for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4741,Generate a monthly average PM2.5 table for Mumbai for the year 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Mumbai'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4742,"Plot the yearly average PM2.5 trends for Puducherry, Assam, and Chhattisgarh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'Assam', 'Chhattisgarh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Puducherry vs Assam vs Chhattisgarh', width=550, height=320) return chart " 4743,Which city recorded the lowest average PM2.5 value in February 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 4744,Generate a cross-tab of state vs month for average PM2.5 in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Arunachal Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Chhattisgarh', 'Delhi', 'Gujarat', 'Haryana', 'Himachal Pradesh', 'Jammu and Kashmir', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Meghalaya', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Sikkim', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh', 'Uttarakhand', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4745,How many times did Thanjavur city exceed 75 µg/m³ of PM2.5 in the year 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 75.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 4746,"Tabulate the distribution of PM2.5 per city in 2017 including mean, median, and std."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4747,"Plot the yearly average PM2.5 trends for Kerala, Kerala, and Karnataka from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Kerala', 'Kerala', 'Karnataka'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Kerala vs Kerala vs Karnataka', width=550, height=320) return chart " 4748,Plot the weekly average PM2.5 for Vatva in 2021 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Vatva') & (data['Timestamp'].dt.year == 2021)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Vatva 2021', width=600, height=300) return chart " 4749,Which station possessed the 2nd highest average for PM10 in the Monsoon season of 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 4750,Show a cumulative area chart of PM2.5 readings for Nagaur across 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Nagaur') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Nagaur 2024', width=600, height=300) return chart " 4751,Show a monthly bar chart of the number of days Himachal Pradesh exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Himachal Pradesh') & (data['Timestamp'].dt.year == 2022)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Himachal Pradesh Exceeded WHO PM2.5 Guideline per Month – 2022', width=500, height=300) return chart " 4752,Name the city that was second in terms of highest 75th percentile for PM10 in November 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 4753,Generate a city × month cross-tab of mean PM10 for Bihar in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Bihar'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Patna']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4754,Which city recorded the 3rd lowest 25th percentile of PM2.5 in April 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 4755,Plot the top 15 states by average PM2.5 in 2019 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2019] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(15, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 15 States by Average PM2.5 in 2019', width=500, height=300) return chart " 4756,Generate a descriptive stats table for PM2.5 grouped by city in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4757,Show a pivot table of monthly average PM2.5 by city for Punjab in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Ludhiana', 'Mandi Gobindgarh']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4758,"Visualize the monthly average PM10 for Uttarakhand, Karnataka, and Bihar in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttarakhand', 'Karnataka', 'Bihar'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Uttarakhand, Karnataka, UP – 2023', width=550, height=320) return chart " 4759,Plot the rolling 30-day average PM2.5 for Arunachal Pradesh in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Arunachal Pradesh') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Arunachal Pradesh 2023', width=600, height=300) " 4760,Identify the city that recorded the 2nd highest median PM10 value in April 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 4761,"Considering 2021, what season (Winter, Summer, Monsoon, Post-Monsoon) had the third-highest 75th percentile of PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'season'}}] " 4762,Determine the state that showed the lowest 75th percentile of PM10 over the Monsoon season of 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 4763,"Compare the monthly average PM2.5 of Tirupati, Pithampur, and Charkhi Dadri in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Tirupati', 'Pithampur', 'Charkhi Dadri'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Tirupati vs Pithampur vs Charkhi Dadri – 2017', width=550, height=320) return chart " 4764,Plot the rolling 30-day average PM2.5 for Delhi in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Delhi') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Delhi 2024', width=600, height=300) " 4765,"Show the variability of PM2.5 across citys in 2017 using mean, median, and standard deviation."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4766,"In November 2021, identify the state with the 2nd lowest median PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 4767,Create a table of PM2.5 exceedance frequency above 60 µg/m³ by city for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4768,"Comparing December 2021 to October 2021, which station showed the second least significant drop in average PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 4769,"Visualize the monthly average PM10 for Uttarakhand, Haryana, and Nagaland in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttarakhand', 'Haryana', 'Nagaland'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Uttarakhand, Haryana, UP – 2023', width=550, height=320) return chart " 4770,Identify the state that recorded the third lowest median PM10 during the Summer season of 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 4771,"Plot the yearly average PM2.5 trends for Meghalaya, Punjab, and Tripura from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Meghalaya', 'Punjab', 'Tripura'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Meghalaya vs Punjab vs Tripura', width=550, height=320) return chart " 4772,List average PM2.5 by month for Andhra Pradesh in 2023 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4773,"In March 2021, which city displayed the 3rd highest median PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 4774,Determine the city that recorded the 3rd highest 25th percentile of PM10 over the Summer season of 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 4775,"In November 2022, identify the state with the 3rd lowest average PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 4776,List how many days each city breached the PM10 limit of 150 µg/m³ in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4777,"Create a grouped bar chart comparing the average PM2.5 for Kerala, Assam, and Haryana across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Kerala', 'Assam', 'Haryana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 4778,Tabulate the monthly mean PM2.5 levels for Patna during 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Patna'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4779,Create a summary table ranking the top 15 states by PM10 concentration in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 4780,Show a table of the top 5 citys by average PM2.5 in 2021 including their PM10 levels too.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 4781,Report the station with the 3rd highest median PM2.5 in July 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 4782,Which station registered the lowest median PM10 during October 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 4783,How many times did Sasaram city exceed 75 µg/m³ of PM10 in the year 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 75.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 4784,"Visualize the monthly average PM10 for Uttarakhand, Sikkim, and Andhra Pradesh in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttarakhand', 'Sikkim', 'Andhra Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Uttarakhand, Sikkim, UP – 2018', width=550, height=320) return chart " 4785,Plot the rolling 30-day average PM2.5 for Gujarat in 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Gujarat') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Gujarat 2022', width=600, height=300) " 4786,What is the mean PM10 value on Thursdays in Haryana?," [{'op': 'FILTER', 'params': {'field': 'state', 'value': 'Haryana'}}] " 4787,"Create a grouped bar chart comparing the average PM2.5 for Nagaland, Uttar Pradesh, and Haryana across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Nagaland', 'Uttar Pradesh', 'Haryana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 4788,Tabulate average PM10 for each city in Punjab across all months of 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Amritsar', 'Ludhiana', 'Mandi Gobindgarh']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4789,"Create a grouped bar chart comparing the average PM2.5 for Assam, Andhra Pradesh, and Mizoram across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Assam', 'Andhra Pradesh', 'Mizoram'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 4790,Determine the city with the lowest median PM10 in August 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 4791,"Scatter plot PM2.5 vs PM10 for West Bengal stations in 2024, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'West Bengal') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – West Bengal Stations 2024', width=450, height=350) " 4792,Show the monthly average PM2.5 for Barmer in 2023 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Barmer') & (data['Timestamp'].dt.year == 2023)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Barmer 2023', width=450, height=280) " 4793,Tabulate the yearly average PM2.5 trend for Delhi across all years.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Delhi'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4794,"Visualize the monthly average PM10 for Punjab, Odisha, and Jammu and Kashmir in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Punjab', 'Odisha', 'Jammu and Kashmir'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Punjab, Odisha, UP – 2022', width=550, height=320) return chart " 4795,"List each state's average PM2.5, PM10, and how many stations it has in 2022."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}, {'alias': 'Station Count', 'col': 'station', 'fn': 'nunique'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4796,Tabulate average PM2.5 for each city in Uttar Pradesh across all months of 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Agra', 'Baghpat', 'Bareilly', 'Bulandshahr', 'Firozabad', 'Ghaziabad', 'Gorakhpur', 'Greater Noida', 'Hapur', 'Jhansi', 'Kanpur', 'Khurja', 'Lucknow', 'Meerut', 'Moradabad', 'Muzaffarnagar', 'Prayagraj', 'Varanasi', 'Vrindavan']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4797,Show PM10 averages in a state × month matrix for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Delhi', 'Jharkhand', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Punjab', 'Rajasthan', 'Telangana', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4798,List how many days each city breached the PM2.5 limit of 100 µg/m³ in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4799,Create a table with mean and standard deviation of PM10 by city in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4800,Which 15 citys had the lowest mean PM2.5 in 2024? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 4801,Determine the state exhibiting the 2nd highest average PM2.5 in August 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 4802,Create a month-wise summary of average PM10 for Patna in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Patna'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4803,Show a monthly breakdown table of average PM2.5 for Kanpur in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Kanpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4804,List average PM10 by month for Indore in 2024 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Indore'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4805,Show the monthly average PM10 trend for Chikkaballapur from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Chikkaballapur'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Chikkaballapur (2019–2024)', width=600, height=300) return chart " 4806,"Show mean, median, minimum, and maximum PM10 for each city in 2023 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4807,Show a pivot table of monthly average PM10 by city for Kerala in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Thiruvananthapuram']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4808,Identify the state with the lowest median PM2.5 for February 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 4809,Which city showed the 2nd highest 25th percentile for PM2.5 in the Summer season of 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 4810,List how many days each state breached the PM10 limit of 100 µg/m³ in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4811,Report the station with the 3rd lowest 75th percentile of PM10 in November 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 4812,Tabulate mean PM2.5 and PM10 along with station coverage per state in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}, {'alias': 'Station Count', 'col': 'station', 'fn': 'nunique'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4813,Create a ranked table of the 20 best-performing citys by PM10 in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 4814,Show a pivot table of monthly average PM10 by state for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Arunachal Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Chhattisgarh', 'Delhi', 'Gujarat', 'Haryana', 'Himachal Pradesh', 'Jammu and Kashmir', 'Jharkhand', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Meghalaya', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Sikkim', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh', 'Uttarakhand', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4815,Show the number of days each city exceeded a PM2.5 threshold of 100 µg/m³ in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4816,Show a bar chart of the top 14 cities by median PM2.5 in 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2024] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(14, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 14 Cities by Median PM2.5 in 2024', width=500, height=300) return chart " 4817,List average PM10 by month for Delhi in 2018 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Delhi'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4818,Plot the rolling 30-day average PM2.5 for Mizoram in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Mizoram') & (data['Timestamp'].dt.year == 2020)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Mizoram 2020', width=600, height=300) " 4819,How many times did Haldia city exceed the Indian guideline for PM10 in the year 2017?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 60.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 4820,How many times did Madhya Pradesh exceed the WHO guideline for PM2.5 in 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 15.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 4821,Show the monthly average PM2.5 for Karauli in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Karauli') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Karauli 2020', width=450, height=280) " 4822,Show a cumulative area chart of PM2.5 readings for Amaravati across 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Amaravati') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Amaravati 2021', width=600, height=300) return chart " 4823,"Show descriptive statistics of PM10 (mean, median, std, min, max) per city in 2021."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4824,Generate a monthly average PM10 table for Ahmedabad for the year 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Ahmedabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4825,"Compare the monthly average PM2.5 of Ratlam, Katihar, and Chamarajanagar in 2020 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Ratlam', 'Katihar', 'Chamarajanagar'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2020)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Ratlam vs Katihar vs Chamarajanagar – 2020', width=550, height=320) return chart " 4826,Create a ranked table of the 5 best-performing citys by PM2.5 in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 4827,Identify the station where the 75th percentile of PM10 levels increased the most from October 2019 to October 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 4828,Which 10 citys had the lowest mean PM10 in 2019? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 4829,Plot the weekly average PM2.5 for Panipat in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Panipat') & (data['Timestamp'].dt.year == 2020)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Panipat 2020', width=600, height=300) return chart " 4830,Determine the city that recorded the maximum 75th percentile for PM2.5 ever.," [{'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 4831,"In October 2024, identify the station with the 3rd highest average PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 4832,List the top 15 citys by average PM10 in 2018 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 4833,List all states with their average PM2.5 and PM10 levels in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4834,Report the state that had the highest 75th percentile of PM2.5 in September 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 4835,"Plot the yearly average PM2.5 trends for Uttarakhand, Arunachal Pradesh, and Assam from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttarakhand', 'Arunachal Pradesh', 'Assam'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Uttarakhand vs Arunachal Pradesh vs Assam', width=550, height=320) return chart " 4836,Which 5 citys had the lowest mean PM2.5 in 2021? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 4837,Identify the state with the highest average PM10 for March 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 4838,"Plot the yearly average PM2.5 trends for Arunachal Pradesh, Himachal Pradesh, and Assam from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Arunachal Pradesh', 'Himachal Pradesh', 'Assam'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Arunachal Pradesh vs Himachal Pradesh vs Assam', width=550, height=320) return chart " 4839,Determine the city exhibiting the 2nd highest average PM10 in April 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 4840,List average PM2.5 by month for Patna in 2020 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Patna'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4841,Show the monthly average PM2.5 for Talcher in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Talcher') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Talcher 2019', width=450, height=280) " 4842,"For Noida, what date in the last three years showed the second-highest PM2.5 reading?"," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 3}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'Timestamp'}}] " 4843,Which station exhibited the third smallest decrease in its 25th percentile PM2.5 levels between October and December of 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 4844,Determine the station exhibiting the highest average PM2.5 in August 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 4845,Show a monthly bar chart of the number of days Tamil Nadu exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Tamil Nadu') & (data['Timestamp'].dt.year == 2023)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Tamil Nadu Exceeded WHO PM2.5 Guideline per Month – 2023', width=500, height=300) return chart " 4846,Report which city experienced the 2nd highest median PM10 throughout the Winter season of 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 4847,Generate a year-by-year summary table of PM10 readings for Haryana.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Haryana'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4848,"Compare the monthly average PM2.5 of Sirsa, Hisar, and Imphal in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Sirsa', 'Hisar', 'Imphal'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Sirsa vs Hisar vs Imphal – 2024', width=550, height=320) return chart " 4849,Determine the city with the 3rd lowest 25th percentile of PM2.5 in February 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 4850,Which city registered the 2nd maximum 25th percentile of PM10 in the Post-Monsoon season of 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 4851,"Create a grouped bar chart comparing the average PM2.5 for Uttar Pradesh, Himachal Pradesh, and Puducherry across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttar Pradesh', 'Himachal Pradesh', 'Puducherry'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 4852,Identify the state that recorded the 2nd highest 75th percentile of PM10 value in March 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 4853,Create a month-wise PM2.5 breakdown table across cities in Maharashtra for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Aurangabad', 'Chandrapur', 'Kalyan', 'Mumbai', 'Nagpur', 'Nashik', 'Navi Mumbai', 'Pune', 'Solapur']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4854,"Tabulate PM2.5 levels, population, and land area per state in 2024."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': { 'map': { 'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4855,Determine the state exhibiting the 2nd lowest average PM2.5 in August 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 4856,"Create a table showing top 10 citys ranked by PM2.5 in 2021, also showing PM10."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 4857,"In February 2020, identify the state with the 2nd highest 75th percentile of PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 4858,Show a bar chart of the top 15 cities by median PM2.5 in 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2023] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(15, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 15 Cities by Median PM2.5 in 2023', width=500, height=300) return chart " 4859,"Compare the monthly average PM2.5 of Chikkamagaluru, Gadag, and Kanpur in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Chikkamagaluru', 'Gadag', 'Kanpur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Chikkamagaluru vs Gadag vs Kanpur – 2019', width=550, height=320) return chart " 4860,Show a cumulative area chart of PM2.5 readings for Greater Noida across 2019.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Greater Noida') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Greater Noida 2019', width=600, height=300) return chart " 4861,"Plot the yearly average PM2.5 trends for Jharkhand, Manipur, and Haryana from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Manipur', 'Haryana'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Jharkhand vs Manipur vs Haryana', width=550, height=320) return chart " 4862,Show the monthly average PM10 trend for Chengalpattu from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Chengalpattu'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Chengalpattu (2017–2022)', width=600, height=300) return chart " 4863,"Which city showed the minimum median PM10 on March 31, 2021?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 4864,Show PM2.5 averages in a state × month matrix for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Arunachal Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Chhattisgarh', 'Delhi', 'Gujarat', 'Haryana', 'Jammu and Kashmir', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Meghalaya', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4865,Report the city that had the lowest 25th percentile of PM10 in September 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 4866,Which state noted the 2nd maximum average PM10 during the Monsoon season of 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 4867,"Visualize the monthly average PM10 for Assam, Odisha, and Telangana in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Assam', 'Odisha', 'Telangana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Assam, Odisha, UP – 2021', width=550, height=320) return chart " 4868,Report which city registered the 3rd most minimal 25th percentile of PM2.5 throughout the Summer season of 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 4869,"For November 2020 compared to November 2019, which city registered the highest increase in average PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 4870,"Compare the monthly average PM2.5 of Rohtak, Palkalaiperur, and Dewas in 2020 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Rohtak', 'Palkalaiperur', 'Dewas'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2020)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Rohtak vs Palkalaiperur vs Dewas – 2020', width=550, height=320) return chart " 4871,Show a ranked table of the 15 most polluted citys by average PM2.5 in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 4872,Show the monthly average PM2.5 for Amritsar in 2024 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Amritsar') & (data['Timestamp'].dt.year == 2024)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Amritsar 2024', width=450, height=280) " 4873,How many times did Maharashtra exceed the Indian guideline for PM10 in 2017?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 60.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 4874,Identify the state with the 2nd lowest average PM2.5 in September 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 4875,Tabulate days with PM10 > 100 µg/m³ and exceedance percentage per state in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4876,Which city experienced the most significant drop in its 75th percentile PM2.5 levels between October and December 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 4877,Report which station registered the 2nd highest 25th percentile of PM2.5 throughout the Post-Monsoon season of 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 4878,List the top 20 states by average PM2.5 in 2019 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 4879,Which station recorded the 2nd lowest median PM2.5 in the Post-Monsoon season of 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 4880,What is the mean PM10 value on Saturdays in Tamil Nadu?," [{'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}] " 4881,Show a monthly bar chart of the number of days Delhi exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2017.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Delhi') & (data['Timestamp'].dt.year == 2017)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Delhi Exceeded WHO PM2.5 Guideline per Month – 2017', width=500, height=300) return chart " 4882,Tabulate mean PM2.5 alongside state population figures for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4883,Create a statistical summary table of PM10 readings by state for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4884,"Create a grouped bar chart comparing the average PM2.5 for Jammu and Kashmir, Jammu and Kashmir, and Haryana across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jammu and Kashmir', 'Jammu and Kashmir', 'Haryana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 4885,Tabulate the 5 worst citys for average PM2.5 in 2019 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 4886,"Create a grouped bar chart comparing the average PM2.5 for Tripura, Chhattisgarh, and Uttarakhand across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tripura', 'Chhattisgarh', 'Uttarakhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 4887,Identify the week in 2018 that registered the second-lowest 75th percentile for PM2.5 levels.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'week'}}] " 4888,Show a table of average PM2.5 per state in 2017 along with population.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4889,Identify the city that recorded the 2nd highest 25th percentile of PM2.5 value in May 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 4890,"Visualize the monthly average PM10 for Puducherry, Haryana, and Chandigarh in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'Haryana', 'Chandigarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Puducherry, Haryana, UP – 2023', width=550, height=320) return chart " 4891,Report which state experienced the third lowest average PM10 throughout the Monsoon season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 4892,Create a table showing annual mean PM10 levels for Mizoram (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Mizoram'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4893,Create a summary table ranking the top 15 states by PM10 concentration in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 4894,Show a pivot table of monthly average PM2.5 by city for Haryana in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Haryana'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Ambala', 'Bahadurgarh', 'Ballabgarh', 'Bhiwani', 'Dharuhera', 'Faridabad', 'Fatehabad', 'Gurugram', 'Hisar', 'Jind', 'Karnal', 'Kurukshetra', 'Manesar', 'Narnaul', 'Palwal', 'Panchkula', 'Panipat', 'Rohtak', 'Sirsa', 'Sonipat', 'Yamuna Nagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4895,Which 15 citys recorded the highest average PM2.5 levels in 2021? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 4896,"In November 2020, identify the station with the highest median PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 4897,Show a table of the 20 cleanest states by average PM2.5 in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 4898,Which city experienced the most significant drop in its median PM10 levels between October and December 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 4899,Which state had the second-most minimal 25th percentile of PM10 in July 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 4900,Report the city that had the 2nd lowest 75th percentile of PM10 in April 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 4901,"Visualize the monthly average PM10 for Andhra Pradesh, Puducherry, and Telangana in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Puducherry', 'Telangana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Andhra Pradesh, Puducherry, UP – 2019', width=550, height=320) return chart " 4902,Report which city experienced the third highest average PM2.5 throughout the Monsoon season of 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 4903,Create a month-wise PM2.5 breakdown table across cities in Assam for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Assam'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Byrnihat', 'Guwahati', 'Nagaon', 'Nalbari', 'Silchar', 'Sivasagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4904,"Show mean, median, minimum, and maximum PM2.5 for each city in 2018 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4905,"Create a grouped bar chart comparing the average PM2.5 for Punjab, Kerala, and Odisha across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Punjab', 'Kerala', 'Odisha'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 4906,Show a table of the top 15 states by average PM2.5 in 2017 including their PM10 levels too.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 4907,List how many days each city breached the PM10 limit of 150 µg/m³ in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4908,Show a monthly bar chart of the number of days Uttar Pradesh exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Uttar Pradesh') & (data['Timestamp'].dt.year == 2022)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Uttar Pradesh Exceeded WHO PM2.5 Guideline per Month – 2022', width=500, height=300) return chart " 4909,Report the state with the 3rd highest 75th percentile of PM10 in September 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 4910,Show a pivot table of monthly average PM2.5 by city for Punjab in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Amritsar', 'Bathinda', 'Jalandhar', 'Khanna', 'Ludhiana', 'Mandi Gobindgarh', 'Patiala']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4911,"In 2019, which season (Winter, Summer, Monsoon, Post-Monsoon) experienced the minimum 25th percentile of PM10 concentrations?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'season'}}] " 4912,Show the monthly average PM2.5 for Kolkata in 2021 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Kolkata') & (data['Timestamp'].dt.year == 2021)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Kolkata 2021', width=450, height=280) " 4913,"Plot the yearly average PM2.5 trends for Odisha, Kerala, and Madhya Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Odisha', 'Kerala', 'Madhya Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Odisha vs Kerala vs Madhya Pradesh', width=550, height=320) return chart " 4914,Create a summary table ranking the top 15 citys by PM2.5 concentration in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 4915,Plot the top 12 states by average PM2.5 in 2017 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2017] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(12, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 12 States by Average PM2.5 in 2017', width=500, height=300) return chart " 4916,Which state experienced the 2nd highest average PM2.5 in the Winter season of 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 4917,Show a pivot table of monthly average PM2.5 by city for Odisha in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Odisha'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Angul', 'Balasore', 'Barbil', 'Baripada', 'Bhubaneswar', 'Bileipada', 'Brajrajnagar', 'Byasanagar', 'Cuttack', 'Keonjhar', 'Nayagarh', 'Rairangpur', 'Rourkela', 'Suakati', 'Talcher', 'Tensa']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4918,Plot the weekly average PM2.5 for Siwan in 2021 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Siwan') & (data['Timestamp'].dt.year == 2021)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Siwan 2021', width=600, height=300) return chart " 4919,Show the monthly average PM2.5 for Siwan in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Siwan') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Siwan 2019', width=450, height=280) " 4920,Show a cumulative area chart of PM2.5 readings for Palwal across 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Palwal') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Palwal 2022', width=600, height=300) return chart " 4921,"In 2023, which week of the year corresponded to the second-lowest 75th percentile for PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'week'}}] " 4922,Report the state that had the highest 75th percentile of PM2.5 in February 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 4923,Create a month-wise summary of average PM10 for Hyderabad in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Hyderabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4924,Show annual average PM2.5 for Karnataka as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4925,"Show descriptive statistics of PM10 (mean, median, std, min, max) per state in 2023."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4926,"Create a grouped bar chart comparing the average PM2.5 for Chhattisgarh, Telangana, and Arunachal Pradesh across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chhattisgarh', 'Telangana', 'Arunachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 4927,"Visualize the monthly average PM10 for Puducherry, Tripura, and Uttarakhand in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'Tripura', 'Uttarakhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Puducherry, Tripura, UP – 2021', width=550, height=320) return chart " 4928,List all states with their average PM2.5 and population for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4929,Show the monthly average PM2.5 for Pudukottai in 2024 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Pudukottai') & (data['Timestamp'].dt.year == 2024)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Pudukottai 2024', width=450, height=280) " 4930,Generate a city × month cross-tab of mean PM10 for Kerala in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Eloor', 'Kannur', 'Kochi', 'Kollam', 'Kozhikode', 'Thiruvananthapuram', 'Thrissur']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4931,Which 15 states had the lowest mean PM2.5 in 2018? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 4932,Show a cumulative area chart of PM2.5 readings for Gorakhpur across 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Gorakhpur') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Gorakhpur 2021', width=600, height=300) return chart " 4933,Report the state that had the 2nd lowest average PM10 in July 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 4934,"Which state (excluding Union Territories) has the 2nd largest land area among the top 10 most polluted states, according to the 75th percentile of PM10 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 10, 'ret': 'state'}}] " 4935,Show how average PM10 varied month by month for West Bengal in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'West Bengal'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4936,Show a ranked table of the 5 most polluted citys by average PM10 in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 4937,Show the monthly average PM2.5 for Rourkela in 2022 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Rourkela') & (data['Timestamp'].dt.year == 2022)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Rourkela 2022', width=450, height=280) " 4938,"Show the top 15 states by average PM10 in 2023 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2023] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(15, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 15 States by Average PM10 in 2023', width=500, height=300) return chart " 4939,"Between April 2019 and April 2020, which state saw the largest upsurge in its 75th percentile PM2.5 level?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 4940,Show the monthly average PM2.5 for Guwahati in 2024 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Guwahati') & (data['Timestamp'].dt.year == 2024)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Guwahati 2024', width=450, height=280) " 4941,Show a year-wise table of average PM2.5 for Gaya from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Gaya'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4942,Tabulate average PM10 for each city in Rajasthan across all months of 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Ajmer', 'Alwar', 'Bhiwadi', 'Jaipur', 'Jodhpur', 'Kota', 'Pali', 'Sirohi', 'Udaipur']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4943,Show the monthly average PM10 trend for Bilaspur from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Bilaspur'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Bilaspur (2017–2022)', width=600, height=300) return chart " 4944,"Create a grouped bar chart comparing the average PM2.5 for Andhra Pradesh, Tripura, and Tamil Nadu across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Tripura', 'Tamil Nadu'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 4945,List the top 15 citys by average PM2.5 in 2017 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 4946,Show average PM2.5 per capita by state in 2023 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM2.5 per million', 'numerator': 'PM2.5', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'PM2.5 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4947,Identify the state that recorded the 2nd lowest 25th percentile of PM2.5 value in March 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 4948,List states ranked by PM10 concentration relative to their area in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM10 per km²', 'numerator': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)', 'PM10 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4949,Identify the station that recorded the lowest median PM10 value in March 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 4950,List states with their PM2.5 violation count and rate (>60 µg/m³) in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4951,"Tabulate PM10 statistics (mean, std, min, max) for each city in 2024."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'q25', 'median', 'q75']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4952,"Compare the monthly average PM2.5 of Meerut, Howrah, and Gorakhpur in 2020 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Meerut', 'Howrah', 'Gorakhpur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2020)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Meerut vs Howrah vs Gorakhpur – 2020', width=550, height=320) return chart " 4953,Which state recorded the 2nd lowest 25th percentile of PM10 in October 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 4954,Which state had the most pronounced increase in median PM10 levels when comparing November 2019 to November 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 4955,How many times did Manguraha city exceed 90 µg/m³ of PM2.5 in the year 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 90.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 4956,"Show the mean, median and standard deviation of PM2.5 per city in 2021 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4957,Identify the week in 2022 that experienced the minimum 25th percentile for PM2.5 levels.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'week'}}] " 4958,Which state registered the lowest median PM10 during April 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 4959,"On March 31, 2023, which city recorded the second-highest average PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 4960,"On March 31, 2022, which city had the second-highest average PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 4961,"On January 14, 2020, which station showed the second-highest PM2.5 values?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 4962,Show a bar chart of the top 13 cities by median PM2.5 in 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2021] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(13, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 13 Cities by Median PM2.5 in 2021', width=500, height=300) return chart " 4963,Show the monthly average PM10 trend for Manesar from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Manesar'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Manesar (2017–2022)', width=600, height=300) return chart " 4964,Identify the state with the third-highest median PM2.5 during February 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 4965,"Which state having a land area less than 50,000 km² registers the 2nd maximum PM2.5 level, based on its median PM2.5 level?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}] " 4966,Create a ranked table of the 10 best-performing citys by PM2.5 in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 4967,"Compare the monthly average PM2.5 of Kadapa, Baddi, and Dharuhera in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Kadapa', 'Baddi', 'Dharuhera'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Kadapa vs Baddi vs Dharuhera – 2024', width=550, height=320) return chart " 4968,"Comparing December 2023 to October 2023, which state showed the most significant drop in median PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 4969,Determine the state that recorded the maximum average PM2.5 across all time.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 4970,Tabulate the 15 states with the least PM2.5 pollution in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 4971,List the average PM2.5 for West Bengal broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'West Bengal'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4972,Which 10 citys had the lowest mean PM2.5 in 2018? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 4973,"Plot average PM2.5 (2022) vs state population as a scatter plot, labeling each point with the state name."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): pm = data[data['Timestamp'].dt.year == 2022].groupby('state')['PM2.5'].mean().reset_index().dropna() df = pm.merge(states_data, on='state') points = alt.Chart(df).mark_point(filled=True, size=80).encode( x=alt.X('population:Q', title='Population', axis=alt.Axis(format='~s')), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('population:Q', format=',')] ) labels = alt.Chart(df).mark_text(align='left', dx=5, fontSize=9).encode( x='population:Q', y='PM2\.5:Q', text='state:N' ) return (points + labels).properties(title='PM2.5 vs Population by State – 2022', width=500, height=400) " 4974,"Taking all years into account, which September was associated with the minimum 75th percentile of PM2.5 levels?"," [{'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'Timestamp'}}] " 4975,"Which union territory exhibits the 3rd maximum PM10 concentration per square kilometer, based on 25th percentile PM10 values?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_km2', 'numerator': 'PM10', 'denominator': 'area (km2)'}}, {'op': 'SORT', 'params': {'col': 'pm_per_km2', 'ascending': False}}] " 4976,Show a cumulative area chart of PM2.5 readings for Imphal across 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Imphal') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Imphal 2024', width=600, height=300) return chart " 4977,List the bottom 15 states with the lowest average PM2.5 in 2019 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 4978,"Scatter plot PM2.5 vs PM10 for Mizoram stations in 2020, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Mizoram') & (data['Timestamp'].dt.year == 2020)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Mizoram Stations 2020', width=450, height=350) " 4979,Show a cumulative area chart of PM2.5 readings for Vijayawada across 2019.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Vijayawada') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Vijayawada 2019', width=600, height=300) return chart " 4980,Show a bar chart of the top 13 cities by median PM2.5 in 2020.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2020] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(13, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 13 Cities by Median PM2.5 in 2020', width=500, height=300) return chart " 4981,Determine the city with the 3rd lowest median PM10 in June 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 4982,Identify the city with the lowest average PM2.5 for November 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 4983,Show a bar chart of the top 12 cities by median PM2.5 in 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2024] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(12, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 12 Cities by Median PM2.5 in 2024', width=500, height=300) return chart " 4984,Create a summary table ranking the top 20 citys by PM2.5 concentration in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 4985,Tabulate daily PM2.5 exceedances (above 60 µg/m³) per city for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4986,Visualize the bottom 5 states with the lowest average PM2.5 in 2017 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2017] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(5, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 5 States by Average PM2.5 in 2017', width=500, height=300) return chart " 4987,"Create a grouped bar chart comparing the average PM2.5 for Kerala, Jharkhand, and Chandigarh across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Kerala', 'Jharkhand', 'Chandigarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 4988,"Scatter plot PM2.5 vs PM10 for Tamil Nadu stations in 2023, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Tamil Nadu') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Tamil Nadu Stations 2023', width=450, height=350) " 4989,Tabulate the monthly mean PM10 levels for Jodhpur during 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Jodhpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4990,Show a year-wise table of average PM2.5 for Gwalior from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Gwalior'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4991,Create a month-wise PM2.5 breakdown table across cities in Gujarat for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Gujarat'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Ahmedabad', 'Ankleshwar', 'Gandhinagar', 'Nandesari', 'Surat', 'Vapi', 'Vatva']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4992,Report which station possessed the 2nd highest 75th percentile of PM2.5 throughout the Winter season of 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 4993,"In 2022, on which day of the week were average PM2.5 pollution levels the second highest?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'Timestamp'}}] " 4994,Create a month-wise summary of average PM2.5 for Prayagraj in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Prayagraj'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4995,"In January 2023, identify the station with the 2nd lowest median PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 4996,How many stations in Kerala surpassed 30 µg/m³ of PM2.5 in the year 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 30.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 4997,Show a pivot table of monthly average PM10 by city for Punjab in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Amritsar', 'Bathinda', 'Jalandhar', 'Khanna', 'Ludhiana', 'Mandi Gobindgarh', 'Patiala', 'Rupnagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 4998,Report the station with the highest median PM2.5 in May 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 4999,Report the station that had the 2nd highest median PM2.5 in September 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 5000,Create a month-wise PM10 breakdown table across cities in Karnataka for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Bagalkot', 'Belgaum', 'Bengaluru', 'Bidar', 'Chamarajanagar', 'Chikkaballapur', 'Chikkamagaluru', 'Davanagere', 'Dharwad', 'Gadag', 'Hassan', 'Haveri', 'Hubballi', 'Kalaburagi', 'Koppal', 'Madikeri', 'Mangalore', 'Mysuru', 'Raichur', 'Ramanagara', 'Shivamogga', 'Tumakuru', 'Udupi', 'Vijayapura', 'Yadgir']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5001,"Create a grouped bar chart comparing the average PM2.5 for Rajasthan, Andhra Pradesh, and Bihar across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Andhra Pradesh', 'Bihar'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 5002,"Which state (excluding Union Territories) possesses the 2nd smallest land area among the top 3 most polluted states, based on the variance of PM10 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'var', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 3, 'ret': 'state'}}] " 5003,List the top 15 states by average PM10 in 2023 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 5004,Determine the state which was granted the 5th lowest NCAP funding considering its 75th percentile of PM10 concentration in 2021 (FY 2020-21).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 5005,"Show a table of average PM10, population, and area for all states in 2022."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5006,Show a table of the 10 cleanest states by average PM2.5 in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 5007,"Taking all years into account, which July registered the maximum median PM2.5 levels?"," [{'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'Timestamp'}}] " 5008,"Visualize the monthly average PM10 for Himachal Pradesh, Manipur, and Meghalaya in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Himachal Pradesh', 'Manipur', 'Meghalaya'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Himachal Pradesh, Manipur, UP – 2022', width=550, height=320) return chart " 5009,"Plot the yearly average PM2.5 trends for Punjab, Odisha, and Rajasthan from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Punjab', 'Odisha', 'Rajasthan'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Punjab vs Odisha vs Rajasthan', width=550, height=320) return chart " 5010,Tabulate average and median PM10 for all citys in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5011,Find the state that had the third-highest median PM2.5 in December 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 5012,Generate a dual-pollutant summary table (PM2.5 and PM10) by state for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5013,Create a table showing annual mean PM2.5 levels for Kerala (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5014,"On March 31, 2024, which state recorded the minimum median PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 5015,"In January 2020, report the station with the 2nd highest 25th percentile of PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 5016,Tabulate the monthly mean PM2.5 levels for Varanasi during 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Varanasi'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5017,"Which state showed the second-lowest 25th percentile for PM2.5 on March 31, 2021?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 5018,Generate a dual-pollutant summary table (PM2.5 and PM10) by state for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5019,Create a table of PM10 exceedance frequency above 100 µg/m³ by city for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5020,"Scatter plot PM2.5 vs PM10 for Tamil Nadu stations in 2024, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Tamil Nadu') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Tamil Nadu Stations 2024', width=450, height=350) " 5021,Name the station with the highest 25th percentile for PM2.5 in November 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 5022,Which state had the 3rd highest average PM2.5 in October 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 5023,Name the station with the third-lowest 75th percentile for PM2.5 in May 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 5024,Plot the weekly average PM2.5 for Hapur in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Hapur') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Hapur 2023', width=600, height=300) return chart " 5025,"Considering 2018, what weekday displayed the second-highest average PM10 pollution levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'Timestamp'}}] " 5026,Create a heatmap showing the average PM2.5 by month (x-axis) and year (y-axis) for Jammu and Kashmir.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Jammu and Kashmir'].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Year:N', title='Year'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='Avg PM2.5'), tooltip=['Year:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Jammu and Kashmir (Month × Year)', width=500, height=280) return chart " 5027,List states with their average PM2.5 and area for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5028,What count of Assam stations went above the Indian guideline for PM2.5 in 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 60.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 5029,Show a ranked table of the 10 most polluted citys by average PM10 in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 5030,"Show descriptive statistics of PM2.5 (mean, median, std, min, max) per city in 2017."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5031,"Which state (excluding Union Territories) exhibits the 2nd lowest PM2.5 concentration per square kilometer, based on median PM2.5 values?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_km2', 'numerator': 'PM2.5', 'denominator': 'area (km2)'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'pm_per_km2', 'ascending': True}}] " 5032,Which city recorded the 3rd highest average PM10 in August 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 5033,Plot the weekly average PM2.5 for Rohtak in 2019 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Rohtak') & (data['Timestamp'].dt.year == 2019)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Rohtak 2019', width=600, height=300) return chart " 5034,Generate a table showing the 10 most polluted citys based on mean PM2.5 for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 5035,Show how average PM10 varied month by month for Mizoram in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Mizoram'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5036,Plot the rolling 30-day average PM2.5 for Rajasthan in 2018 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Rajasthan') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Rajasthan 2018', width=600, height=300) " 5037,"In April 2018, which station exhibited the 2nd highest median PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 5038,Show a monthly bar chart of the number of days Madhya Pradesh exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Madhya Pradesh') & (data['Timestamp'].dt.year == 2021)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Madhya Pradesh Exceeded WHO PM2.5 Guideline per Month – 2021', width=500, height=300) return chart " 5039,"Which state (excluding Union Territories) possesses the minimum land area among the top 10 most polluted states, based on median PM2.5 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 10, 'ret': 'state'}}] " 5040,Which station had the 2nd highest average PM2.5 in August 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 5041,List all states with their average PM2.5 and population for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5042,Create a summary table ranking the top 15 states by PM10 concentration in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 5043,"Create a grouped bar chart comparing the average PM2.5 for Nagaland, Manipur, and Himachal Pradesh across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Nagaland', 'Manipur', 'Himachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 5044,Create a ranked table of the 10 best-performing citys by PM10 in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 5045,"Create a grouped bar chart comparing the average PM2.5 for Telangana, Assam, and Andhra Pradesh across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Telangana', 'Assam', 'Andhra Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 5046,"Plot the yearly average PM2.5 trends for Meghalaya, Telangana, and Arunachal Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Meghalaya', 'Telangana', 'Arunachal Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Meghalaya vs Telangana vs Arunachal Pradesh', width=550, height=320) return chart " 5047,"Visualize the monthly average PM10 for Delhi, Kerala, and Telangana in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Delhi', 'Kerala', 'Telangana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Delhi, Kerala, UP – 2017', width=550, height=320) return chart " 5048,Show a heatmap of average PM2.5 for the top 6 most polluted states by month for 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(6).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 6 Polluted States by Month (2021)', width=500, height=300) return chart " 5049,Create a table showing annual mean PM10 levels for Ghaziabad (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Ghaziabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5050,"In 2021, which city will rank with the smallest reduction in median PM10 levels from October to December?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 5051,"Create a grouped bar chart comparing the average PM2.5 for Chandigarh, Madhya Pradesh, and Manipur across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chandigarh', 'Madhya Pradesh', 'Manipur'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 5052,Show a pivot table of monthly average PM10 by city for Bihar in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Bihar'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Araria', 'Arrah', 'Bettiah', 'Bhagalpur', 'Bihar Sharif', 'Chhapra', 'Darbhanga', 'Gaya', 'Hajipur', 'Katihar', 'Kishanganj', 'Manguraha', 'Motihari', 'Munger', 'Muzaffarpur', 'Patna', 'Purnia', 'Rajgir', 'Saharsa', 'Sasaram', 'Siwan']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5053,Tabulate the year-wise NCAP funding for each state.," [ {'op': 'SOURCE', 'params': {'table': 'ncap'}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ { 'alias': 'FY 2019-20 (Cr)', 'col': 'Amount released during FY 2019-20', 'fn': 'sum'}, { 'alias': 'FY 2020-21 (Cr)', 'col': 'Amount released during FY 2020-21', 'fn': 'sum'}, { 'alias': 'FY 2021-22 (Cr)', 'col': 'Amount released during FY 2021-22', 'fn': 'sum'}, {'alias': 'Total (Cr)', 'col': 'Total fund released', 'fn': 'sum'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Total (Cr)'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5054,Tabulate average PM10 for each city in Punjab across all months of 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Amritsar', 'Bathinda', 'Jalandhar', 'Khanna', 'Ludhiana', 'Mandi Gobindgarh', 'Patiala', 'Rupnagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5055,"Scatter plot PM2.5 vs PM10 for Delhi stations in 2021, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Delhi') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Delhi Stations 2021', width=450, height=350) " 5056,Which 15 states had the lowest mean PM10 in 2018? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 5057,"Visualize the monthly average PM10 for Haryana, Odisha, and Puducherry in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Odisha', 'Puducherry'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Haryana, Odisha, UP – 2022', width=550, height=320) return chart " 5058,Create a ranked table of the 15 best-performing states by PM10 in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 5059,Which station recorded the most significant growth in its 75th percentile PM2.5 level between March 2019 and March 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 5060,Create a month-wise summary of average PM10 for Bihar in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Bihar'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5061,Show the monthly average PM2.5 for Sivasagar in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Sivasagar') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Sivasagar 2018', width=450, height=280) " 5062,Plot the distribution of PM2.5 values in Puducherry across all years using a histogram.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Puducherry'].dropna(subset=['PM2.5']) df = df[['PM2.5']] chart = alt.Chart(df).mark_bar(color='steelblue', opacity=0.75).encode( x=alt.X('PM2\.5:Q', bin=alt.Bin(maxbins=40), title='PM2.5 (µg/m³)'), y=alt.Y('count()', title='Number of Observations'), tooltip=[alt.Tooltip('PM2\.5:Q', bin=True), 'count()'] ).properties(title='PM2.5 Distribution – Puducherry (All Years)', width=500, height=300) return chart " 5063,Identify the station with the 2nd lowest median PM2.5 for June 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 5064,"Plot the yearly average PM2.5 trends for Himachal Pradesh, Madhya Pradesh, and Sikkim from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Himachal Pradesh', 'Madhya Pradesh', 'Sikkim'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Himachal Pradesh vs Madhya Pradesh vs Sikkim', width=550, height=320) return chart " 5065,Which city had the highest median PM10 in October 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 5066,How many stations in Arunachal Pradesh exceeded 90 µg/m³ of PM10 in the year 2017?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 90.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 5067,Show the monthly average PM2.5 for Delhi across each year from 2017 to 2024 as small multiples (faceted by year).," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Delhi'].copy() df['Year'] = df['Timestamp'].dt.year df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5'), tooltip=['Year:O','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet( facet=alt.Facet('Year:O', title='Year'), columns=4 ).properties(title='Monthly PM2.5 in Delhi by Year (2017–2024)') return chart " 5068,"Which state having a land area exceeding 50,000 km² registers the maximum PM2.5 level, based on its total PM2.5 level?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'sum', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}] " 5069,Show average PM2.5 per state in 2023 with area in km².," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5070,Show a monthly breakdown table of average PM2.5 for Gurugram in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Gurugram'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5071,Identify a week showing Kurukshetra's 3rd maximum PM2.5 levels across the specified years.," [{'op': 'FILTER', 'params': {'field': 'city', 'value': 'Kurukshetra'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'week'}}] " 5072,"Which union territory having a land area less than 1,000 km² registers the 2nd minimum PM2.5 level, according to its median PM2.5 level?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}] " 5073,Report which state documented the second highest 75th percentile for PM2.5 historically.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 5074,Create a table of PM2.5 per unit area for all states in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, { 'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM2.5 per km²', 'numerator': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)', 'PM2.5 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5075,"Identify the city with the lowest PM2.5 measurements on January 14, 2021."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 5076,Determine the station exhibiting the 3rd lowest 75th percentile of PM2.5 over the Post-Monsoon season of 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 5077,Which state received the 4th lowest NCAP funding relative to its total PM2.5 concentration in 2020 (FY 2019-20)?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'sum', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2020_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 5078,Determine a week with Sagar's 2nd lowest PM2.5 levels over all these years.," [{'op': 'FILTER', 'params': {'field': 'city', 'value': 'Sagar'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'week'}}] " 5079,Show a cumulative area chart of PM2.5 readings for Belapur across 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Belapur') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Belapur 2024', width=600, height=300) return chart " 5080,Which state registered the lowest 25th percentile of PM2.5 during January 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 5081,Create a ranked table of the 5 best-performing states by PM10 in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 5082,"Taking all years into account, which September was associated with the third-highest 75th percentile of PM2.5 levels?"," [{'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'Timestamp'}}] " 5083,"Scatter plot PM2.5 vs PM10 for Delhi stations in 2022, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Delhi') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Delhi Stations 2022', width=450, height=350) " 5084,Identify the station that recorded the 3rd highest 25th percentile of PM10 value in March 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 5085,"In 2019, which state will rank with the third largest reduction in 25th percentile PM2.5 levels from October to December?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 5086,Create a month-wise summary of average PM2.5 for Maharashtra in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5087,List average PM10 by month for Madhya Pradesh in 2024 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5088,Which station recorded the 3rd lowest average PM10 in April 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 5089,Identify the state with the 2nd lowest 75th percentile of PM2.5 for October 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 5090,"Identify the station that recorded the second-highest PM10 measurements on January 14, 2020."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 5091,Tabulate the 5 states with the least PM10 pollution in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 5092,Which station showed the highest 75th percentile of PM2.5 in December 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 5093,Which state recorded the 2nd lowest median PM2.5 during the Summer season of 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 5094,"Compare the monthly average PM2.5 of Katni, Chandrapur, and Sasaram in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Katni', 'Chandrapur', 'Sasaram'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Katni vs Chandrapur vs Sasaram – 2019', width=550, height=320) return chart " 5095,Generate a dual-pollutant summary table (PM2.5 and PM10) by city for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5096,Show the monthly average PM10 trend for Karwar from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Karwar'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Karwar (2019–2024)', width=600, height=300) return chart " 5097,Which Indian station recorded the 3rd lowest PM10 levels for a single day in the past decade?," [{'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'eq_rank', 'rank': 2}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'count'}}, {'op': 'SORT', 'params': {'col': 'count', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 5098,"Tabulate the distribution of PM10 per city in 2023 including mean, median, and std."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5099,Find the state with the second-lowest 75th percentile for PM10 in November 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 5100,Show the monthly average PM2.5 for Haveri in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Haveri') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Haveri 2017', width=450, height=280) " 5101,Which 20 states recorded the highest average PM2.5 levels in 2019? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 5102,Show average PM2.5 per state in 2017 with area in km².," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5103,Which state recorded the 3rd highest median PM10 in August 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 5104,Generate a table showing the 5 most polluted citys based on mean PM2.5 for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 5105,"Which city experienced the minimum PM10 concentrations on August 15, 2024?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 5106,"Plot the yearly average PM2.5 trends for Manipur, Tamil Nadu, and Mizoram from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Manipur', 'Tamil Nadu', 'Mizoram'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Manipur vs Tamil Nadu vs Mizoram', width=550, height=320) return chart " 5107,Determine the state with the highest 75th percentile PM2.5 value in April 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 5108,Which 10 states recorded the highest average PM10 levels in 2017? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 5109,"Show descriptive statistics of PM10 (mean, median, std, min, max) per city in 2023."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5110,"For 2022, which week of the year experienced the highest median PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'week'}}] " 5111,How many times did Bangalore city exceed 30 µg/m³ of PM2.5 in the year 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 30.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 5112,Report the state with the highest median PM10 in November 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 5113,"Identify the city that experienced the second-highest PM10 levels on August 15, 2021."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 5114,Which state recorded the highest 75th percentile of PM10 in May 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 5115,"Tabulate PM2.5 levels, population, and land area per state in 2019."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': { 'map': { 'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5116,Plot the weekly average PM2.5 for Meerut in 2021 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Meerut') & (data['Timestamp'].dt.year == 2021)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Meerut 2021', width=600, height=300) return chart " 5117,Determine the state that recorded the 2nd highest average PM2.5 over the Winter season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 5118,Tabulate the monthly mean PM10 levels for Kolkata during 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Kolkata'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5119,Which city recorded the 3rd lowest 25th percentile of PM10 in April 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 5120,Show the monthly average PM10 trend for Hanumangarh from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Hanumangarh'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Hanumangarh (2019–2024)', width=600, height=300) return chart " 5121,Identify the week in 2019 that registered the third-lowest average PM2.5 levels.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'week'}}] " 5122,Identify the weekday in 2018 that registered the second-lowest 75th percentile of PM2.5 pollution levels.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'Timestamp'}}] " 5123,"Scatter plot PM2.5 vs PM10 for Karnataka stations in 2023, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Karnataka') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Karnataka Stations 2023', width=450, height=350) " 5124,Plot the weekly average PM2.5 for Muzaffarnagar in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Muzaffarnagar') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Muzaffarnagar 2023', width=600, height=300) return chart " 5125,Which city recorded the 2nd lowest average for PM2.5 in the Post-Monsoon season of 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 5126,Plot the distribution of PM2.5 values in Himachal Pradesh across all years using a histogram.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Himachal Pradesh'].dropna(subset=['PM2.5']) df = df[['PM2.5']] chart = alt.Chart(df).mark_bar(color='steelblue', opacity=0.75).encode( x=alt.X('PM2\.5:Q', bin=alt.Bin(maxbins=40), title='PM2.5 (µg/m³)'), y=alt.Y('count()', title='Number of Observations'), tooltip=[alt.Tooltip('PM2\.5:Q', bin=True), 'count()'] ).properties(title='PM2.5 Distribution – Himachal Pradesh (All Years)', width=500, height=300) return chart " 5127,"Which state with a land area below 50,000 km² shows the minimum PM2.5 level, according to its median PM2.5 level?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}] " 5128,"Scatter plot PM2.5 vs PM10 for Himachal Pradesh stations in 2019, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Himachal Pradesh') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Himachal Pradesh Stations 2019', width=450, height=350) " 5129,Show the monthly average PM2.5 for Tirupati in 2024 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Tirupati') & (data['Timestamp'].dt.year == 2024)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Tirupati 2024', width=450, height=280) " 5130,Show the monthly average PM2.5 for Patna in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Patna') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Patna 2017', width=450, height=280) " 5131,Visualize the bottom 5 states with the lowest average PM2.5 in 2024 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2024] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(5, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 5 States by Average PM2.5 in 2024', width=500, height=300) return chart " 5132,List all citys with their average PM2.5 and PM10 levels in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5133,Identify the city exhibiting the peak 25th percentile of PM2.5 during the Winter season of 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 5134,Identify the city exhibiting the 2nd highest average PM10 during the Winter season of 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 5135,Tabulate days with PM2.5 > 100 µg/m³ and exceedance percentage per city in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5136,Create a month-wise PM2.5 breakdown table across cities in Rajasthan for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Ajmer', 'Alwar', 'Bhiwadi', 'Jaipur', 'Jodhpur', 'Kota', 'Pali', 'Udaipur']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5137,"Which city showed the second-highest average PM10 on March 31, 2019?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 5138,Show the monthly average PM2.5 for Ujjain in 2022 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ujjain') & (data['Timestamp'].dt.year == 2022)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Ujjain 2022', width=450, height=280) " 5139,Show a year-wise table of average PM10 for Puducherry from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Puducherry'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5140,Show the monthly average PM2.5 for Malegaon in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Malegaon') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Malegaon 2019', width=450, height=280) " 5141,Show PM2.5 density (µg/m³ per km²) by state for 2017 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, { 'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM2.5 per km²', 'numerator': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)', 'PM2.5 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5142,Generate a city × month cross-tab of mean PM10 for Karnataka in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Bengaluru']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5143,"Compare the monthly average PM2.5 of Hajipur, Karwar, and Davanagere in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Hajipur', 'Karwar', 'Davanagere'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Hajipur vs Karwar vs Davanagere – 2024', width=550, height=320) return chart " 5144,"Create a grouped bar chart comparing the average PM2.5 for Gujarat, Mizoram, and Kerala across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Gujarat', 'Mizoram', 'Kerala'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 5145,Show the monthly average PM10 trend for Imphal from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Imphal'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Imphal (2017–2022)', width=600, height=300) return chart " 5146,Show a cumulative area chart of PM2.5 readings for Chikkaballapur across 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Chikkaballapur') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Chikkaballapur 2018', width=600, height=300) return chart " 5147,Tabulate daily PM2.5 exceedances (above 100 µg/m³) per city for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5148,Which 15 citys had the lowest mean PM10 in 2019? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 5149,Which station had the 2nd lowest average PM10 in March 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 5150,Show a pivot table of monthly average PM10 by city for West Bengal in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'West Bengal'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Asansol', 'Durgapur', 'Howrah', 'Kolkata', 'Siliguri']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5151,Show a pivot table of monthly average PM2.5 by city for Haryana in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Haryana'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Faridabad', 'Gurugram', 'Panchkula']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5152,Show a monthly bar chart of the number of days West Bengal exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'West Bengal') & (data['Timestamp'].dt.year == 2021)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days West Bengal Exceeded WHO PM2.5 Guideline per Month – 2021', width=500, height=300) return chart " 5153,"Visualize the monthly average PM10 for Assam, Madhya Pradesh, and Andhra Pradesh in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Assam', 'Madhya Pradesh', 'Andhra Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Assam, Madhya Pradesh, UP – 2022', width=550, height=320) return chart " 5154,Tabulate daily PM2.5 exceedances (above 60 µg/m³) per state for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5155,Which city registered the 2nd minimum median PM10 in the Monsoon season of 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 5156,"Visualize the monthly average PM10 for Bihar, Jharkhand, and Karnataka in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Bihar', 'Jharkhand', 'Karnataka'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Bihar, Jharkhand, UP – 2024', width=550, height=320) return chart " 5157,"Visualize the monthly average PM10 for Tamil Nadu, Delhi, and Sikkim in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Delhi', 'Sikkim'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Tamil Nadu, Delhi, UP – 2022', width=550, height=320) return chart " 5158,Tabulate daily PM10 exceedances (above 150 µg/m³) per city for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5159,"Visualize the monthly average PM10 for Maharashtra, Jharkhand, and Manipur in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Maharashtra', 'Jharkhand', 'Manipur'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Maharashtra, Jharkhand, UP – 2023', width=550, height=320) return chart " 5160,Show a heatmap of average PM2.5 for the top 6 most polluted states by month for 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(6).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 6 Polluted States by Month (2022)', width=500, height=300) return chart " 5161,Show a bar chart of the top 10 cities by median PM2.5 in 2020.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2020] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(10, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 10 Cities by Median PM2.5 in 2020', width=500, height=300) return chart " 5162,Create a heatmap showing the average PM2.5 by month (x-axis) and year (y-axis) for Andhra Pradesh.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Andhra Pradesh'].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Year:N', title='Year'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='Avg PM2.5'), tooltip=['Year:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Andhra Pradesh (Month × Year)', width=500, height=280) return chart " 5163,Tabulate average PM10 for each city in Maharashtra across all months of 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Aurangabad', 'Chandrapur', 'Kalyan', 'Mumbai', 'Nagpur', 'Nashik', 'Navi Mumbai', 'Pune', 'Solapur', 'Thane']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5164,Plot the rolling 30-day average PM2.5 for Nagaland in 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Nagaland') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Nagaland 2022', width=600, height=300) " 5165,Determine the station exhibiting the 2nd lowest 75th percentile of PM2.5 in July 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 5166,Tabulate the top 5 states for PM2.5 in 2017 along with their corresponding PM10 values.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 5167,Identify the state with the 2nd lowest average PM2.5 for March 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 5168,Show a monthly bar chart of the number of days Uttar Pradesh exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Uttar Pradesh') & (data['Timestamp'].dt.year == 2024)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Uttar Pradesh Exceeded WHO PM2.5 Guideline per Month – 2024', width=500, height=300) return chart " 5169,Which state exhibited the third smallest decrease in its 75th percentile PM10 levels between October and December of 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 5170,"In April 2021, which city registered the 2nd highest 25th percentile of PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 5171,List average PM2.5 by month for Jammu and Kashmir in 2024 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Jammu and Kashmir'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5172,"Create a comprehensive state summary with PM10, population, and area for 2019."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5173,Create a ranked table of the 5 best-performing states by PM10 in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 5174,Which 10 states had the lowest mean PM10 in 2017? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 5175,Which city received the 3rd highest NCAP funding relative to the standard deviation of its PM2.5 concentration in 2021 (FY 2020-21)?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'std', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 5176,Create a month-wise PM2.5 breakdown table across cities in Tamil Nadu for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Chennai']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5177,Create a table showing annual mean PM10 levels for Bhopal (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Bhopal'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5178,Identify the station with the 3rd lowest 75th percentile of PM2.5 in April 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 5179,Tabulate both PM2.5 and PM10 averages by state for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5180,"Identify the station that recorded the third-highest average PM10 level on January 5, 2020."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 5181,"On January 5, 2024, which city had the second-highest average PM10 reading?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 5182,Plot the weekly average PM2.5 for Noida in 2017 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Noida') & (data['Timestamp'].dt.year == 2017)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Noida 2017', width=600, height=300) return chart " 5183,Show the monthly average PM10 trend for Virudhunagar from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Virudhunagar'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Virudhunagar (2019–2024)', width=600, height=300) return chart " 5184,"On January 14, 2023, which city experienced the second-highest PM10 measurements?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 5185,"Show the variability of PM10 across citys in 2024 using mean, median, and standard deviation."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5186,"On March 31, 2021, which state recorded the third-lowest median PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 5187,Generate a city × month cross-tab of mean PM10 for Uttar Pradesh in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Ghaziabad', 'Moradabad', 'Noida', 'Varanasi']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5188,How many times did Singrauli city go above 30 µg/m³ of PM10 in 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 30.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 5189,Which 15 citys recorded the highest average PM10 levels in 2022? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 5190,Plot the rolling 30-day average PM2.5 for Manipur in 2017 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Manipur') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Manipur 2017', width=600, height=300) " 5191,Report the union territory exhibiting the 3rd highest standard deviation of PM2.5 concentration when considering population density.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'std', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_capita', 'numerator': 'PM2.5', 'denominator': 'population'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'pm_per_capita', 'ascending': False}}] " 5192,Tabulate average PM10 for each city in Andhra Pradesh across all months of 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Amaravati', 'Rajamahendravaram', 'Tirupati', 'Visakhapatnam']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5193,Show a table of the 5 cleanest states by average PM10 in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 5194,Show PM10 exceedance count and rate (%) above 150 µg/m³ per city in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 150'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5195,Show a pivot table of monthly average PM2.5 by city for Tamil Nadu in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Chennai', 'Coimbatore', 'Gummidipoondi']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5196,"Identify the state (excluding UTs) with the 3rd smallest population among the top 10 most polluted states, based on average PM2.5 levels."," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 10, 'ret': 'state'}}] " 5197,"Plot the yearly average PM2.5 trends for Nagaland, Andhra Pradesh, and Gujarat from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Nagaland', 'Andhra Pradesh', 'Gujarat'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Nagaland vs Andhra Pradesh vs Gujarat', width=550, height=320) return chart " 5198,Show a table of the 10 cleanest states by average PM10 in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 5199,"In the year 2022, which week recorded the second-highest 75th percentile for PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'week'}}] " 5200,Create a summary table ranking the top 10 citys by PM10 concentration in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 5201,"Plot the yearly average PM2.5 trends for Jharkhand, Jammu and Kashmir, and Arunachal Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Jammu and Kashmir', 'Arunachal Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Jharkhand vs Jammu and Kashmir vs Arunachal Pradesh', width=550, height=320) return chart " 5202,Show a cumulative area chart of PM2.5 readings for Gummidipoondi across 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Gummidipoondi') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Gummidipoondi 2023', width=600, height=300) return chart " 5203,Show a pivot table of monthly average PM2.5 by city for Tamil Nadu in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Chennai', 'Gummidipoondi']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5204,Which state recorded the lowest median PM2.5 figure in June 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 5205,"Create a faceted bar chart showing top 12 states by average PM2.5 per year for 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year.isin([2017,2018,2019,2020])].copy() df['Year'] = df['Timestamp'].dt.year agg = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() top = agg.groupby('Year').apply(lambda x: x.nlargest(12,'PM2.5')).reset_index(drop=True) chart = alt.Chart(top).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Avg PM2.5'), y=alt.Y('state:N', sort='-x'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet(facet='Year:O', columns=2).properties(title='Top 12 States by PM2.5 per Year') return chart " 5206,Identify the city with the 3rd lowest 75th percentile of PM10 for September 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 5207,Which state exhibits the 2nd highest 75th percentile of PM10 concentration when considering population density?," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_capita', 'numerator': 'PM10', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'pm_per_capita', 'ascending': False}}] " 5208,Create a table showing PM2.5 levels and population for each state in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5209,Show the monthly average PM2.5 for Kishanganj in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Kishanganj') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Kishanganj 2018', width=450, height=280) " 5210,Show a ranked table of the 10 most polluted citys by average PM10 in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 5211,List the average PM10 for Assam broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Assam'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5212,Plot the rolling 30-day average PM2.5 for Sikkim in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Sikkim') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Sikkim 2024', width=600, height=300) " 5213,Plot the top 11 states by average PM2.5 in 2021 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2021] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(11, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 11 States by Average PM2.5 in 2021', width=500, height=300) return chart " 5214,Identify the station that showed the second highest median PM2.5 during the Summer season of 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 5215,"Report the state (excluding UTs) having the 3rd largest population within the top 5 most polluted states, when pollution is measured by median PM10 levels."," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 5, 'ret': 'state'}}] " 5216,Show the monthly average PM2.5 for Chandigarh across each year from 2017 to 2024 as small multiples (faceted by year).," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Chandigarh'].copy() df['Year'] = df['Timestamp'].dt.year df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5'), tooltip=['Year:O','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet( facet=alt.Facet('Year:O', title='Year'), columns=4 ).properties(title='Monthly PM2.5 in Chandigarh by Year (2017–2024)') return chart " 5217,Plot the rolling 30-day average PM2.5 for Gujarat in 2019 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Gujarat') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Gujarat 2019', width=600, height=300) " 5218,"Scatter plot PM2.5 vs PM10 for Andhra Pradesh stations in 2024, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Andhra Pradesh') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Andhra Pradesh Stations 2024', width=450, height=350) " 5219,What date over the last three years noted Chhal's highest PM2.5 reading?," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 3}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'Timestamp'}}] " 5220,Show annual average PM2.5 for Noida as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Noida'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5221,Show a heatmap of average PM2.5 for the top 10 most polluted states by month for 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(10).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 10 Polluted States by Month (2024)', width=500, height=300) return chart " 5222,"Tabulate PM2.5 statistics (mean, std, min, max) for each state in 2024."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5223,"During 2024, which week saw the second-highest 75th percentile for PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'week'}}] " 5224,List average PM2.5 by month for Andhra Pradesh in 2017 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5225,Show the monthly average PM2.5 for Nanded in 2022 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Nanded') & (data['Timestamp'].dt.year == 2022)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Nanded 2022', width=450, height=280) " 5226,"Create a faceted bar chart showing top 5 states by average PM2.5 per year for 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year.isin([2021,2022,2023,2024])].copy() df['Year'] = df['Timestamp'].dt.year agg = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() top = agg.groupby('Year').apply(lambda x: x.nlargest(5,'PM2.5')).reset_index(drop=True) chart = alt.Chart(top).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Avg PM2.5'), y=alt.Y('state:N', sort='-x'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet(facet='Year:O', columns=2).properties(title='Top 5 States by PM2.5 per Year') return chart " 5227,Show a cumulative area chart of PM2.5 readings for Srinagar across 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Srinagar') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Srinagar 2023', width=600, height=300) return chart " 5228,Show the monthly average PM2.5 for Perundurai in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Perundurai') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Perundurai 2019', width=450, height=280) " 5229,Show the monthly average PM2.5 for Ulhasnagar in 2024 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ulhasnagar') & (data['Timestamp'].dt.year == 2024)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Ulhasnagar 2024', width=450, height=280) " 5230,Which state showed the 3rd lowest average for PM2.5 in the Post-Monsoon season of 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 5231,Plot the weekly average PM2.5 for Pune in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Pune') & (data['Timestamp'].dt.year == 2020)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Pune 2020', width=600, height=300) return chart " 5232,Determine the state exhibiting the highest average PM2.5 in January 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 5233,Show the monthly average PM2.5 for Kolhapur in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Kolhapur') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Kolhapur 2017', width=450, height=280) " 5234,Identify the city that recorded the highest average PM2.5 value in March 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 5235,Which city had the highest 25th percentile of PM10 in October 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 5236,List average PM2.5 by month for Gandhinagar in 2019 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Gandhinagar'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5237,Create a table of PM10 per unit area for all states in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM10 per km²', 'numerator': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)', 'PM10 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5238,Create a table showing annual mean PM2.5 levels for Pune (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Pune'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5239,Generate a city × month cross-tab of mean PM2.5 for Uttar Pradesh in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Agra', 'Bulandshahr', 'Firozabad', 'Ghaziabad', 'Gorakhpur', 'Greater Noida', 'Hapur', 'Kanpur', 'Lucknow', 'Meerut', 'Moradabad', 'Muzaffarnagar', 'Noida', 'Prayagraj', 'Varanasi', 'Vrindavan']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5240,Generate a city × month cross-tab of mean PM10 for West Bengal in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'West Bengal'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Asansol', 'Durgapur', 'Haldia', 'Howrah', 'Kolkata', 'Siliguri']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5241,"Which union territory has the 2nd minimum land area among the top 2 most polluted union territories, according to average PM2.5 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 2, 'ret': 'state'}}] " 5242,"Identify the station with the second-lowest PM2.5 values on January 14, 2021."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 5243,Show a monthly bar chart of the number of days Madhya Pradesh exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Madhya Pradesh') & (data['Timestamp'].dt.year == 2023)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Madhya Pradesh Exceeded WHO PM2.5 Guideline per Month – 2023', width=500, height=300) return chart " 5244,Show PM2.5 exceedances above the Indian standard (60 µg/m³) per year as a bar chart for Tamil Nadu.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Tamil Nadu'].dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 60].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby('Year')['Timestamp'].nunique().reset_index() df.columns = ['Year','Days Exceeded'] chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('Year:N', title='Year'), y=alt.Y('Days Exceeded:Q', title='Days PM2.5 > 60 µg/m³'), tooltip=['Year:N','Days Exceeded:Q'] ).properties(title='Days Tamil Nadu Exceeded Indian PM2.5 Standard (60 µg/m³) per Year', width=450, height=300) return chart " 5245,List the bottom 20 states with the lowest average PM10 in 2024 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 5246,List the top 20 citys by PM2.5 in 2017 with both PM2.5 and PM10 averages.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 5247,Show the monthly average PM10 trend for Hosur from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Hosur'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Hosur (2019–2024)', width=600, height=300) return chart " 5248,List states ranked by PM2.5 concentration relative to their area in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, { 'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM2.5 per km²', 'numerator': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)', 'PM2.5 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5249,Which state recorded the highest average PM10 concentration for April 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 5250,Which station recorded the peak average PM2.5 during the Winter season of 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 5251,Tabulate average PM2.5 for each state across all months in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Delhi', 'Gujarat', 'Haryana', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Meghalaya', 'Odisha', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5252,Tabulate the 20 states with the least PM2.5 pollution in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 5253,"Plot the yearly average PM2.5 trends for Rajasthan, Jharkhand, and Puducherry from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Jharkhand', 'Puducherry'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Rajasthan vs Jharkhand vs Puducherry', width=550, height=320) return chart " 5254,How many times did Bangalore city exceed 75 µg/m³ of PM10 in the year 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 75.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 5255,List states with their PM10 violation count and rate (>150 µg/m³) in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 150'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5256,Generate a cross-tab of state vs month for average PM2.5 in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Bihar', 'Delhi', 'Haryana', 'Karnataka', 'Maharashtra', 'Tamil Nadu', 'Telangana', 'Uttar Pradesh']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5257,Plot the rolling 30-day average PM2.5 for Odisha in 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Odisha') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Odisha 2022', width=600, height=300) " 5258,Which union territory was the 2nd most polluted based on per capita PM10 exposure during 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'COMPUTE', 'params': {'new_col': 'per_capita_pm', 'numerator': 'PM10', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'per_capita_pm', 'ascending': False}}] " 5259,Create a ranked table of the 20 best-performing citys by PM10 in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 5260,Tabulate days with PM2.5 > 60 µg/m³ and exceedance percentage per state in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5261,"Plot the yearly average PM2.5 trends for Chandigarh, Kerala, and Gujarat from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chandigarh', 'Kerala', 'Gujarat'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Chandigarh vs Kerala vs Gujarat', width=550, height=320) return chart " 5262,Show a cumulative area chart of PM2.5 readings for Ahmednagar across 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ahmednagar') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Ahmednagar 2023', width=600, height=300) return chart " 5263,Show PM2.5 exceedance count and rate (%) above 100 µg/m³ per city in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5264,Generate a city × month cross-tab of mean PM10 for Madhya Pradesh in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Bhopal', 'Damoh', 'Dewas', 'Gwalior', 'Indore', 'Jabalpur', 'Katni', 'Maihar', 'Mandideep', 'Pithampur', 'Ratlam', 'Sagar', 'Satna', 'Singrauli', 'Ujjain']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5265,Create a statistical summary table of PM10 readings by state for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5266,Show the monthly average PM2.5 for Thoothukudi in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Thoothukudi') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Thoothukudi 2019', width=450, height=280) " 5267,Show a table of the 5 cleanest states by average PM2.5 in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 5268,Which station showed the third-lowest 25th percentile for PM2.5 in May 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 5269,Tabulate average PM2.5 for each city in Kerala across all months of 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Eloor', 'Kannur', 'Kochi', 'Kollam', 'Kozhikode', 'Thiruvananthapuram', 'Thrissur']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5270,Report the state that had the 2nd lowest 75th percentile of PM10 in July 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 5271,"List each state's average PM2.5, PM10, and how many stations it has in 2021."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}, {'alias': 'Station Count', 'col': 'station', 'fn': 'nunique'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5272,Show how many times PM10 exceeded 100 µg/m³ per day across citys in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5273,Which 20 citys recorded the highest average PM10 levels in 2021? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 5274,Determine the state exhibiting the lowest average PM10 in August 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 5275,Identify the state that saw the least significant fall in average PM10 levels when comparing December 2019 to October 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 5276,List the average PM2.5 for Himachal Pradesh broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Himachal Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5277,Create a statistical summary table of PM10 readings by city for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5278,Show PM10 exceedance count and rate (%) above 100 µg/m³ per city in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5279,"Create a comprehensive state summary with PM2.5, population, and area for 2020."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': { 'map': { 'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5280,Determine the average PM10 level on Tuesdays in Assam.," [{'op': 'FILTER', 'params': {'field': 'state', 'value': 'Assam'}}] " 5281,"Scatter plot PM2.5 vs PM10 for Telangana stations in 2017, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Telangana') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Telangana Stations 2017', width=450, height=350) " 5282,"In May 2021, which state recorded the highest 75th percentile of PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 5283,Create a month-wise summary of average PM10 for Madhya Pradesh in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5284,Show the monthly average PM2.5 for Jalore in 2022 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Jalore') & (data['Timestamp'].dt.year == 2022)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Jalore 2022', width=450, height=280) " 5285,"Which state having a land area exceeding 50,000 km² registers the 5th minimum PM10 level, based on its variance of PM10 level?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'var', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}] " 5286,Plot the weekly average PM2.5 for Pali in 2017 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Pali') & (data['Timestamp'].dt.year == 2017)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Pali 2017', width=600, height=300) return chart " 5287,"Visualize the monthly average PM10 for Maharashtra, West Bengal, and Tamil Nadu in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Maharashtra', 'West Bengal', 'Tamil Nadu'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Maharashtra, West Bengal, UP – 2022', width=550, height=320) return chart " 5288,Plot the rolling 30-day average PM2.5 for Delhi in 2018 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Delhi') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Delhi 2018', width=600, height=300) " 5289,Create a month-wise PM10 breakdown table across cities in Bihar for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Bihar'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Patna']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5290,Which station registered the 2nd maximum 25th percentile of PM2.5 in the Monsoon season of 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 5291,Which station showed the 3rd lowest average for PM10 in the Summer season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 5292,"Plot the yearly average PM2.5 trends for Haryana, Karnataka, and Meghalaya from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Karnataka', 'Meghalaya'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Haryana vs Karnataka vs Meghalaya', width=550, height=320) return chart " 5293,Show a table of the 15 cleanest states by average PM10 in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 5294,"In August 2021, report the state with the 3rd highest 25th percentile of PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 5295,"In November 2018, report the station with the 3rd lowest median PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 5296,"Which state (excluding Union Territories) has the 3rd minimum land area among the top 10 most polluted states, according to average PM2.5 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 10, 'ret': 'state'}}] " 5297,Generate a year-by-year summary table of PM10 readings for Kanpur.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Kanpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5298,Show PM2.5 exceedances above the Indian standard (60 µg/m³) per year as a bar chart for Jammu and Kashmir.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Jammu and Kashmir'].dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 60].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby('Year')['Timestamp'].nunique().reset_index() df.columns = ['Year','Days Exceeded'] chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('Year:N', title='Year'), y=alt.Y('Days Exceeded:Q', title='Days PM2.5 > 60 µg/m³'), tooltip=['Year:N','Days Exceeded:Q'] ).properties(title='Days Jammu and Kashmir Exceeded Indian PM2.5 Standard (60 µg/m³) per Year', width=450, height=300) return chart " 5299,Visualize the bottom 8 states with the lowest average PM2.5 in 2020 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2020] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(8, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 8 States by Average PM2.5 in 2020', width=500, height=300) return chart " 5300,Generate a table showing the 20 most polluted states based on mean PM2.5 for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 5301,"Show the top 12 states by average PM10 in 2023 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2023] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(12, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 12 States by Average PM10 in 2023', width=500, height=300) return chart " 5302,"Create a grouped bar chart comparing the average PM2.5 for Kerala, Chandigarh, and Gujarat across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Kerala', 'Chandigarh', 'Gujarat'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 5303,Which station experienced the second least significant drop in its 25th percentile PM2.5 levels between October and December 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 5304,How many times did Ghaziabad city go above 30 µg/m³ of PM2.5 in 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 30.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 5305,"Which state with a land area below 50,000 km² shows the highest PM2.5 level, according to its median PM2.5 level?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}] " 5306,How many times did Lucknow city go above the Indian guideline for PM2.5 in 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 60.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 5307,Report which station registered the 3rd highest average PM2.5 throughout the Post-Monsoon season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 5308,Which 10 citys had the lowest mean PM2.5 in 2022? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 5309,Identify the station that registered the second-highest average PM2.5 in November 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 5310,"Throughout all New Year's Eves, which state registered the second-lowest PM2.5 concentrations?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 5311,Show a cumulative area chart of PM2.5 readings for Kota across 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Kota') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Kota 2021', width=600, height=300) return chart " 5312,Create a month-wise PM10 breakdown table across cities in Gujarat for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Gujarat'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Ahmedabad', 'Ankleshwar', 'Gandhinagar', 'Nandesari', 'Vapi', 'Vatva']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5313,Which state ranked as the 3rd least polluted based on per capita PM10 exposure during 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'per_capita_pm', 'numerator': 'PM10', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'per_capita_pm', 'ascending': True}}] " 5314,"Create a grouped bar chart comparing the average PM2.5 for Punjab, Andhra Pradesh, and Bihar across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Punjab', 'Andhra Pradesh', 'Bihar'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 5315,"Create a grouped bar chart comparing the average PM2.5 for Gujarat, Himachal Pradesh, and Odisha across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Gujarat', 'Himachal Pradesh', 'Odisha'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 5316,List citys with their PM10 violation count and rate (>100 µg/m³) in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5317,Which station had the 3rd highest 75th percentile of PM2.5 in June 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 5318,Show a bar chart of the top 12 cities by median PM2.5 in 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2023] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(12, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 12 Cities by Median PM2.5 in 2023', width=500, height=300) return chart " 5319,Which station had the 2nd highest 25th percentile of PM2.5 in October 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 5320,Which 10 citys had the lowest mean PM2.5 in 2017? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 5321,Which city recorded the 3rd highest median PM2.5 in January 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 5322,"Identify the state with the third-highest average PM10 level on January 5, 2021."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 5323,Generate a table showing the 15 most polluted states based on mean PM2.5 for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 5324,"Create a table showing top 5 citys ranked by PM2.5 in 2022, also showing PM10."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 5325,Which city possessed the 3rd lowest 25th percentile for PM2.5 in the Summer season of 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 5326,Show the monthly average PM2.5 for Yadgir in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Yadgir') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Yadgir 2020', width=450, height=280) " 5327,Tabulate days with PM10 > 150 µg/m³ and exceedance percentage per city in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 150'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5328,Show a monthly breakdown table of average PM2.5 for Jammu and Kashmir in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Jammu and Kashmir'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5329,"Compare the monthly average PM2.5 of Dhanbad, Raipur, and Kota in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Dhanbad', 'Raipur', 'Kota'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Dhanbad vs Raipur vs Kota – 2022', width=550, height=320) return chart " 5330,Generate a city × month cross-tab of mean PM2.5 for Kerala in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Thiruvananthapuram']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5331,How many times did Vijayapura city surpass 90 µg/m³ of PM10 in 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 90.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 5332,Create a month-wise summary of average PM2.5 for Kerala in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5333,Tabulate the top 5 citys for PM2.5 in 2018 along with their corresponding PM10 values.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 5334,Report the station that had the highest 25th percentile of PM10 in December 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 5335,"Create a grouped bar chart comparing the average PM2.5 for Kerala, Bihar, and Mizoram across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Kerala', 'Bihar', 'Mizoram'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 5336,"Plot the yearly average PM2.5 trends for Uttarakhand, Maharashtra, and Rajasthan from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttarakhand', 'Maharashtra', 'Rajasthan'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Uttarakhand vs Maharashtra vs Rajasthan', width=550, height=320) return chart " 5337,"During 2020, which weekday saw the lowest 25th percentile of PM2.5 pollution levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'Timestamp'}}] " 5338,"In 2018, which state ranked with the third largest decrease in average PM10 levels from October to December?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 5339,"Create a grouped bar chart comparing the average PM2.5 for Jammu and Kashmir, Tamil Nadu, and Haryana across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jammu and Kashmir', 'Tamil Nadu', 'Haryana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 5340,"Visualize the monthly average PM10 for Bihar, Kerala, and Chhattisgarh in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Bihar', 'Kerala', 'Chhattisgarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Bihar, Kerala, UP – 2023', width=550, height=320) return chart " 5341,Show the monthly average PM2.5 for Manesar in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Manesar') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Manesar 2019', width=450, height=280) " 5342,Show a year-wise table of average PM10 for Prayagraj from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Prayagraj'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5343,Tabulate average PM2.5 for each city in Karnataka across all months of 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Bengaluru']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5344,Show a monthly breakdown table of average PM10 for Madhya Pradesh in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5345,"Plot the yearly average PM2.5 trends for Tripura, Karnataka, and Bihar from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tripura', 'Karnataka', 'Bihar'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Tripura vs Karnataka vs Bihar', width=550, height=320) return chart " 5346,"Identify the station with the peak PM2.5 measurements on January 14, 2022."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 5347,"Which station showed the minimum 25th percentile for PM10 on March 31, 2019?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 5348,"Which state (excluding Union Territories) possesses the 3rd largest land area among the top 3 most polluted states, based on the variance of PM10 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'var', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 3, 'ret': 'state'}}] " 5349,Identify the station with the third-highest average PM10 in May 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 5350,Create a month-wise PM2.5 breakdown table across cities in Karnataka for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Bengaluru']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5351,"Which state (excluding Union Territories) has the largest land area among the top 5 most polluted states, according to the 75th percentile of PM10 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 5, 'ret': 'state'}}] " 5352,"Create a grouped bar chart comparing the average PM2.5 for Andhra Pradesh, Madhya Pradesh, and Himachal Pradesh across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Madhya Pradesh', 'Himachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 5353,"Which state (excluding Union Territories) possesses the 2nd largest land area among the top 10 most polluted states, based on the variance of PM2.5 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'var', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 10, 'ret': 'state'}}] " 5354,Which 10 citys had the lowest mean PM2.5 in 2023? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 5355,Plot the weekly average PM2.5 for Talcher in 2021 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Talcher') & (data['Timestamp'].dt.year == 2021)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Talcher 2021', width=600, height=300) return chart " 5356,Create a ranked table of the 5 best-performing states by PM10 in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 5357,Tabulate the 15 worst citys for average PM2.5 in 2024 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 5358,Generate a monthly average PM10 table for Maharashtra for the year 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5359,"Plot the yearly average PM2.5 trends for Chandigarh, Telangana, and Delhi from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chandigarh', 'Telangana', 'Delhi'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Chandigarh vs Telangana vs Delhi', width=550, height=320) return chart " 5360,Generate a descriptive stats table for PM10 grouped by city in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5361,Tabulate mean PM2.5 alongside state population figures for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5362,List the bottom 5 citys with the lowest average PM2.5 in 2020 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 5363,Create a ranked table of the 10 best-performing citys by PM10 in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 5364,"Compare the monthly average PM2.5 of Araria, Chamarajanagar, and Gummidipoondi in 2020 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Araria', 'Chamarajanagar', 'Gummidipoondi'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2020)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Araria vs Chamarajanagar vs Gummidipoondi – 2020', width=550, height=320) return chart " 5365,Show the monthly average PM10 trend for Begusarai from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Begusarai'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Begusarai (2019–2024)', width=600, height=300) return chart " 5366,Tabulate mean PM10 and land area for each state in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5367,Plot the rolling 30-day average PM2.5 for Assam in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Assam') & (data['Timestamp'].dt.year == 2020)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Assam 2020', width=600, height=300) " 5368,"Create a table showing top 10 citys ranked by PM2.5 in 2018, also showing PM10."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 5369,Show the monthly average PM2.5 for Purnia in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Purnia') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Purnia 2018', width=450, height=280) " 5370,Which city had the third-highest mean PM10 concentration in February 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 5371,Which week in 2020 was linked to the third-highest average PM10 levels?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'week'}}] " 5372,"Create a grouped bar chart comparing the average PM2.5 for Andhra Pradesh, Bihar, and Tamil Nadu across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Bihar', 'Tamil Nadu'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 5373,"Visualize the monthly average PM10 for Gujarat, Karnataka, and Kerala in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Gujarat', 'Karnataka', 'Kerala'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Gujarat, Karnataka, UP – 2017', width=550, height=320) return chart " 5374,Which station had the 3rd highest 75th percentile of PM2.5 in February 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 5375,Show a table of the top 15 states by average PM2.5 in 2019 including their PM10 levels too.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 5376,Tabulate the yearly average PM2.5 trend for Moradabad across all years.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Moradabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5377,"Identify the state that showed the second-highest PM2.5 readings on January 14, 2019."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 5378,Show the monthly average PM10 trend for Greater Noida from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Greater Noida'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Greater Noida (2019–2024)', width=600, height=300) return chart " 5379,Which 20 states had the lowest mean PM10 in 2022? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 5380,Which station had the 2nd highest median PM10 in May 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 5381,Which city registered the highest average PM2.5 during December 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 5382,Which state had the highest average PM2.5 in March 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 5383,"Show the mean, median and standard deviation of PM10 per city in 2023 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5384,Show how many times PM2.5 exceeded 60 µg/m³ per day across citys in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5385,"Report the union territory having the second smallest population among the top 4 most polluted union territories, when pollution is measured by 25th percentile of PM2.5 levels."," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 4, 'ret': 'state'}}] " 5386,Which city recorded the minimum 75th percentile of PM10 in the Monsoon season of 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 5387,Create a month-wise PM10 breakdown table across cities in Kerala for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Eloor', 'Ernakulam', 'Kannur', 'Kochi', 'Kollam', 'Kozhikode', 'Thiruvananthapuram', 'Thrissur']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5388,Show a bar chart of the top 9 cities by median PM2.5 in 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2018] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(9, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 9 Cities by Median PM2.5 in 2018', width=500, height=300) return chart " 5389,Which state experienced the second most significant drop in its median PM10 levels between October and December 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 5390,Create a month-wise summary of average PM10 for Mizoram in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Mizoram'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5391,"On March 31, 2019, which station had the third-highest median PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 5392,Show a pivot table of monthly average PM2.5 by city for Maharashtra in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Aurangabad', 'Chandrapur', 'Mumbai', 'Nagpur', 'Nashik', 'Pune', 'Solapur']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5393,"For November 2020 relative to November 2019, which station had the most substantial increase in its 75th percentile PM2.5 level?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 5394,Show the monthly average PM10 trend for Ariyalur from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Ariyalur'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Ariyalur (2019–2024)', width=600, height=300) return chart " 5395,"Visualize the monthly average PM10 for Punjab, Jammu and Kashmir, and Gujarat in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Punjab', 'Jammu and Kashmir', 'Gujarat'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Punjab, Jammu and Kashmir, UP – 2019', width=550, height=320) return chart " 5396,Show a year-wise table of average PM10 for Telangana from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Telangana'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5397,"Scatter plot PM2.5 vs PM10 for Mizoram stations in 2018, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Mizoram') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Mizoram Stations 2018', width=450, height=350) " 5398,Identify the city that recorded the highest 25th percentile of PM10 value in November 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 5399,"Tabulate the distribution of PM2.5 per state in 2021 including mean, median, and std."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5400,Show how average PM2.5 varied month by month for Gurugram in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Gurugram'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5401,Tabulate the 10 worst citys for average PM2.5 in 2018 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 5402,Show a table of the 20 cleanest citys by average PM2.5 in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 5403,"Tabulate PM10 statistics (mean, std, min, max) for each state in 2022."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'q25', 'median', 'q75']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5404,"Comparing December 2023 to October 2023, which state showed the third least significant drop in 25th percentile PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 5405,Show a table of the top 15 citys by average PM2.5 in 2021 including their PM10 levels too.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 5406,Show a bar chart of the top 15 cities by median PM2.5 in 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2024] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(15, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 15 Cities by Median PM2.5 in 2024', width=500, height=300) return chart " 5407,Show a pivot table of monthly average PM2.5 by state for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Bihar', 'Delhi', 'Haryana', 'Karnataka', 'Maharashtra', 'Tamil Nadu', 'Telangana', 'Uttar Pradesh']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5408,Tabulate average PM2.5 for each city in Uttar Pradesh across all months of 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Agra', 'Baghpat', 'Bareilly', 'Bulandshahr', 'Firozabad', 'Ghaziabad', 'Gorakhpur', 'Greater Noida', 'Hapur', 'Jhansi', 'Kanpur', 'Khurja', 'Lucknow', 'Meerut', 'Moradabad', 'Muzaffarnagar', 'Noida', 'Prayagraj', 'Varanasi', 'Vrindavan']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5409,Create a month-wise PM2.5 breakdown table across cities in Bihar for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Bihar'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Araria', 'Arrah', 'Bettiah', 'Bhagalpur', 'Bihar Sharif', 'Chhapra', 'Darbhanga', 'Gaya', 'Hajipur', 'Katihar', 'Kishanganj', 'Manguraha', 'Motihari', 'Munger', 'Muzaffarpur', 'Patna', 'Purnia', 'Rajgir', 'Saharsa', 'Sasaram', 'Siwan']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5410,"Show mean, median, minimum, and maximum PM2.5 for each state in 2019 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5411,Identify the state that registered the second most minimal average PM10 historically.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 5412,"Create a grouped bar chart comparing the average PM2.5 for Haryana, Manipur, and Assam across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Manipur', 'Assam'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 5413,Tabulate average PM10 for each city in Odisha across all months of 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Odisha'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Baripada', 'Bileipada', 'Brajrajnagar', 'Keonjhar', 'Nayagarh', 'Rourkela', 'Suakati', 'Talcher', 'Tensa']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5414,Generate a year-by-year summary table of PM2.5 readings for Nagpur.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Nagpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5415,Show a monthly bar chart of the number of days Punjab exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Punjab') & (data['Timestamp'].dt.year == 2018)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Punjab Exceeded WHO PM2.5 Guideline per Month – 2018', width=500, height=300) return chart " 5416,"Create a grouped bar chart comparing the average PM2.5 for Arunachal Pradesh, Chhattisgarh, and Tripura across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Arunachal Pradesh', 'Chhattisgarh', 'Tripura'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 5417,List the top 20 states by PM2.5 in 2021 with both PM2.5 and PM10 averages.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 5418,Show a table of average PM2.5 and PM10 for all states in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5419,Which city registered the highest median PM10 during March 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 5420,Show a table of the 10 cleanest states by average PM2.5 in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 5421,Show average PM2.5 per state in 2022 with area in km².," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5422,"Tabulate PM10 statistics (mean, std, min, max) for each state in 2020."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5423,Show a bar chart of the top 9 cities by median PM2.5 in 2019.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2019] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(9, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 9 Cities by Median PM2.5 in 2019', width=500, height=300) return chart " 5424,Generate a city × month cross-tab of mean PM2.5 for Bihar in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Bihar'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Muzaffarpur', 'Patna']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5425,Determine which city experienced the 4th highest decrease in funding between FY 2019-20 and FY 2021-22.," [{'op': 'AGG', 'params': {'by': 'city', 'fn': 'sum', 'col': 'change'}}, {'op': 'SORT', 'params': {'col': 'change', 'ascending': False}}] " 5426,Which Indian station recorded the minimum PM2.5 levels for a single day in the past decade?," [{'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'count'}}, {'op': 'SORT', 'params': {'col': 'count', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 5427,Report the city that received the 5th highest NCAP funding relative to its total PM10 concentration in 2021 (FY 2020-21).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'sum', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 5428,"Identify the city with the highest 25th percentile for PM2.5 on March 31, 2019."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 5429,Tabulate average PM2.5 for each city in Gujarat across all months of 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Gujarat'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Ahmedabad', 'Ankleshwar', 'Gandhinagar', 'Nandesari', 'Vatva']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5430,Create a heatmap showing the average PM2.5 by state and year from 2017 to 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_rect().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='plasma'), title='Avg PM2.5'), tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Average PM2.5 Heatmap by State and Year', width=500, height=400) return chart " 5431,"Tabulate the distribution of PM2.5 per state in 2023 including mean, median, and std."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5432,Show a table of average PM10 per state in 2022 along with population.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5433,"Across all recorded years, which February had the third-lowest median PM10 levels?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'Timestamp'}}] " 5434,"Show mean, median, minimum, and maximum PM2.5 for each state in 2022 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'q25', 'median', 'q75']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5435,Show the monthly average PM2.5 for Dausa in 2022 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Dausa') & (data['Timestamp'].dt.year == 2022)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Dausa 2022', width=450, height=280) " 5436,Visualize the bottom 8 states with the lowest average PM2.5 in 2019 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2019] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(8, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 8 States by Average PM2.5 in 2019', width=500, height=300) return chart " 5437,"Create a table showing top 5 citys ranked by PM2.5 in 2019, also showing PM10."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 5438,Show a cumulative area chart of PM2.5 readings for Bidar across 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bidar') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Bidar 2023', width=600, height=300) return chart " 5439,Identify the city with the highest median PM10 for July 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 5440,Identify the state that recorded the third highest 25th percentile of PM10 during the Summer season of 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 5441,Show a bar chart of the top 9 cities by median PM2.5 in 2020.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2020] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(9, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 9 Cities by Median PM2.5 in 2020', width=500, height=300) return chart " 5442,Which station possessed the 3rd lowest average for PM2.5 in the Monsoon season of 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 5443,Report which state possessed the third lowest median PM10 throughout the Monsoon season of 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 5444,Show the PM2.5 per 1000 km² (air quality density) for each state in 2022 as a bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): pm = data[data['Timestamp'].dt.year == 2022].groupby('state')['PM2.5'].mean().reset_index().dropna() df = pm.merge(states_data[['state','area (km2)']], on='state') df['PM2.5 per 1000 km²'] = df['PM2.5'] / df['area (km2)'] * 1000 df = df.sort_values('PM2.5 per 1000 km²', ascending=False) chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5 per 1000 km²:Q', title='PM2.5 per 1000 km²'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5 per 1000 km²:Q', scale=alt.Scale(scheme='orangered'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5 per 1000 km²:Q', format='.3f')] ).properties(title='Air Quality Density (PM2.5 per 1000 km²) by State – 2022', width=500, height=400) return chart " 5445,List average PM10 by month for Tripura in 2023 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tripura'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5446,"Tabulate PM10 statistics (mean, std, min, max) for each city in 2020."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5447,Show a ranked table of the 10 most polluted citys by average PM2.5 in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 5448,Create a ranked table of the 10 best-performing states by PM10 in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 5449,"Create a grouped bar chart comparing the average PM2.5 for Himachal Pradesh, Jammu and Kashmir, and West Bengal across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Himachal Pradesh', 'Jammu and Kashmir', 'West Bengal'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 5450,Show how average PM10 varied month by month for Ahmedabad in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Ahmedabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5451,Show a monthly bar chart of the number of days Andhra Pradesh exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Andhra Pradesh') & (data['Timestamp'].dt.year == 2023)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Andhra Pradesh Exceeded WHO PM2.5 Guideline per Month – 2023', width=500, height=300) return chart " 5452,Which 15 citys had the lowest mean PM2.5 in 2018? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 5453,Tabulate the yearly average PM10 trend for Assam across all years.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Assam'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5454,Which station displayed the highest 25th percentile of PM2.5 in August 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 5455,"Create a grouped bar chart comparing the average PM2.5 for Jharkhand, Tamil Nadu, and Delhi across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Tamil Nadu', 'Delhi'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 5456,Show a monthly breakdown table of average PM10 for Jodhpur in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Jodhpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5457,Generate a monthly average PM10 table for Karnataka for the year 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5458,"During 2024, determine the weekday that showed the lowest median PM10 pollution levels."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'Timestamp'}}] " 5459,"Over all years, which June showed the third-lowest median PM2.5 concentration?"," [{'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'Timestamp'}}] " 5460,Tabulate the 5 worst states for average PM2.5 in 2018 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 5461,Create a ranked table of the 10 best-performing states by PM2.5 in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 5462,Create a summary table ranking the top 15 citys by PM10 concentration in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 5463,Which state recorded the 2nd highest median PM10 in February 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 5464,"Visualize the monthly average PM10 for Haryana, Nagaland, and Rajasthan in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Nagaland', 'Rajasthan'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Haryana, Nagaland, UP – 2022', width=550, height=320) return chart " 5465,Show a monthly breakdown table of average PM10 for Nagpur in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Nagpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5466,Plot the weekly average PM2.5 for Nagpur in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Nagpur') & (data['Timestamp'].dt.year == 2020)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Nagpur 2020', width=600, height=300) return chart " 5467,Generate a monthly average PM2.5 table for Patna for the year 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Patna'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5468,How many times did Sangli city surpass the Indian guideline for PM10 in 2017?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 60.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 5469,Plot the top 9 states by average PM2.5 in 2021 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2021] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(9, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 9 States by Average PM2.5 in 2021', width=500, height=300) return chart " 5470,Plot the weekly average PM2.5 for Rajamahendravaram in 2019 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Rajamahendravaram') & (data['Timestamp'].dt.year == 2019)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Rajamahendravaram 2019', width=600, height=300) return chart " 5471,Tabulate the 10 states with the least PM2.5 pollution in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 5472,Show the monthly average PM2.5 for Ludhiana in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ludhiana') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Ludhiana 2019', width=450, height=280) " 5473,Which city had the highest average PM10 in March 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 5474,Report which city possessed the third highest 75th percentile of PM2.5 throughout the Winter season of 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 5475,Which city recorded the 3rd lowest average for PM10 in the Summer season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 5476,"In July 2024, which state displayed the 3rd highest average PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 5477,Create a month-wise PM10 breakdown table across cities in Rajasthan for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Ajmer', 'Alwar', 'Bhiwadi', 'Jaipur', 'Jodhpur', 'Kota', 'Pali', 'Udaipur']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5478,Create a statistical summary table of PM10 readings by state for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5479,Tabulate area-adjusted PM10 (per km²) for each state in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM10 per km²', 'numerator': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)', 'PM10 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5480,Show a cumulative area chart of PM2.5 readings for Vapi across 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Vapi') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Vapi 2021', width=600, height=300) return chart " 5481,Create a grouped bar chart comparing the average PM2.5 in Winter vs Summer for the top 13 most polluted states.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top6 = data.groupby('state')['PM2.5'].mean().nlargest(13).index.tolist() df = data[data['state'].isin(top6)].copy() df['Season'] = df['Timestamp'].dt.month.apply( lambda m: 'Winter' if m in [12,1,2] else ('Summer' if m in [3,4,5] else None)) df = df.dropna(subset=['Season']) df = df.groupby(['state','Season'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('state:N', title='State'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('Season:N', title='Season'), xOffset='Season:N', tooltip=['state:N','Season:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Winter vs Summer PM2.5 – Top 13 Polluted States', width=550, height=320) return chart " 5482,Show a cumulative area chart of PM2.5 readings for Udaipur across 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Udaipur') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Udaipur 2018', width=600, height=300) return chart " 5483,How many times did Malegaon city surpass 75 µg/m³ of PM10 in 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 75.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 5484,Plot the rolling 30-day average PM2.5 for Odisha in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Odisha') & (data['Timestamp'].dt.year == 2020)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Odisha 2020', width=600, height=300) " 5485,Show a bar chart comparing the 75th percentile PM2.5 of all states in winter 2017 (November–February).," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.month.isin([11,12,1,2])] df = df[df['Timestamp'].dt.year.isin([2017,2018])] df = df.groupby('state')['PM2.5'].quantile(0.75).reset_index().dropna() df.columns = ['state','PM2.5_p75'] df = df.sort_values('PM2.5_p75', ascending=False) chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5_p75:Q', title='75th Percentile PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5_p75:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5_p75:Q', format='.1f', title='P75 PM2.5')] ).properties(title='75th Percentile PM2.5 by State – Winter 2017', width=500, height=400) return chart " 5486,Show the monthly average PM2.5 for Barmer in 2022 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Barmer') & (data['Timestamp'].dt.year == 2022)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Barmer 2022', width=450, height=280) " 5487,"Which union territory having a land area less than 1,000 km² registers the maximum PM10 level, according to its average PM10 level?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}] " 5488,Show a table of the top 20 states by average PM2.5 in 2024 including their PM10 levels too.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 5489,Generate a city × month cross-tab of mean PM2.5 for Andhra Pradesh in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Amaravati', 'Rajamahendravaram', 'Tirupati', 'Visakhapatnam']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5490,Determine the station exhibiting the highest average PM10 in June 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 5491,Which city recorded the 3rd highest 75th percentile of PM2.5 in February 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 5492,"Which union territory possesses the smallest land area among the top 2 most polluted union territories, based on average PM2.5 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 2, 'ret': 'state'}}] " 5493,Show a year-wise table of average PM2.5 for Kanpur from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Kanpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5494,Which city recorded the 3rd highest 25th percentile of PM10 in the Winter season of 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 5495,"On March 31, 2020, which state had the third-lowest average PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 5496,Create a summary table comparing mean PM2.5 and PM10 across states in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5497,Tabulate the yearly average PM10 trend for Meghalaya across all years.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Meghalaya'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5498,Plot the weekly average PM2.5 for Siliguri in 2021 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Siliguri') & (data['Timestamp'].dt.year == 2021)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Siliguri 2021', width=600, height=300) return chart " 5499,"Compare the monthly average PM2.5 of Ratlam, Sonipat, and Hyderabad in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Ratlam', 'Sonipat', 'Hyderabad'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Ratlam vs Sonipat vs Hyderabad – 2024', width=550, height=320) return chart " 5500,Show the number of days each city exceeded a PM10 threshold of 150 µg/m³ in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5501,"Which state (excluding Union Territories) possesses the 3rd smallest land area among the top 3 most polluted states, based on the standard deviation of PM10 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'std', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 3, 'ret': 'state'}}] " 5502,"Plot the yearly average PM2.5 trends for Bihar, Delhi, and Chhattisgarh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Bihar', 'Delhi', 'Chhattisgarh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Bihar vs Delhi vs Chhattisgarh', width=550, height=320) return chart " 5503,Which state got the lowest NCAP funding considering its 75th percentile of PM2.5 concentration in 2020 (FY 2019-20)?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2020_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 5504,List states with their PM2.5 violation count and rate (>100 µg/m³) in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5505,Report the state with the 3rd lowest 75th percentile of PM10 in January 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 5506,Determine the state with the 2nd lowest median PM2.5 in August 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 5507,"Scatter plot PM2.5 vs PM10 for Arunachal Pradesh stations in 2024, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Arunachal Pradesh') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Arunachal Pradesh Stations 2024', width=450, height=350) " 5508,"Which state (excluding UTs) possesses the 3rd smallest population among the top 10 most polluted states, determined by median PM2.5 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 10, 'ret': 'state'}}] " 5509,Plot the weekly average PM2.5 for Samastipur in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Samastipur') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Samastipur 2023', width=600, height=300) return chart " 5510,"Create a grouped bar chart comparing the average PM2.5 for Chandigarh, Mizoram, and Telangana across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chandigarh', 'Mizoram', 'Telangana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 5511,Tabulate the 20 states with the least PM10 pollution in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 5512,Show the monthly average PM2.5 for Varanasi in 2023 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Varanasi') & (data['Timestamp'].dt.year == 2023)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Varanasi 2023', width=450, height=280) " 5513,Plot the average PM2.5 across all states in February 2017 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['Timestamp'].dt.year == 2017) & (data['Timestamp'].dt.month == 2)] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('PM2.5', ascending=False) chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='plasma'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Average PM2.5 by State – February 2017', width=500, height=400) return chart " 5514,Show a cumulative area chart of PM2.5 readings for Bidar across 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bidar') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Bidar 2022', width=600, height=300) return chart " 5515,Tabulate average PM2.5 for each city in Maharashtra across all months of 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Ahmednagar', 'Akola', 'Amravati', 'Aurangabad', 'Badlapur', 'Belapur', 'Bhiwandi', 'Boisar', 'Chandrapur', 'Dhule', 'Jalgaon', 'Jalna', 'Kalyan', 'Kolhapur', 'Latur', 'Mahad', 'Malegaon', 'Mira-Bhayandar', 'Mumbai', 'Nagpur', 'Nanded', 'Nashik', 'Navi Mumbai', 'Parbhani', 'Pimpri-Chinchwad', 'Pune', 'Sangli', 'Solapur', 'Thane', 'Ulhasnagar', 'Virar']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5516,Show a cumulative area chart of PM2.5 readings for Chandrapur across 2017.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Chandrapur') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Chandrapur 2017', width=600, height=300) return chart " 5517,"Create a grouped bar chart comparing the average PM2.5 for Madhya Pradesh, Puducherry, and Meghalaya across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Madhya Pradesh', 'Puducherry', 'Meghalaya'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 5518,Which station possessed the 2nd lowest 25th percentile for PM10 in the Summer season of 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 5519,Show a cumulative area chart of PM2.5 readings for Gummidipoondi across 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Gummidipoondi') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Gummidipoondi 2022', width=600, height=300) return chart " 5520,"On January 14, 2018, which station showed the lowest PM2.5 readings?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 5521,Identify the state with the highest median PM2.5 in September 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 5522,"Which station showed the second-highest 25th percentile for PM10 on March 31, 2018?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 5523,"Create a grouped bar chart comparing the average PM2.5 for Tamil Nadu, Chhattisgarh, and Himachal Pradesh across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Chhattisgarh', 'Himachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 5524,Show annual average PM10 for Telangana as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Telangana'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5525,List average PM10 by month for Mumbai in 2017 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Mumbai'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5526,Create a heatmap showing the average PM2.5 by month (x-axis) and year (y-axis) for Tamil Nadu.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Tamil Nadu'].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Year:N', title='Year'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='Avg PM2.5'), tooltip=['Year:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Tamil Nadu (Month × Year)', width=500, height=280) return chart " 5527,Plot the weekly average PM2.5 for Solapur in 2019 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Solapur') & (data['Timestamp'].dt.year == 2019)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Solapur 2019', width=600, height=300) return chart " 5528,Show average PM2.5 per state in 2021 with area in km².," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5529,Create a ranked table of the 5 best-performing states by PM10 in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 5530,Tabulate daily PM10 exceedances (above 100 µg/m³) per state for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5531,List average PM10 by month for Kerala in 2020 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5532,Show PM2.5 exceedance count and rate (%) above 60 µg/m³ per city in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5533,List the average PM10 for Varanasi broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Varanasi'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5534,"Visualize the monthly average PM10 for Haryana, Arunachal Pradesh, and Jammu and Kashmir in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Arunachal Pradesh', 'Jammu and Kashmir'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Haryana, Arunachal Pradesh, UP – 2024', width=550, height=320) return chart " 5535,"On January 14, 2019, which station recorded the lowest PM2.5 measurements?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 5536,Report which city possessed the 2nd most minimal 75th percentile of PM10 throughout the Post-Monsoon season of 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 5537,Identify the state that recorded the 2nd lowest median PM10 value in August 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 5538,"Show the top 15 states by average PM10 in 2022 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2022] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(15, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 15 States by Average PM10 in 2022', width=500, height=300) return chart " 5539,"Comparing December 2019 to October 2019, which state showed the second most significant drop in 75th percentile PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 5540,Generate a year-by-year summary table of PM2.5 readings for Mizoram.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Mizoram'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5541,Which state displayed the 3rd highest average PM2.5 in September 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 5542,Show annual average PM2.5 for Mizoram as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Mizoram'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5543,Which state had the 2nd lowest 75th percentile of PM2.5 in January 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 5544,Determine the city that ranks third for the highest 25th percentile of PM10 in December 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 5545,Create a grouped bar chart comparing the average PM2.5 in Winter vs Summer for the top 9 most polluted states.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top6 = data.groupby('state')['PM2.5'].mean().nlargest(9).index.tolist() df = data[data['state'].isin(top6)].copy() df['Season'] = df['Timestamp'].dt.month.apply( lambda m: 'Winter' if m in [12,1,2] else ('Summer' if m in [3,4,5] else None)) df = df.dropna(subset=['Season']) df = df.groupby(['state','Season'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('state:N', title='State'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('Season:N', title='Season'), xOffset='Season:N', tooltip=['state:N','Season:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Winter vs Summer PM2.5 – Top 9 Polluted States', width=550, height=320) return chart " 5546,"Show the mean, median and standard deviation of PM2.5 per city in 2024 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5547,Plot the rolling 30-day average PM2.5 for Sikkim in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Sikkim') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Sikkim 2023', width=600, height=300) " 5548,Which city showed the 2nd lowest median for PM10 in the Summer season of 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 5549,Show how average PM10 varied month by month for Gwalior in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Gwalior'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5550,Plot the weekly average PM2.5 for Hapur in 2019 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Hapur') & (data['Timestamp'].dt.year == 2019)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Hapur 2019', width=600, height=300) return chart " 5551,"Compare the monthly average PM2.5 of Tumakuru, Indore, and Angul in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Tumakuru', 'Indore', 'Angul'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Tumakuru vs Indore vs Angul – 2023', width=550, height=320) return chart " 5552,How many times did Amritsar city surpass 75 µg/m³ of PM2.5 in 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 75.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 5553,"In 2023, which season (Winter, Summer, Monsoon, Post-Monsoon) corresponded to the second-lowest 75th percentile of PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'season'}}] " 5554,"Create a grouped bar chart comparing the average PM2.5 for Madhya Pradesh, Himachal Pradesh, and Andhra Pradesh across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Madhya Pradesh', 'Himachal Pradesh', 'Andhra Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 5555,Show annual average PM10 for Agra as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Agra'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5556,Which city had the highest median PM10 in September 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 5557,Create a month-wise summary of average PM2.5 for Tamil Nadu in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5558,Tabulate the monthly mean PM2.5 levels for Maharashtra during 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5559,"Compare the monthly average PM2.5 of Virar, Tirupati, and Chhal in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Virar', 'Tirupati', 'Chhal'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Virar vs Tirupati vs Chhal – 2023', width=550, height=320) return chart " 5560,"On January 5, 2021, which state registered the second-highest average PM10 concentration?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 5561,Generate a monthly average PM10 table for Tripura for the year 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tripura'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5562,Generate a descriptive stats table for PM2.5 grouped by city in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5563,"Compare the monthly average PM2.5 of Mahad, Ratlam, and Pithampur in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Mahad', 'Ratlam', 'Pithampur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Mahad vs Ratlam vs Pithampur – 2022', width=550, height=320) return chart " 5564,"Taking all years into account, which November was associated with the third-highest 75th percentile of PM2.5 levels?"," [{'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'Timestamp'}}] " 5565,Show how many times PM2.5 exceeded 100 µg/m³ per day across states in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5566,List the average PM10 for Nagaland broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Nagaland'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5567,"Compare the monthly average PM2.5 of Hapur, Noida, and Agra in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Hapur', 'Noida', 'Agra'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Hapur vs Noida vs Agra – 2018', width=550, height=320) return chart " 5568,Show a year-wise table of average PM2.5 for Andhra Pradesh from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5569,Which city showed the 3rd highest average for PM10 in the Post-Monsoon season of 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 5570,"Compare the monthly average PM2.5 of Chengalpattu, Kolar, and Kohima in 2020 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Chengalpattu', 'Kolar', 'Kohima'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2020)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Chengalpattu vs Kolar vs Kohima – 2020', width=550, height=320) return chart " 5571,Plot the weekly average PM2.5 for Nalbari in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Nalbari') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Nalbari 2023', width=600, height=300) return chart " 5572,"Tabulate the distribution of PM2.5 per state in 2020 including mean, median, and std."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'q25', 'median', 'q75']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5573,Create a summary table ranking the top 20 citys by PM10 concentration in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 5574,"For the period October to December 2020, which city had the third largest decrease in 25th percentile PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 5575,Show the monthly average PM10 trend for Bahadurgarh from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Bahadurgarh'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Bahadurgarh (2019–2024)', width=600, height=300) return chart " 5576,Show the monthly average PM10 trend for Udaipur from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Udaipur'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Udaipur (2019–2024)', width=600, height=300) return chart " 5577,Show how many times PM10 exceeded 150 µg/m³ per day across states in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5578,Show the monthly average PM10 trend for Chennai from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Chennai'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Chennai (2017–2022)', width=600, height=300) return chart " 5579,Tabulate daily PM10 exceedances (above 150 µg/m³) per state for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5580,How many times did Barrackpore city go above 30 µg/m³ of PM10 in 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 30.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 5581,"Considering all years, which March had the highest 25th percentile for PM2.5 levels?"," [{'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'Timestamp'}}] " 5582,Which station had the highest average PM2.5 in December 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 5583,Plot the weekly average PM2.5 for Hisar in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Hisar') & (data['Timestamp'].dt.year == 2020)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Hisar 2020', width=600, height=300) return chart " 5584,"Which union territory has the 2nd maximum PM2.5 concentration per square kilometer, based on 75th percentile PM2.5 values?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_km2', 'numerator': 'PM2.5', 'denominator': 'area (km2)'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'pm_per_km2', 'ascending': False}}] " 5585,Which state had the 2nd lowest average PM10 in November 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 5586,Show the number of days each city exceeded a PM10 threshold of 150 µg/m³ in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5587,Identify the union territory with the 2nd highest total PM2.5 concentration relative to its population density.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'sum', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_capita', 'numerator': 'PM2.5', 'denominator': 'population'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'pm_per_capita', 'ascending': False}}] " 5588,List the top 20 citys by average PM2.5 in 2020 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 5589,Report the state having the 5th highest NCAP funding considering its median PM2.5 concentration in 2022 (FY 2021-22).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2022_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 5590,"Plot the yearly average PM2.5 trends for Gujarat, Telangana, and Himachal Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Gujarat', 'Telangana', 'Himachal Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Gujarat vs Telangana vs Himachal Pradesh', width=550, height=320) return chart " 5591,"Plot the yearly average PM2.5 trends for Andhra Pradesh, Tamil Nadu, and Uttar Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Tamil Nadu', 'Uttar Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Andhra Pradesh vs Tamil Nadu vs Uttar Pradesh', width=550, height=320) return chart " 5592,Plot the rolling 30-day average PM2.5 for Bihar in 2017 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Bihar') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Bihar 2017', width=600, height=300) " 5593,"Visualize the monthly average PM10 for Karnataka, Jharkhand, and Manipur in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Karnataka', 'Jharkhand', 'Manipur'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Karnataka, Jharkhand, UP – 2017', width=550, height=320) return chart " 5594,"Scatter plot PM2.5 vs PM10 for Assam stations in 2023, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Assam') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Assam Stations 2023', width=450, height=350) " 5595,Show the monthly average PM10 trend for Katni from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Katni'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Katni (2019–2024)', width=600, height=300) return chart " 5596,Identify the station that registered the second highest median PM10 level overall.," [{'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 5597,Show the monthly average PM10 trend for Kaithal from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Kaithal'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Kaithal (2017–2022)', width=600, height=300) return chart " 5598,Identify the station that recorded the 2nd highest average PM10 value in January 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 5599,"In July 2018, which station registered the 3rd lowest median PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 5600,Which state demonstrates the 4th lowest total PM10 concentration relative to its population density?," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'sum', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_capita', 'numerator': 'PM10', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'pm_per_capita', 'ascending': True}}] " 5601,Show how average PM10 varied month by month for Telangana in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Telangana'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5602,Plot the top 5 states by average PM2.5 in 2017 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2017] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(5, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 5 States by Average PM2.5 in 2017', width=500, height=300) return chart " 5603,Plot the weekly average PM2.5 for Singrauli in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Singrauli') & (data['Timestamp'].dt.year == 2020)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Singrauli 2020', width=600, height=300) return chart " 5604,How many times did Kadapa city exceed the Indian guideline for PM2.5 in the year 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 60.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 5605,"Plot the yearly average PM2.5 trends for Punjab, Assam, and Jammu and Kashmir from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Punjab', 'Assam', 'Jammu and Kashmir'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Punjab vs Assam vs Jammu and Kashmir', width=550, height=320) return chart " 5606,Show a bar chart of the top 8 cities by median PM2.5 in 2019.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2019] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(8, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 8 Cities by Median PM2.5 in 2019', width=500, height=300) return chart " 5607,Determine the city exhibiting the 3rd lowest average PM10 in May 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 5608,Show the monthly average PM2.5 for Malegaon in 2022 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Malegaon') & (data['Timestamp'].dt.year == 2022)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Malegaon 2022', width=450, height=280) " 5609,"Scatter plot PM2.5 vs PM10 for Gujarat stations in 2019, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Gujarat') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Gujarat Stations 2019', width=450, height=350) " 5610,Show a monthly bar chart of the number of days Maharashtra exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Maharashtra') & (data['Timestamp'].dt.year == 2022)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Maharashtra Exceeded WHO PM2.5 Guideline per Month – 2022', width=500, height=300) return chart " 5611,Tabulate days with PM10 > 150 µg/m³ and exceedance percentage per city in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 150'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5612,Find the state with the third-lowest median PM2.5 concentration in February 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 5613,Plot the weekly average PM2.5 for Faridabad in 2017 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Faridabad') & (data['Timestamp'].dt.year == 2017)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Faridabad 2017', width=600, height=300) return chart " 5614,Identify the city exhibiting the third highest 25th percentile of PM2.5 during the Summer season of 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 5615,Create a table with mean and standard deviation of PM10 by state in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5616,Plot the top 6 states by average PM2.5 in 2023 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2023] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(6, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 6 States by Average PM2.5 in 2023', width=500, height=300) return chart " 5617,Show the monthly average PM2.5 for Hubballi in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Hubballi') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Hubballi 2019', width=450, height=280) " 5618,Determine the station with the 2nd lowest 75th percentile of PM2.5 in February 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 5619,Tabulate the yearly average PM2.5 trend for Bengaluru across all years.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Bengaluru'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5620,Show the number of days each state exceeded a PM2.5 threshold of 60 µg/m³ in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5621,"Compare the monthly average PM2.5 of Chhapra, Raichur, and Katihar in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Chhapra', 'Raichur', 'Katihar'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Chhapra vs Raichur vs Katihar – 2022', width=550, height=320) return chart " 5622,List all citys with their average PM2.5 and PM10 levels in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5623,Show a pivot table of monthly average PM10 by city for Haryana in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Haryana'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Ambala', 'Bahadurgarh', 'Ballabgarh', 'Bhiwani', 'Charkhi Dadri', 'Dharuhera', 'Faridabad', 'Fatehabad', 'Gurugram', 'Hisar', 'Jind', 'Kaithal', 'Karnal', 'Kurukshetra ', 'Mandikhera', 'Manesar', 'Narnaul', 'Palwal ', 'Panipat', 'Sirsa', 'Sonipat', 'Yamuna Nagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5624,Visualize NCAP city-level funding for FY 2021-22 as a horizontal bar chart for the top 9 cities.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = ncap_funding_data[['city','state','Amount released during FY 2021-22']].copy() df.columns = ['city','state','Amount (Cr)'] df = df.nlargest(9, 'Amount (Cr)') df['City_State'] = df['city'] + ', ' + df['state'] chart = alt.Chart(df).mark_bar().encode( x=alt.X('Amount (Cr):Q', title='Amount Released (Cr)'), y=alt.Y('City_State:N', sort='-x', title='City, State'), color=alt.Color('state:N', title='State'), tooltip=['city:N','state:N', alt.Tooltip('Amount (Cr):Q', format='.1f')] ).properties(title='Top 9 Cities by NCAP Funding – FY 2021-22', width=500, height=400) return chart " 5625,"In April 2020, report the station with the 2nd lowest 75th percentile of PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 5626,Create a table showing annual mean PM10 levels for Varanasi (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Varanasi'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5627,Determine the state with the second-most minimal median PM10 in December 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 5628,Determine the city exhibiting the lowest 25th percentile of PM2.5 in April 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 5629,"Plot the yearly average PM2.5 trends for Himachal Pradesh, Chhattisgarh, and Tamil Nadu from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Himachal Pradesh', 'Chhattisgarh', 'Tamil Nadu'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Himachal Pradesh vs Chhattisgarh vs Tamil Nadu', width=550, height=320) return chart " 5630,Generate a city × month cross-tab of mean PM10 for Punjab in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Amritsar', 'Bathinda', 'Jalandhar', 'Khanna', 'Ludhiana', 'Mandi Gobindgarh', 'Patiala', 'Rupnagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5631,Show average PM10 per capita by state in 2019 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM10 per million', 'numerator': 'PM10', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'PM10 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5632,Which station reported the second-highest PM2.5 readings on any New Year's Eve to date?," [{'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 5633,"In May 2023, report the city with the 2nd highest median PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 5634,Generate a city × month cross-tab of mean PM2.5 for Andhra Pradesh in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Tirupati']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5635,Show a cumulative area chart of PM2.5 readings for Guwahati across 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Guwahati') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Guwahati 2022', width=600, height=300) return chart " 5636,How many times did Sri Ganganagar city go above the Indian guideline for PM10 in 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 60.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 5637,Determine the state exhibiting the highest 75th percentile of PM10 over the Summer season of 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 5638,Show a cumulative area chart of PM2.5 readings for Ankleshwar across 2019.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ankleshwar') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Ankleshwar 2019', width=600, height=300) return chart " 5639,Show the monthly average PM2.5 for Kurukshetra in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Kurukshetra') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Kurukshetra 2017', width=450, height=280) " 5640,Which 20 states recorded the highest average PM10 levels in 2022? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 5641,Determine the city exhibiting the 2nd lowest median PM10 in August 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 5642,List the bottom 15 citys with the lowest average PM10 in 2020 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 5643,Show the monthly average PM10 trend for Bagalkot from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Bagalkot'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Bagalkot (2017–2022)', width=600, height=300) return chart " 5644,"List each state's average PM2.5, PM10, and how many stations it has in 2023."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}, {'alias': 'Station Count', 'col': 'station', 'fn': 'nunique'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5645,Tabulate days with PM2.5 > 100 µg/m³ and exceedance percentage per city in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5646,"Scatter plot PM2.5 vs PM10 for Jharkhand stations in 2018, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Jharkhand') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Jharkhand Stations 2018', width=450, height=350) " 5647,Generate a city × month cross-tab of mean PM10 for Punjab in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Amritsar', 'Bathinda', 'Jalandhar', 'Khanna', 'Ludhiana', 'Mandi Gobindgarh', 'Patiala', 'Rupnagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5648,Show the monthly average PM2.5 for Vatva in 2022 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Vatva') & (data['Timestamp'].dt.year == 2022)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Vatva 2022', width=450, height=280) " 5649,"Show the variability of PM2.5 across states in 2023 using mean, median, and standard deviation."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5650,"Identify the state with the third-highest median PM10 on March 31, 2024."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 5651,Create a heatmap showing the average PM2.5 by month (x-axis) and year (y-axis) for Gujarat.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Gujarat'].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Year:N', title='Year'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='Avg PM2.5'), tooltip=['Year:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Gujarat (Month × Year)', width=500, height=280) return chart " 5652,List the average PM10 for Bengaluru broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Bengaluru'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5653,"Create a grouped bar chart comparing the average PM2.5 for Nagaland, Mizoram, and Haryana across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Nagaland', 'Mizoram', 'Haryana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 5654,Plot the weekly average PM2.5 for Kalaburagi in 2018 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Kalaburagi') & (data['Timestamp'].dt.year == 2018)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Kalaburagi 2018', width=600, height=300) return chart " 5655,"During 2023, which weekday saw the second-highest 25th percentile of PM2.5 pollution levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'Timestamp'}}] " 5656,Tabulate days with PM2.5 > 60 µg/m³ and exceedance percentage per city in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5657,Which city had the 3rd lowest average PM10 in February 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 5658,Generate a year-by-year summary table of PM10 readings for Andhra Pradesh.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5659,Generate a monthly average PM10 table for Karnataka for the year 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5660,Show how average PM2.5 varied month by month for Madhya Pradesh in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5661,"Scatter plot PM2.5 vs PM10 for Tripura stations in 2020, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Tripura') & (data['Timestamp'].dt.year == 2020)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Tripura Stations 2020', width=450, height=350) " 5662,"Visualize the monthly average PM10 for Meghalaya, Maharashtra, and Uttarakhand in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Meghalaya', 'Maharashtra', 'Uttarakhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Meghalaya, Maharashtra, UP – 2022', width=550, height=320) return chart " 5663,Show how many times PM2.5 exceeded 60 µg/m³ per day across states in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5664,Find the state with the third-highest mean PM10 concentration in December 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 5665,List how many days each state breached the PM2.5 limit of 100 µg/m³ in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5666,List the top 15 states by average PM2.5 in 2019 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 5667,List the average PM10 for Indore broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Indore'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5668,Create a summary table ranking the top 15 citys by PM2.5 concentration in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 5669,Plot the distribution of PM2.5 values in Chandigarh across all years using a histogram.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Chandigarh'].dropna(subset=['PM2.5']) df = df[['PM2.5']] chart = alt.Chart(df).mark_bar(color='steelblue', opacity=0.75).encode( x=alt.X('PM2\.5:Q', bin=alt.Bin(maxbins=40), title='PM2.5 (µg/m³)'), y=alt.Y('count()', title='Number of Observations'), tooltip=[alt.Tooltip('PM2\.5:Q', bin=True), 'count()'] ).properties(title='PM2.5 Distribution – Chandigarh (All Years)', width=500, height=300) return chart " 5670,"Compare the monthly average PM2.5 of Shivamogga, Ballabgarh, and Howrah in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Shivamogga', 'Ballabgarh', 'Howrah'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Shivamogga vs Ballabgarh vs Howrah – 2023', width=550, height=320) return chart " 5671,"On March 31, 2023, which station recorded the second-lowest median PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 5672,"Create a faceted bar chart showing top 15 states by average PM2.5 per year for 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year.isin([2019,2020,2021,2022])].copy() df['Year'] = df['Timestamp'].dt.year agg = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() top = agg.groupby('Year').apply(lambda x: x.nlargest(15,'PM2.5')).reset_index(drop=True) chart = alt.Chart(top).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Avg PM2.5'), y=alt.Y('state:N', sort='-x'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet(facet='Year:O', columns=2).properties(title='Top 15 States by PM2.5 per Year') return chart " 5673,Show the monthly average PM2.5 for Kohima in 2023 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Kohima') & (data['Timestamp'].dt.year == 2023)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Kohima 2023', width=450, height=280) " 5674,Which city registered the highest 25th percentile of PM10 during December 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 5675,"Visualize the monthly average PM10 for Arunachal Pradesh, Andhra Pradesh, and Haryana in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Arunachal Pradesh', 'Andhra Pradesh', 'Haryana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Arunachal Pradesh, Andhra Pradesh, UP – 2022', width=550, height=320) return chart " 5676,Report which city registered the peak median PM10 throughout the Post-Monsoon season of 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 5677,Generate a cross-tab of state vs month for average PM10 in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Delhi', 'Gujarat', 'Haryana', 'Jharkhand', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5678,Show a monthly breakdown table of average PM10 for Tamil Nadu in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5679,"Considering 2021, what day of the week had the third-highest 75th percentile of PM10 pollution levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'Timestamp'}}] " 5680,Identify the city with the second-lowest 75th percentile for PM10 in March 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 5681,"Taking all years into account, which March was associated with the maximum average PM10 levels?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'Timestamp'}}] " 5682,How many stations in Odisha surpassed 75 µg/m³ of PM10 in the year 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 75.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 5683,Tabulate average and median PM10 for all citys in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5684,"Visualize the monthly average PM10 for Maharashtra, Jammu and Kashmir, and Punjab in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Maharashtra', 'Jammu and Kashmir', 'Punjab'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Maharashtra, Jammu and Kashmir, UP – 2017', width=550, height=320) return chart " 5685,"In September 2021, which city exhibited the highest average PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 5686,"Scatter plot PM2.5 vs PM10 for Uttar Pradesh stations in 2023, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Uttar Pradesh') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Uttar Pradesh Stations 2023', width=450, height=350) " 5687,Generate a monthly average PM10 table for Assam for the year 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Assam'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5688,Generate a monthly average PM10 table for Nagaland for the year 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Nagaland'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5689,Show the monthly average PM2.5 for Dholpur in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Dholpur') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Dholpur 2017', width=450, height=280) " 5690,Generate a year-by-year summary table of PM10 readings for Puducherry.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Puducherry'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5691,"Show the mean, median and standard deviation of PM10 per state in 2021 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5692,Show how average PM10 varied month by month for Ahmedabad in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Ahmedabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5693,Visualize the bottom 13 states with the lowest average PM2.5 in 2024 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2024] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(13, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 13 States by Average PM2.5 in 2024', width=500, height=300) return chart " 5694,List how many days each city breached the PM2.5 limit of 60 µg/m³ in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5695,Identify the city with the lowest NCAP funding considering its average PM2.5 concentration in 2020 (FY 2019-20).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2020_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 5696,"Create a grouped bar chart comparing the average PM2.5 for Bihar, Odisha, and Madhya Pradesh across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Bihar', 'Odisha', 'Madhya Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 5697,Create a summary table ranking the top 15 states by PM2.5 concentration in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 5698,"Show the top 8 states by average PM10 in 2018 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2018] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(8, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 8 States by Average PM10 in 2018', width=500, height=300) return chart " 5699,Tabulate days with PM2.5 > 60 µg/m³ and exceedance percentage per city in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5700,Generate a descriptive stats table for PM2.5 grouped by city in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5701,Report the state with the 3rd highest median PM10 in October 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 5702,"In 2018, which weekday was associated with the third-highest 75th percentile of PM10 pollution concentrations?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'Timestamp'}}] " 5703,Show a cumulative area chart of PM2.5 readings for Ahmednagar across 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ahmednagar') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Ahmednagar 2024', width=600, height=300) return chart " 5704,Identify the station that showed the second highest average PM10 during the Winter season of 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 5705,Show a bar chart of the top 5 cities by median PM2.5 in 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2018] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(5, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 5 Cities by Median PM2.5 in 2018', width=500, height=300) return chart " 5706,Determine the state that recorded the third highest PM10 level on 27 January 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 5707,"Over all years, which March registered the minimum 25th percentile for PM10 levels?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'Timestamp'}}] " 5708,Which station registered the 3rd highest 25th percentile of PM10 during December 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 5709,Create a table of PM2.5 standard violations (>60 µg/m³) per city in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5710,Show a monthly bar chart of the number of days Jammu and Kashmir exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Jammu and Kashmir') & (data['Timestamp'].dt.year == 2022)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Jammu and Kashmir Exceeded WHO PM2.5 Guideline per Month – 2022', width=500, height=300) return chart " 5711,"Compare the monthly average PM2.5 of Mahad, Perundurai, and Bhiwadi in 2020 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Mahad', 'Perundurai', 'Bhiwadi'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2020)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Mahad vs Perundurai vs Bhiwadi – 2020', width=550, height=320) return chart " 5712,"In March 2020, identify the station with the lowest median PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 5713,"Plot the yearly average PM2.5 trends for Bihar, Nagaland, and Chandigarh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Bihar', 'Nagaland', 'Chandigarh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Bihar vs Nagaland vs Chandigarh', width=550, height=320) return chart " 5714,Which state recorded the 2nd lowest 75th percentile of PM10 during the Summer season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 5715,Generate a year-by-year summary table of PM10 readings for Meerut.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Meerut'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5716,Report which city possessed the peak median PM10 throughout the Post-Monsoon season of 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 5717,"Which union territory with a land area greater than 1,000 km² shows the 2nd highest PM10 level, based on its variance of PM10 level?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'var', 'col': 'PM10'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}] " 5718,"In September 2020, which state recorded the 3rd highest 75th percentile of PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 5719,How many times did Punjab city go above 75 µg/m³ of PM2.5 in 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 75.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 5720,"Which state (excluding Union Territories) has the 2nd highest land area among the top 5 most polluted states, according to median PM2.5 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 5, 'ret': 'state'}}] " 5721,Tabulate the 20 worst states for average PM10 in 2021 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 5722,Identify the city that recorded the 3rd highest 75th percentile of PM2.5 value in June 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 5723,Generate a city × month cross-tab of mean PM10 for Uttar Pradesh in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Agra', 'Bulandshahr', 'Firozabad', 'Ghaziabad', 'Gorakhpur', 'Greater Noida', 'Hapur', 'Kanpur', 'Lucknow', 'Meerut', 'Moradabad', 'Muzaffarnagar', 'Noida', 'Prayagraj', 'Varanasi', 'Vrindavan']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5724,Which state showed the highest 25th percentile of PM10 in June 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 5725,"For the year 2018, which week had the third-lowest average PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'week'}}] " 5726,Show a table of average PM2.5 and PM10 for all citys in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5727,"On January 14, 2022, which station had the third-lowest PM10 measurements?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 5728,Determine the state with the 2nd lowest 75th percentile of PM2.5 in July 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 5729,Show annual average PM10 for Maharashtra as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5730,Which city recorded the minimum 75th percentile of PM10 during the Winter season of 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 5731,Which city had the 3rd highest 25th percentile of PM2.5 in September 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 5732,Show a cumulative area chart of PM2.5 readings for Chamarajanagar across 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Chamarajanagar') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Chamarajanagar 2021', width=600, height=300) return chart " 5733,Which station had the 2nd highest average PM10 in May 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 5734,"In 2023, which season (Winter, Summer, Monsoon, Post-Monsoon) experienced the maximum 25th percentile of PM2.5 concentrations?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'season'}}] " 5735,Create a table with mean and standard deviation of PM2.5 by state in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5736,Plot the top 7 states by average PM2.5 in 2018 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2018] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(7, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 7 States by Average PM2.5 in 2018', width=500, height=300) return chart " 5737,Show a bar chart of the top 15 cities by median PM2.5 in 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2021] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(15, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 15 Cities by Median PM2.5 in 2021', width=500, height=300) return chart " 5738,Report the city that had the lowest 75th percentile of PM10 in July 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 5739,"Report which union territory, from those with populations exceeding the median, obtains the highest per capita NCAP funding."," [{'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_capita', 'numerator': 'total_fund', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'funding_per_capita', 'ascending': False}}] " 5740,Which state had the 4th highest NCAP funding with respect to its total PM2.5 concentration in 2020 (FY 2019-20)?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'sum', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2020_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 5741,Identify the station with the 2nd lowest 75th percentile of PM2.5 for June 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 5742,Show average PM2.5 per state in 2018 with area in km².," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5743,Show the monthly average PM2.5 for Gurugram in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Gurugram') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Gurugram 2018', width=450, height=280) " 5744,Show how average PM10 varied month by month for Gandhinagar in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Gandhinagar'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5745,Create a summary table ranking the top 10 citys by PM2.5 concentration in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 5746,"On August 15, 2022, which station had the minimum PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 5747,Determine the station with the 2nd highest average PM2.5 in April 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 5748,Identify the city that recorded the 2nd highest average PM2.5 value in November 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 5749,Which state noted the 2nd maximum median PM2.5 during the Summer season of 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 5750,Tabulate both PM2.5 and PM10 averages by city for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5751,Plot the top 5 states by average PM2.5 in 2019 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2019] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(5, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 5 States by Average PM2.5 in 2019', width=500, height=300) return chart " 5752,Show a cumulative area chart of PM2.5 readings for Nashik across 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Nashik') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Nashik 2022', width=600, height=300) return chart " 5753,Tabulate the monthly mean PM10 levels for Puducherry during 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Puducherry'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5754,Show the monthly average PM2.5 for Silchar in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Silchar') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Silchar 2020', width=450, height=280) " 5755,Show a bar chart of the top 13 cities by median PM2.5 in 2017.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2017] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(13, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 13 Cities by Median PM2.5 in 2017', width=500, height=300) return chart " 5756,Create a statistical summary table of PM2.5 readings by state for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5757,Show a table of the top 10 citys by average PM2.5 in 2022 including their PM10 levels too.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 5758,List NCAP funding per fiscal year and total for all states.," [ {'op': 'SOURCE', 'params': {'table': 'ncap'}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ { 'alias': 'FY 2019-20 (Cr)', 'col': 'Amount released during FY 2019-20', 'fn': 'sum'}, { 'alias': 'FY 2020-21 (Cr)', 'col': 'Amount released during FY 2020-21', 'fn': 'sum'}, { 'alias': 'FY 2021-22 (Cr)', 'col': 'Amount released during FY 2021-22', 'fn': 'sum'}, {'alias': 'Total (Cr)', 'col': 'Total fund released', 'fn': 'sum'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Total (Cr)'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5759,How many times did Meghalaya surpass 45 µg/m³ of PM2.5 in 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 45.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 5760,Show the monthly average PM2.5 for Bettiah in 2022 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bettiah') & (data['Timestamp'].dt.year == 2022)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Bettiah 2022', width=450, height=280) " 5761,Show how average PM2.5 varied month by month for Delhi in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Delhi'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5762,Which city had the 2nd lowest 75th percentile of PM2.5 in January 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 5763,How many times did Maihar city exceed 75 µg/m³ of PM2.5 in the year 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 75.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 5764,Which week in 2020 was linked to the second-highest median PM10 levels?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'week'}}] " 5765,"Scatter plot PM2.5 vs PM10 for Nagaland stations in 2023, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Nagaland') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Nagaland Stations 2023', width=450, height=350) " 5766,Create a table with mean and standard deviation of PM2.5 by city in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5767,"Create a grouped bar chart comparing the average PM2.5 for Sikkim, Punjab, and Punjab across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Sikkim', 'Punjab', 'Punjab'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 5768,Create a per-capita PM10 summary table by state for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM10 per million', 'numerator': 'PM10', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'PM10 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5769,"Plot the yearly average PM2.5 trends for Assam, Himachal Pradesh, and Nagaland from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Assam', 'Himachal Pradesh', 'Nagaland'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Assam vs Himachal Pradesh vs Nagaland', width=550, height=320) return chart " 5770,Report the city that had the 3rd highest average PM2.5 in April 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 5771,Tabulate the monthly mean PM2.5 levels for Meerut during 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Meerut'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5772,Tabulate mean PM2.5 alongside state population figures for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5773,Show a heatmap of average PM2.5 for the top 11 most polluted states by month for 2017.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(11).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 11 Polluted States by Month (2017)', width=500, height=300) return chart " 5774,Determine the station exhibiting the 2nd highest average PM2.5 over the Monsoon season of 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 5775,Create a table with mean and standard deviation of PM2.5 by city in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5776,"Compare the monthly average PM2.5 of Bareilly, Nashik, and Thiruvananthapuram in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Bareilly', 'Nashik', 'Thiruvananthapuram'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Bareilly vs Nashik vs Thiruvananthapuram – 2022', width=550, height=320) return chart " 5777,"On August 15, 2021, which station registered the second-lowest PM2.5 concentrations?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 5778,"In January 2019, identify the city with the 3rd lowest median PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 5779,Show a monthly bar chart of the number of days Kerala exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Kerala') & (data['Timestamp'].dt.year == 2023)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Kerala Exceeded WHO PM2.5 Guideline per Month – 2023', width=500, height=300) return chart " 5780,Show a bar chart of the top 6 cities by median PM2.5 in 2020.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2020] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(6, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 6 Cities by Median PM2.5 in 2020', width=500, height=300) return chart " 5781,"Visualize the monthly average PM10 for Haryana, Gujarat, and Chandigarh in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Gujarat', 'Chandigarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Haryana, Gujarat, UP – 2017', width=550, height=320) return chart " 5782,"In October 2022, which city recorded the 2nd lowest 75th percentile of PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 5783,Identify the state that registered the third most minimal PM2.5 level on 27 January 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 5784,Create a ranked table of the 15 best-performing states by PM10 in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 5785,Show how average PM2.5 varied month by month for Meerut in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Meerut'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5786,Which city recorded the peak 75th percentile of PM2.5 during the Winter season of 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 5787,Show a table of average PM2.5 and PM10 for all citys in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5788,Generate a year-by-year summary table of PM2.5 readings for Punjab.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5789,Plot the weekly average PM2.5 for Gummidipoondi in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Gummidipoondi') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Gummidipoondi 2023', width=600, height=300) return chart " 5790,Report the city with the lowest median PM2.5 in July 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 5791,Show a monthly bar chart of the number of days Kerala exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2020.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Kerala') & (data['Timestamp'].dt.year == 2020)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Kerala Exceeded WHO PM2.5 Guideline per Month – 2020', width=500, height=300) return chart " 5792,"Create a table showing top 5 states ranked by PM2.5 in 2023, also showing PM10."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 5793,Create a table of state PM2.5 levels and geographic area for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5794,Generate a city × month cross-tab of mean PM2.5 for Karnataka in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Bagalkot', 'Belgaum', 'Bengaluru', 'Bidar', 'Chamarajanagar', 'Chikkaballapur', 'Chikkamagaluru', 'Davanagere', 'Dharwad', 'Gadag', 'Hassan', 'Haveri', 'Hubballi', 'Kalaburagi', 'Karwar', 'Koppal', 'Madikeri', 'Mangalore', 'Mysuru', 'Raichur', 'Ramanagara', 'Shivamogga', 'Vijayapura', 'Yadgir']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5795,"Create a grouped bar chart comparing the average PM2.5 for Delhi, Nagaland, and Uttarakhand across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Delhi', 'Nagaland', 'Uttarakhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 5796,"In 2022, what was the peak PM2.5 concentration observed?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}] " 5797,"Plot the yearly average PM2.5 trends for Himachal Pradesh, West Bengal, and Jammu and Kashmir from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Himachal Pradesh', 'West Bengal', 'Jammu and Kashmir'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Himachal Pradesh vs West Bengal vs Jammu and Kashmir', width=550, height=320) return chart " 5798,"Create a table showing top 5 states ranked by PM2.5 in 2019, also showing PM10."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 5799,"Compare the monthly average PM2.5 of Chamarajanagar, Ahmedabad, and Indore in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Chamarajanagar', 'Ahmedabad', 'Indore'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Chamarajanagar vs Ahmedabad vs Indore – 2018', width=550, height=320) return chart " 5800,Report which city possessed the 2nd most minimal average PM10 throughout the Post-Monsoon season of 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 5801,"Plot the yearly average PM2.5 trends for Tripura, Arunachal Pradesh, and Puducherry from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tripura', 'Arunachal Pradesh', 'Puducherry'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Tripura vs Arunachal Pradesh vs Puducherry', width=550, height=320) return chart " 5802,Determine the state exhibiting the 2nd lowest average PM10 over the Post-Monsoon season of 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 5803,"Visualize the monthly average PM10 for Himachal Pradesh, Karnataka, and Telangana in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Himachal Pradesh', 'Karnataka', 'Telangana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Himachal Pradesh, Karnataka, UP – 2024', width=550, height=320) return chart " 5804,Show a cumulative area chart of PM2.5 readings for Nagpur across 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Nagpur') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Nagpur 2021', width=600, height=300) return chart " 5805,"Create a grouped bar chart comparing the average PM2.5 for Meghalaya, Jammu and Kashmir, and Jharkhand across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Meghalaya', 'Jammu and Kashmir', 'Jharkhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 5806,"Which state with a land area below 50,000 km² shows the 2nd lowest PM2.5 level, according to its variance of PM2.5 level?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'var', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}] " 5807,Visualize the bottom 13 states with the lowest average PM2.5 in 2020 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2020] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(13, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 13 States by Average PM2.5 in 2020', width=500, height=300) return chart " 5808,Report which state experienced the third lowest 25th percentile of PM2.5 throughout the Monsoon season of 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 5809,Show a table of the 20 cleanest states by average PM10 in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 5810,Show how average PM2.5 varied month by month for Karnataka in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5811,Plot the weekly average PM2.5 for Ratlam in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ratlam') & (data['Timestamp'].dt.year == 2020)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Ratlam 2020', width=600, height=300) return chart " 5812,List all states with their average PM10 and population for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5813,Determine the state with the lowest 25th percentile of PM2.5 in March 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 5814,Show a cumulative area chart of PM2.5 readings for Panipat across 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Panipat') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Panipat 2024', width=600, height=300) return chart " 5815,Determine the second-lowest PM2.5 reading from 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}] " 5816,"On March 31, 2020, which city recorded the minimum median PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 5817,Show how average PM2.5 varied month by month for Mumbai in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Mumbai'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5818,Tabulate average PM10 for each city in Punjab across all months of 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Amritsar', 'Bathinda', 'Jalandhar', 'Khanna', 'Ludhiana', 'Mandi Gobindgarh', 'Patiala', 'Rupnagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5819,Tabulate the monthly mean PM2.5 levels for Nashik during 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Nashik'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5820,List the top 5 citys by average PM10 in 2018 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 5821,"For the period October to December 2022, which station had the third largest decrease in 25th percentile PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 5822,Determine the station with the 3rd highest average PM10 in July 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 5823,Show annual average PM10 for Rajasthan as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5824,Identify the city that registered the second lowest 25th percentile of PM10 during the Winter season of 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 5825,Identify the city that recorded the lowest 25th percentile of PM2.5 value in April 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 5826,"Create a faceted bar chart showing top 11 states by average PM2.5 per year for 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year.isin([2017,2018,2019,2020])].copy() df['Year'] = df['Timestamp'].dt.year agg = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() top = agg.groupby('Year').apply(lambda x: x.nlargest(11,'PM2.5')).reset_index(drop=True) chart = alt.Chart(top).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Avg PM2.5'), y=alt.Y('state:N', sort='-x'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet(facet='Year:O', columns=2).properties(title='Top 11 States by PM2.5 per Year') return chart " 5827,Generate a monthly average PM10 table for Indore for the year 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Indore'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5828,Report the state with the 3rd highest 25th percentile of PM2.5 in March 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 5829,Which station experienced the lowest 75th percentile for PM2.5 in the Post-Monsoon season of 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 5830,Show the monthly average PM10 trend for Navi Mumbai from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Navi Mumbai'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Navi Mumbai (2019–2024)', width=600, height=300) return chart " 5831,Show a monthly bar chart of the number of days Uttar Pradesh exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2017.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Uttar Pradesh') & (data['Timestamp'].dt.year == 2017)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Uttar Pradesh Exceeded WHO PM2.5 Guideline per Month – 2017', width=500, height=300) return chart " 5832,"Scatter plot PM2.5 vs PM10 for Bihar stations in 2023, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Bihar') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Bihar Stations 2023', width=450, height=350) " 5833,Identify the station with the minimum average PM2.5 level in May 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 5834,Generate a city × month cross-tab of mean PM2.5 for Uttar Pradesh in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Agra', 'Baghpat', 'Bareilly', 'Bulandshahr', 'Firozabad', 'Ghaziabad', 'Gorakhpur', 'Greater Noida', 'Hapur', 'Jhansi', 'Kanpur', 'Khurja', 'Lucknow', 'Meerut', 'Moradabad', 'Muzaffarnagar', 'Prayagraj', 'Varanasi', 'Vrindavan']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5835,Plot the yearly average PM2.5 for the top 9 most polluted states from 2017 to 2024 as a multi-line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top5 = data.groupby('state')['PM2.5'].mean().nlargest(9).index.tolist() df = data[data['state'].isin(top5)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends – Top 9 Most Polluted States', width=600, height=350) return chart " 5836,List the top 20 states by PM2.5 in 2018 with both PM2.5 and PM10 averages.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 5837,Plot the rolling 30-day average PM2.5 for Karnataka in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Karnataka') & (data['Timestamp'].dt.year == 2020)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Karnataka 2020', width=600, height=300) " 5838,Report the city that had the 2nd lowest average PM2.5 in September 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 5839,Show a cumulative area chart of PM2.5 readings for Muzaffarnagar across 2019.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Muzaffarnagar') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Muzaffarnagar 2019', width=600, height=300) return chart " 5840,What count of Gujarat stations surpassed the Indian guideline for PM2.5 in 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 60.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 5841,Determine the city with the 2nd highest median PM10 in December 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 5842,"Create a grouped bar chart comparing the average PM2.5 for Telangana, Maharashtra, and Puducherry across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Telangana', 'Maharashtra', 'Puducherry'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 5843,Determine the state with the 2nd lowest median PM2.5 in December 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 5844,Determine which city got the 3rd lowest NCAP funding with respect to its average PM2.5 concentration in 2020 (FY 2019-20).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2020_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 5845,"Plot the yearly average PM2.5 trends for Tripura, Kerala, and Sikkim from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tripura', 'Kerala', 'Sikkim'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Tripura vs Kerala vs Sikkim', width=550, height=320) return chart " 5846,What was the third-lowest PM10 reading in 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'PM10'}}] " 5847,Plot the weekly average PM2.5 for Koppal in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Koppal') & (data['Timestamp'].dt.year == 2020)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Koppal 2020', width=600, height=300) return chart " 5848,"Plot the yearly average PM2.5 trends for Rajasthan, Jammu and Kashmir, and Assam from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Jammu and Kashmir', 'Assam'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Rajasthan vs Jammu and Kashmir vs Assam', width=550, height=320) return chart " 5849,"Comparing December 2023 to October 2023, which station showed the third most significant drop in 25th percentile PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 5850,Tabulate the 15 states with the least PM2.5 pollution in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 5851,"Compare the monthly average PM2.5 of Navi Mumbai, Bhilwara, and Dausa in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Navi Mumbai', 'Bhilwara', 'Dausa'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Navi Mumbai vs Bhilwara vs Dausa – 2022', width=550, height=320) return chart " 5852,"In 2020, which station ranked third for the most substantial fall in average PM2.5 levels from October to December?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 5853,"Plot the yearly average PM2.5 trends for Haryana, Punjab, and Uttar Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Punjab', 'Uttar Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Haryana vs Punjab vs Uttar Pradesh', width=550, height=320) return chart " 5854,Create a statistical summary table of PM10 readings by city for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5855,"In July 2023, which city exhibited the 2nd highest 25th percentile of PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 5856,Generate a dual-pollutant summary table (PM2.5 and PM10) by city for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5857,"Show the variability of PM10 across citys in 2019 using mean, median, and standard deviation."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5858,Generate a table showing the 5 most polluted citys based on mean PM10 for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 5859,Show a cumulative area chart of PM2.5 readings for Purnia across 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Purnia') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Purnia 2023', width=600, height=300) return chart " 5860,"In July 2019, which state registered the lowest 25th percentile of PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 5861,"Compare the monthly average PM2.5 of Mandi Gobindgarh, Madurai, and Lucknow in 2020 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Mandi Gobindgarh', 'Madurai', 'Lucknow'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2020)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Mandi Gobindgarh vs Madurai vs Lucknow – 2020', width=550, height=320) return chart " 5862,"Create a grouped bar chart comparing the average PM2.5 for Madhya Pradesh, Sikkim, and Rajasthan across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Madhya Pradesh', 'Sikkim', 'Rajasthan'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 5863,Show a heatmap of average PM2.5 for the top 5 most polluted states by month for 2019.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(5).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 5 Polluted States by Month (2019)', width=500, height=300) return chart " 5864,Show a monthly bar chart of the number of days Himachal Pradesh exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Himachal Pradesh') & (data['Timestamp'].dt.year == 2023)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Himachal Pradesh Exceeded WHO PM2.5 Guideline per Month – 2023', width=500, height=300) return chart " 5865,Identify the city exhibiting the lowest 25th percentile of PM10 during the Monsoon season of 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 5866,Create a table showing PM10 levels and population for each state in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5867,"In Hubballi, which date in the previous five years showed the second-lowest PM10 concentration?"," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 5}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'Timestamp'}}] " 5868,List the top 20 states by PM2.5 in 2024 with both PM2.5 and PM10 averages.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 5869,Create a summary table ranking the top 15 states by PM2.5 concentration in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 5870,Tabulate the 10 worst citys for average PM2.5 in 2022 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 5871,"Tabulate the distribution of PM10 per state in 2023 including mean, median, and std."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'q25', 'median', 'q75']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5872,"Which city had the peak PM2.5 measurements on January 14, 2020?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 5873,Tabulate average and median PM2.5 for all states in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5874,In which year was the 75th percentile of PM2.5 recorded at its lowest point?," [{'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'Timestamp'}}] " 5875,Which city experienced the third least significant drop in its 75th percentile PM2.5 levels between October and December 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 5876,Determine the station that showed the 2nd lowest average PM2.5 over the Monsoon season of 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 5877,Report the station with the highest median PM2.5 in February 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 5878,Show PM2.5 averages in a state × month matrix for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Arunachal Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Chhattisgarh', 'Delhi', 'Gujarat', 'Haryana', 'Himachal Pradesh', 'Jammu and Kashmir', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Meghalaya', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Sikkim', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh', 'Uttarakhand', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5879,Show a table of the 15 cleanest states by average PM2.5 in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 5880,Identify the state with the lowest 75th percentile of PM10 in December 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 5881,Which 20 states recorded the highest average PM2.5 levels in 2023? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 5882,Report the station that had the highest 25th percentile of PM2.5 in October 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 5883,"Scatter plot PM2.5 vs PM10 for Himachal Pradesh stations in 2023, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Himachal Pradesh') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Himachal Pradesh Stations 2023', width=450, height=350) " 5884,List average PM10 by month for Tamil Nadu in 2024 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5885,Which city registered the highest 75th percentile of PM10 in March 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 5886,Which city exhibited the third largest decrease in its 75th percentile PM2.5 levels between October and December of 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 5887,Which city recorded the 3rd highest 75th percentile of PM10 in August 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 5888,Determine the station exhibiting the 2nd highest median PM10 in December 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 5889,"Plot the yearly average PM2.5 trends for Nagaland, Jammu and Kashmir, and Haryana from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Nagaland', 'Jammu and Kashmir', 'Haryana'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Nagaland vs Jammu and Kashmir vs Haryana', width=550, height=320) return chart " 5890,"Create a table showing top 15 states ranked by PM2.5 in 2020, also showing PM10."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 5891,"Identify the state (excluding UTs) with the largest population among the top 3 most polluted states, based on 75th percentile of PM10 levels."," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 3, 'ret': 'state'}}] " 5892,Which station had the highest 25th percentile of PM2.5 in September 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 5893,Which station had the 2nd highest 75th percentile of PM2.5 in July 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 5894,Tabulate average PM2.5 for each city in Maharashtra across all months of 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Chandrapur']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5895,List how many days each state breached the PM10 limit of 150 µg/m³ in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5896,Identify the city that registered the most minimal 25th percentile of PM10 during the Post-Monsoon season of 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 5897,Tabulate average PM10 for each city in Madhya Pradesh across all months of 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Bhopal', 'Damoh', 'Dewas', 'Gwalior', 'Indore', 'Jabalpur', 'Katni', 'Mandideep', 'Pithampur', 'Ratlam', 'Satna', 'Ujjain']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5898,"Considering all years, which October showed the minimum median PM10 concentration?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'Timestamp'}}] " 5899,"Compare the monthly average PM2.5 of Jalgaon, Barbil, and Badlapur in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Jalgaon', 'Barbil', 'Badlapur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Jalgaon vs Barbil vs Badlapur – 2023', width=550, height=320) return chart " 5900,"Create a grouped bar chart comparing the average PM2.5 for Delhi, Arunachal Pradesh, and Bihar across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Delhi', 'Arunachal Pradesh', 'Bihar'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 5901,"In May 2022, identify the station with the highest 75th percentile of PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 5902,Which state had the 3rd lowest 25th percentile of PM10 in June 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 5903,Determine the station exhibiting the 3rd lowest 75th percentile of PM2.5 in October 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 5904,"Considering 2018, what week number displayed the second-highest average PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'week'}}] " 5905,"Visualize the monthly average PM10 for Kerala, Chandigarh, and Chandigarh in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Kerala', 'Chandigarh', 'Chandigarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Kerala, Chandigarh, UP – 2018', width=550, height=320) return chart " 5906,Tabulate mean PM2.5 and PM10 along with station coverage per state in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}, {'alias': 'Station Count', 'col': 'station', 'fn': 'nunique'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5907,"Determine which state (excluding UTs) has the 3rd largest population within the top 10 most polluted states, based on average PM2.5 levels."," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 10, 'ret': 'state'}}] " 5908,"Plot the yearly average PM2.5 trends for Punjab, Nagaland, and Mizoram from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Punjab', 'Nagaland', 'Mizoram'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Punjab vs Nagaland vs Mizoram', width=550, height=320) return chart " 5909,"Show mean, median, minimum, and maximum PM2.5 for each city in 2017 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5910,"Create a grouped bar chart comparing the average PM2.5 for Delhi, Chhattisgarh, and Arunachal Pradesh across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Delhi', 'Chhattisgarh', 'Arunachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 5911,Report the station that had the highest average PM10 in April 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 5912,"Visualize the monthly average PM10 for Tamil Nadu, Chhattisgarh, and Haryana in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Chhattisgarh', 'Haryana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Tamil Nadu, Chhattisgarh, UP – 2019', width=550, height=320) return chart " 5913,Which city had the lowest 75th percentile of PM2.5 in August 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 5914,Tabulate average PM2.5 for each city in Rajasthan across all months of 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Ajmer', 'Alwar', 'Bhiwadi', 'Jaipur', 'Jodhpur', 'Kota', 'Pali', 'Udaipur']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5915,Plot the weekly average PM2.5 for Rairangpur in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Rairangpur') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Rairangpur 2023', width=600, height=300) return chart " 5916,"Create a grouped bar chart comparing the average PM2.5 for Madhya Pradesh, Jammu and Kashmir, and Andhra Pradesh across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Madhya Pradesh', 'Jammu and Kashmir', 'Andhra Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 5917,Show PM2.5 averages in a state × month matrix for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Arunachal Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Chhattisgarh', 'Delhi', 'Gujarat', 'Haryana', 'Himachal Pradesh', 'Jammu and Kashmir', 'Jharkhand', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Manipur', 'Meghalaya', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh', 'Uttarakhand', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5918,Which city recorded the 3rd lowest median for PM10 in the Post-Monsoon season of 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 5919,List the bottom 10 states with the lowest average PM10 in 2022 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 5920,Tabulate the monthly mean PM10 levels for Prayagraj during 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Prayagraj'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5921,"Plot the yearly average PM2.5 trends for Meghalaya, Telangana, and Tamil Nadu from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Meghalaya', 'Telangana', 'Tamil Nadu'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Meghalaya vs Telangana vs Tamil Nadu', width=550, height=320) return chart " 5922,Identify the city with the lowest 75th percentile of PM10 in July 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 5923,"Taking all years into account, which May had the second-highest 25th percentile for PM2.5 concentration?"," [{'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'Timestamp'}}] " 5924,Create a table of PM10 standard violations (>150 µg/m³) per city in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5925,Tabulate the 15 citys with the least PM2.5 pollution in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 5926,"On March 31, 2018, which city recorded the third-lowest average PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 5927,Which city had the 2nd lowest average PM10 in October 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 5928,Show a pivot table of monthly average PM10 by city for Rajasthan in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Ajmer', 'Alwar', 'Bhiwadi', 'Jaipur', 'Jodhpur', 'Kota', 'Pali', 'Udaipur']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5929,Plot the rolling 30-day average PM2.5 for Kerala in 2018 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Kerala') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Kerala 2018', width=600, height=300) " 5930,Which 10 states recorded the highest average PM10 levels in 2023? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 5931,"In May 2023, which city recorded the 3rd highest average PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 5932,Generate a city × month cross-tab of mean PM2.5 for Haryana in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Haryana'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Ambala', 'Bahadurgarh', 'Ballabgarh', 'Bhiwani', 'Charkhi Dadri', 'Dharuhera', 'Faridabad', 'Fatehabad', 'Gurugram', 'Hisar', 'Jind', 'Kaithal', 'Karnal', 'Kurukshetra', 'Mandikhera', 'Manesar', 'Narnaul', 'Palwal', 'Panchkula', 'Rohtak', 'Sirsa', 'Sonipat', 'Yamuna Nagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5933,Generate a city × month cross-tab of mean PM10 for Kerala in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Thiruvananthapuram']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5934,Identify the state that experienced the second highest drop in average PM10 levels when comparing December 2021 to October 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 5935,"Which state (excluding Union Territories) possesses the 3rd largest land area among the top 10 most polluted states, based on total PM2.5 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'sum', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 10, 'ret': 'state'}}] " 5936,"Visualize the monthly average PM10 for Jharkhand, Nagaland, and Jharkhand in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Nagaland', 'Jharkhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Jharkhand, Nagaland, UP – 2019', width=550, height=320) return chart " 5937,"Compare the monthly average PM2.5 of Bengaluru, Shillong, and Sangli in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Bengaluru', 'Shillong', 'Sangli'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Bengaluru vs Shillong vs Sangli – 2017', width=550, height=320) return chart " 5938,Tabulate average PM2.5 for each state across all months in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Arunachal Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Chhattisgarh', 'Delhi', 'Gujarat', 'Haryana', 'Himachal Pradesh', 'Jammu and Kashmir', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Meghalaya', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Sikkim', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh', 'Uttarakhand', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5939,List how many days each state breached the PM2.5 limit of 60 µg/m³ in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5940,Tabulate daily PM2.5 exceedances (above 100 µg/m³) per city for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5941,Which state noted the peak average PM2.5 during the Summer season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 5942,Which city displayed the lowest 25th percentile of PM2.5 in October 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 5943,Plot the monthly average PM2.5 trend for Jammu and Kashmir from 2017 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Jammu and Kashmir'].copy() df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly Average PM2.5 Trend – Jammu and Kashmir (2017–2024)', width=600, height=300) return chart " 5944,Plot the weekly average PM2.5 for Rajamahendravaram in 2021 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Rajamahendravaram') & (data['Timestamp'].dt.year == 2021)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Rajamahendravaram 2021', width=600, height=300) return chart " 5945,Tabulate the yearly average PM10 trend for Haryana across all years.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Haryana'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5946,Show the monthly average PM10 trend for Buxar from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Buxar'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Buxar (2019–2024)', width=600, height=300) return chart " 5947,Show the monthly average PM2.5 for Ramanathapuram in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ramanathapuram') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Ramanathapuram 2018', width=450, height=280) " 5948,"Which state (excluding Union Territories) has the 2nd minimum land area among the top 5 most polluted states, according to the 75th percentile of PM10 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 5, 'ret': 'state'}}] " 5949,"In 2024, which state will rank with the second largest reduction in median PM2.5 levels from October to December?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 5950,Generate a city × month cross-tab of mean PM2.5 for Madhya Pradesh in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Damoh', 'Dewas', 'Mandideep', 'Pithampur', 'Ratlam', 'Satna', 'Singrauli', 'Ujjain']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5951,Show PM2.5 exceedance count and rate (%) above 60 µg/m³ per city in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5952,Tabulate both PM2.5 and PM10 averages by state for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5953,Generate a monthly average PM2.5 table for Pune for the year 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Pune'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5954,"Show descriptive statistics of PM2.5 (mean, median, std, min, max) per state in 2022."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'q25', 'median', 'q75']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5955,"Show the variability of PM2.5 across citys in 2020 using mean, median, and standard deviation."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5956,How many times did Jhunjhunu city surpass the Indian guideline for PM10 in 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 60.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 5957,"In July 2020, report the state with the lowest 25th percentile of PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 5958,Identify the state with the 2nd lowest 75th percentile of PM2.5 in August 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 5959,Plot a heatmap of average PM10 by state (y-axis) and month (x-axis) for 2019.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2019].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM10'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), title='Avg PM10'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='PM10 Heatmap by State and Month – 2019', width=500, height=400) return chart " 5960,"Visualize the monthly average PM10 for Jharkhand, Mizoram, and Arunachal Pradesh in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Mizoram', 'Arunachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Jharkhand, Mizoram, UP – 2018', width=550, height=320) return chart " 5961,Plot the weekly average PM2.5 for Kohima in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Kohima') & (data['Timestamp'].dt.year == 2020)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Kohima 2020', width=600, height=300) return chart " 5962,"Which state (excluding UTs) possesses the smallest population among the top 5 most polluted states, determined by the 25th percentile of PM2.5 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 5, 'ret': 'state'}}] " 5963,Show a cumulative area chart of PM2.5 readings for Mangalore across 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Mangalore') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Mangalore 2021', width=600, height=300) return chart " 5964,Identify the state that showed the second lowest 25th percentile of PM2.5 during the Monsoon season of 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 5965,Create a heatmap showing the average PM2.5 by month (x-axis) and year (y-axis) for Tripura.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Tripura'].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Year:N', title='Year'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='Avg PM2.5'), tooltip=['Year:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Tripura (Month × Year)', width=500, height=280) return chart " 5966,Plot the top 10 states by average PM2.5 in 2024 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2024] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(10, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 10 States by Average PM2.5 in 2024', width=500, height=300) return chart " 5967,Plot the top 15 states by average PM2.5 in 2018 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2018] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(15, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 15 States by Average PM2.5 in 2018', width=500, height=300) return chart " 5968,Generate a year-by-year summary table of PM2.5 readings for Meerut.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Meerut'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5969,Determine the city with the highest 75th percentile of PM10 in November 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 5970,Show a monthly breakdown table of average PM10 for Kerala in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5971,"Scatter plot PM2.5 vs PM10 for Kerala stations in 2021, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Kerala') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Kerala Stations 2021', width=450, height=350) " 5972,"Visualize the monthly average PM10 for Meghalaya, Gujarat, and Chhattisgarh in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Meghalaya', 'Gujarat', 'Chhattisgarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Meghalaya, Gujarat, UP – 2022', width=550, height=320) return chart " 5973,Which 20 citys had the lowest mean PM10 in 2023? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 5974,"Determine the union territory, from those with populations exceeding the 25th percentile, which is allocated the lowest per capita NCAP funding."," [{'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_capita', 'numerator': 'total_fund', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'funding_per_capita', 'ascending': True}}] " 5975,Identify the city that experienced the largest increase in funding between FY 2019-20 and FY 2020-21.," [{'op': 'AGG', 'params': {'by': 'city', 'fn': 'sum', 'col': 'change'}}, {'op': 'SORT', 'params': {'col': 'change', 'ascending': True}}] " 5976,Identify the city with the 2nd lowest 75th percentile of PM2.5 for May 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 5977,Show a bar chart of the top 9 cities by median PM2.5 in 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2023] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(9, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 9 Cities by Median PM2.5 in 2023', width=500, height=300) return chart " 5978,Plot the weekly average PM2.5 for Bahadurgarh in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bahadurgarh') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Bahadurgarh 2023', width=600, height=300) return chart " 5979,List the bottom 5 citys with the lowest average PM2.5 in 2022 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 5980,List states ranked by PM10 concentration relative to their area in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM10 per km²', 'numerator': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)', 'PM10 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5981,Show the PM2.5 per 1000 km² (air quality density) for each state in 2023 as a bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): pm = data[data['Timestamp'].dt.year == 2023].groupby('state')['PM2.5'].mean().reset_index().dropna() df = pm.merge(states_data[['state','area (km2)']], on='state') df['PM2.5 per 1000 km²'] = df['PM2.5'] / df['area (km2)'] * 1000 df = df.sort_values('PM2.5 per 1000 km²', ascending=False) chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5 per 1000 km²:Q', title='PM2.5 per 1000 km²'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5 per 1000 km²:Q', scale=alt.Scale(scheme='orangered'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5 per 1000 km²:Q', format='.3f')] ).properties(title='Air Quality Density (PM2.5 per 1000 km²) by State – 2023', width=500, height=400) return chart " 5982,"Report the state (excluding UTs) having the smallest population among the top 10 most polluted states, when pollution is measured by median PM2.5 levels."," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 10, 'ret': 'state'}}] " 5983,Show the monthly average PM10 trend for Sirsa from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Sirsa'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Sirsa (2019–2024)', width=600, height=300) return chart " 5984,List the bottom 5 citys with the lowest average PM10 in 2017 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 5985,List the average PM2.5 for Nagaland broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Nagaland'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5986,"Considering all years, which April showed the highest 75th percentile for PM2.5 concentration?"," [{'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'Timestamp'}}] " 5987,Identify the state that recorded the 2nd highest 25th percentile of PM10 value in April 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 5988,"Determine which state (excluding UTs) has the 3rd largest population within the top 3 most polluted states, based on standard deviation of PM2.5 levels."," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'std', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 3, 'ret': 'state'}}] " 5989,Generate a city × month cross-tab of mean PM2.5 for Gujarat in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Gujarat'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Ahmedabad', 'Ankleshwar', 'Gandhinagar', 'Nandesari', 'Vapi', 'Vatva']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5990,Which station noted the peak 75th percentile of PM2.5 in the Post-Monsoon season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 5991,Report the city with the 5th most significant reduction in funding between FY 2020-21 and FY 2021-22.," [{'op': 'AGG', 'params': {'by': 'city', 'fn': 'sum', 'col': 'change'}}, {'op': 'SORT', 'params': {'col': 'change', 'ascending': False}}] " 5992,Plot the distribution of PM2.5 values in Rajasthan across all years using a histogram.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Rajasthan'].dropna(subset=['PM2.5']) df = df[['PM2.5']] chart = alt.Chart(df).mark_bar(color='steelblue', opacity=0.75).encode( x=alt.X('PM2\.5:Q', bin=alt.Bin(maxbins=40), title='PM2.5 (µg/m³)'), y=alt.Y('count()', title='Number of Observations'), tooltip=[alt.Tooltip('PM2\.5:Q', bin=True), 'count()'] ).properties(title='PM2.5 Distribution – Rajasthan (All Years)', width=500, height=300) return chart " 5993,Show a heatmap of average PM2.5 for the top 9 most polluted states by month for 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(9).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 9 Polluted States by Month (2021)', width=500, height=300) return chart " 5994,Determine the station with the 3rd highest 25th percentile of PM2.5 in August 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 5995,Show the monthly average PM2.5 for Indore in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Indore') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Indore 2020', width=450, height=280) " 5996,Create a summary table comparing mean PM2.5 and PM10 across citys in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5997,List states by PM10 concentration per million inhabitants in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM10 per million', 'numerator': 'PM10', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'PM10 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5998,List citys with their PM10 violation count and rate (>100 µg/m³) in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 5999,Generate a city × month cross-tab of mean PM2.5 for Assam in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Assam'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Byrnihat', 'Guwahati', 'Nalbari', 'Silchar', 'Sivasagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6000,Show a cumulative area chart of PM2.5 readings for Kanpur across 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Kanpur') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Kanpur 2018', width=600, height=300) return chart " 6001,Show the monthly average PM10 trend for Panipat from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Panipat'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Panipat (2019–2024)', width=600, height=300) return chart " 6002,Show a pivot table of monthly average PM2.5 by city for West Bengal in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'West Bengal'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Asansol', 'Barrackpore', 'Durgapur', 'Haldia', 'Howrah', 'Kolkata', 'Siliguri']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6003,Plot the weekly average PM2.5 for Chengalpattu in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Chengalpattu') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Chengalpattu 2023', width=600, height=300) return chart " 6004,Report the city that obtained the 5th lowest NCAP funding.," [] " 6005,"Tabulate the distribution of PM2.5 per city in 2023 including mean, median, and std."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6006,Create a grouped bar chart comparing the average PM2.5 in Winter vs Summer for the top 6 most polluted states.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top6 = data.groupby('state')['PM2.5'].mean().nlargest(6).index.tolist() df = data[data['state'].isin(top6)].copy() df['Season'] = df['Timestamp'].dt.month.apply( lambda m: 'Winter' if m in [12,1,2] else ('Summer' if m in [3,4,5] else None)) df = df.dropna(subset=['Season']) df = df.groupby(['state','Season'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('state:N', title='State'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('Season:N', title='Season'), xOffset='Season:N', tooltip=['state:N','Season:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Winter vs Summer PM2.5 – Top 6 Polluted States', width=550, height=320) return chart " 6007,Show PM2.5 exceedance count and rate (%) above 100 µg/m³ per city in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6008,"Visualize the monthly average PM10 for Tamil Nadu, Madhya Pradesh, and Arunachal Pradesh in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Madhya Pradesh', 'Arunachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Tamil Nadu, Madhya Pradesh, UP – 2019', width=550, height=320) return chart " 6009,Show a pivot table of monthly average PM2.5 by state for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Delhi', 'Gujarat', 'Haryana', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Meghalaya', 'Odisha', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6010,Tabulate the yearly average PM2.5 trend for Ghaziabad across all years.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Ghaziabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6011,Plot the yearly average PM2.5 for the top 6 most polluted states from 2017 to 2024 as a multi-line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top5 = data.groupby('state')['PM2.5'].mean().nlargest(6).index.tolist() df = data[data['state'].isin(top5)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends – Top 6 Most Polluted States', width=600, height=350) return chart " 6012,Show a cumulative area chart of PM2.5 readings for Nanded across 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Nanded') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Nanded 2023', width=600, height=300) return chart " 6013,"Plot the yearly average PM2.5 trends for Chhattisgarh, Manipur, and West Bengal from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chhattisgarh', 'Manipur', 'West Bengal'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Chhattisgarh vs Manipur vs West Bengal', width=550, height=320) return chart " 6014,Create a table of PM2.5 exceedance frequency above 100 µg/m³ by city for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6015,Plot the top 15 states by average PM2.5 in 2022 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2022] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(15, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 15 States by Average PM2.5 in 2022', width=500, height=300) return chart " 6016,Tabulate the monthly mean PM2.5 levels for Noida during 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Noida'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6017,Report which city possessed the peak 25th percentile of PM2.5 throughout the Monsoon season of 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 6018,"Show the mean, median and standard deviation of PM10 per state in 2017 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6019,Show the monthly average PM2.5 for Rupnagar in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Rupnagar') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Rupnagar 2020', width=450, height=280) " 6020,"On March 31, 2019, which station recorded the third-lowest median PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 6021,Show the number of days each city exceeded a PM2.5 threshold of 100 µg/m³ in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6022,List how many days each city breached the PM2.5 limit of 60 µg/m³ in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6023,Report the station with the 3rd lowest average PM10 in April 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 6024,Tabulate daily PM10 exceedances (above 100 µg/m³) per state for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6025,Show the monthly average PM10 trend for Nagpur from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Nagpur'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Nagpur (2019–2024)', width=600, height=300) return chart " 6026,Which station exhibited the largest decrease in its 75th percentile PM2.5 levels between October and December of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 6027,Show a heatmap of average PM2.5 for the top 12 most polluted states by month for 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(12).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 12 Polluted States by Month (2018)', width=500, height=300) return chart " 6028,"Scatter plot PM2.5 vs PM10 for Jammu and Kashmir stations in 2023, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Jammu and Kashmir') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Jammu and Kashmir Stations 2023', width=450, height=350) " 6029,"Plot the yearly average PM2.5 trends for Andhra Pradesh, Chhattisgarh, and Mizoram from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Chhattisgarh', 'Mizoram'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Andhra Pradesh vs Chhattisgarh vs Mizoram', width=550, height=320) return chart " 6030,How many times did Meghalaya surpass 45 µg/m³ of PM10 in the year 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 45.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 6031,"Compare the monthly average PM2.5 of Ankleshwar, Asansol, and Pathardih in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Ankleshwar', 'Asansol', 'Pathardih'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Ankleshwar vs Asansol vs Pathardih – 2023', width=550, height=320) return chart " 6032,"Compare the monthly average PM2.5 of Gorakhpur, Araria, and Ajmer in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Gorakhpur', 'Araria', 'Ajmer'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Gorakhpur vs Araria vs Ajmer – 2024', width=550, height=320) return chart " 6033,"Show mean, median, minimum, and maximum PM10 for each city in 2020 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6034,How many times did Mysuru city surpass 30 µg/m³ of PM2.5 in 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 30.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 6035,Report the state with the 2nd highest average PM2.5 in June 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 6036,Generate a year-by-year summary table of PM10 readings for Gujarat.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Gujarat'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6037,Report which city experienced the 2nd most minimal average PM10 throughout the Monsoon season of 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 6038,"In November 2021, report the station with the 3rd highest 25th percentile of PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 6039,"Visualize the monthly average PM10 for Tripura, Meghalaya, and Sikkim in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tripura', 'Meghalaya', 'Sikkim'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Tripura, Meghalaya, UP – 2024', width=550, height=320) return chart " 6040,Show the monthly average PM2.5 for Chhal in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Chhal') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Chhal 2019', width=450, height=280) " 6041,"Identify the state that registered the third-lowest PM10 levels on August 15, 2020."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 6042,"Visualize the monthly average PM10 for Odisha, Gujarat, and Delhi in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Odisha', 'Gujarat', 'Delhi'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Odisha, Gujarat, UP – 2021', width=550, height=320) return chart " 6043,"Compare the monthly average PM2.5 of Raichur, Ghaziabad, and Mira-Bhayandar in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Raichur', 'Ghaziabad', 'Mira-Bhayandar'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Raichur vs Ghaziabad vs Mira-Bhayandar – 2024', width=550, height=320) return chart " 6044,"Which union territory possesses the smallest land area among the top 4 most polluted union territories, based on the variance of PM2.5 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'var', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 4, 'ret': 'state'}}] " 6045,Determine the station exhibiting the highest average PM10 in November 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 6046,Generate a city × month cross-tab of mean PM2.5 for Bihar in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Bihar'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Gaya', 'Patna']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6047,"Which station showed the second-highest average PM2.5 on March 31, 2019?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 6048,Create a month-wise PM2.5 breakdown table across cities in Tamil Nadu for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Ariyalur', 'Chengalpattu', 'Chennai', 'Coimbatore', 'Cuddalore', 'Gummidipoondi', 'Ooty', 'Palkalaiperur', 'Ramanathapuram', 'Tirupur', 'Vellore', 'Virudhunagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6049,"Show descriptive statistics of PM2.5 (mean, median, std, min, max) per city in 2022."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'q25', 'median', 'q75']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6050,How many times did Madhya Pradesh go above the Indian guideline for PM2.5 in the year 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 60.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 6051,Show the monthly average PM10 trend for Aizawl from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Aizawl'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Aizawl (2019–2024)', width=600, height=300) return chart " 6052,Determine the station exhibiting the 2nd lowest 75th percentile of PM10 in February 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 6053,Identify the station exhibiting the second lowest average PM2.5 during the Post-Monsoon season of 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 6054,Report the state with the 2nd highest 25th percentile of PM10 in August 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 6055,Create a table showing annual mean PM2.5 levels for Guwahati (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Guwahati'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6056,Identify the city with the second-most minimal median PM2.5 in May 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 6057,Show the monthly average PM2.5 for Gujarat across each year from 2017 to 2024 as small multiples (faceted by year).," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Gujarat'].copy() df['Year'] = df['Timestamp'].dt.year df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5'), tooltip=['Year:O','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet( facet=alt.Facet('Year:O', title='Year'), columns=4 ).properties(title='Monthly PM2.5 in Gujarat by Year (2017–2024)') return chart " 6058,Show how average PM2.5 varied month by month for Tamil Nadu in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6059,Create a month-wise PM10 breakdown table across cities in Rajasthan for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Ajmer', 'Alwar', 'Bhiwadi', 'Jaipur', 'Jodhpur', 'Kota', 'Pali', 'Sirohi', 'Udaipur']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6060,Which city recorded the lowest 25th percentile of PM2.5 in August 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 6061,Show the monthly average PM10 trend for Tonk from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Tonk'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Tonk (2019–2024)', width=600, height=300) return chart " 6062,Determine the station that recorded the 3rd lowest average PM10 over the Monsoon season of 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 6063,Which city had the 3rd lowest 25th percentile of PM2.5 in August 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 6064,Report which state experienced the peak median PM2.5 throughout the Monsoon season of 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 6065,"In 2019, which station will rank third for the smallest reduction in average PM10 levels from October to December?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 6066,Identify the city with the 3rd highest percentage utilization of its allocated NCAP funds as of June 2022.," [{'op': 'SORT', 'params': {'col': 'utilisation_percent', 'ascending': False}}] " 6067,Show the monthly average PM10 trend for Hosur from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Hosur'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Hosur (2017–2022)', width=600, height=300) return chart " 6068,Show a cumulative area chart of PM2.5 readings for Rupnagar across 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Rupnagar') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Rupnagar 2018', width=600, height=300) return chart " 6069,Which station registered the second-highest average PM10 in March 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 6070,Show a table of the 15 cleanest states by average PM10 in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 6071,"Plot the yearly average PM2.5 trends for Manipur, Sikkim, and Chhattisgarh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Manipur', 'Sikkim', 'Chhattisgarh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Manipur vs Sikkim vs Chhattisgarh', width=550, height=320) return chart " 6072,Show the monthly average PM10 trend for Rohtak from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Rohtak'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Rohtak (2017–2022)', width=600, height=300) return chart " 6073,"In February 2021, report the city with the highest 25th percentile of PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 6074,"Show average PM2.5, PM10 and the number of monitoring stations per state in 2023."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}, {'alias': 'Station Count', 'col': 'station', 'fn': 'nunique'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6075,"For Nandesari, what date in the last three years showed the lowest PM2.5 reading?"," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 3}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'Timestamp'}}] " 6076,Show the monthly average PM10 trend for Barmer from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Barmer'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Barmer (2019–2024)', width=600, height=300) return chart " 6077,Create a grouped bar chart comparing the average PM2.5 in Winter vs Summer for the top 14 most polluted states.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top6 = data.groupby('state')['PM2.5'].mean().nlargest(14).index.tolist() df = data[data['state'].isin(top6)].copy() df['Season'] = df['Timestamp'].dt.month.apply( lambda m: 'Winter' if m in [12,1,2] else ('Summer' if m in [3,4,5] else None)) df = df.dropna(subset=['Season']) df = df.groupby(['state','Season'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('state:N', title='State'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('Season:N', title='Season'), xOffset='Season:N', tooltip=['state:N','Season:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Winter vs Summer PM2.5 – Top 14 Polluted States', width=550, height=320) return chart " 6078,List the top 15 states by PM2.5 in 2023 with both PM2.5 and PM10 averages.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 6079,Tabulate mean PM2.5 and land area for each state in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6080,"In the year 2020, which season (Winter, Summer, Monsoon, Post-Monsoon) recorded the highest 75th percentile for PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'season'}}] " 6081,Plot the rolling 30-day average PM2.5 for Tripura in 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Tripura') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Tripura 2022', width=600, height=300) " 6082,Create a month-wise PM10 breakdown table across cities in Madhya Pradesh for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Dewas', 'Mandideep', 'Pithampur', 'Singrauli', 'Ujjain']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6083,How many times did Gujarat surpass the WHO guideline for PM10 in the year 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 15.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 6084,Generate a city × month cross-tab of mean PM10 for Tamil Nadu in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Chennai', 'Coimbatore']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6085,Create a month-wise summary of average PM2.5 for Andhra Pradesh in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6086,"Compare the monthly average PM2.5 of Rajgir, Gurugram, and Vijayapura in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Rajgir', 'Gurugram', 'Vijayapura'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Rajgir vs Gurugram vs Vijayapura – 2024', width=550, height=320) return chart " 6087,"For the period October to December 2023, which city had the third smallest decrease in 25th percentile PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 6088,How many times did Gujarat exceed the Indian guideline for PM2.5 in the year 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 60.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 6089,"In 2021, which station will rank with the largest reduction in average PM10 levels from October to December?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 6090,Which station registered the 3rd lowest median PM10 in the Winter season of 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 6091,"Comparing December 2024 to October 2024, which state showed the third most significant drop in average PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 6092,"Create a grouped bar chart comparing the average PM2.5 for West Bengal, Nagaland, and Chandigarh across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['West Bengal', 'Nagaland', 'Chandigarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 6093,"On January 5, 2019, which station recorded the third-lowest average PM10 concentration?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 6094,Which station recorded the 2nd highest average PM10 in July 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 6095,"Visualize the monthly average PM10 for Manipur, Sikkim, and Kerala in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Manipur', 'Sikkim', 'Kerala'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Manipur, Sikkim, UP – 2018', width=550, height=320) return chart " 6096,Show a table of the 5 cleanest states by average PM10 in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 6097,"Compare the monthly average PM2.5 of Kochi, Samastipur, and Pudukottai in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Kochi', 'Samastipur', 'Pudukottai'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Kochi vs Samastipur vs Pudukottai – 2022', width=550, height=320) return chart " 6098,"Visualize the monthly average PM10 for Mizoram, Sikkim, and Madhya Pradesh in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Mizoram', 'Sikkim', 'Madhya Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Mizoram, Sikkim, UP – 2017', width=550, height=320) return chart " 6099,"Visualize the monthly average PM10 for Punjab, Jammu and Kashmir, and Gujarat in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Punjab', 'Jammu and Kashmir', 'Gujarat'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Punjab, Jammu and Kashmir, UP – 2023', width=550, height=320) return chart " 6100,"Plot the yearly average PM2.5 trends for Sikkim, Gujarat, and Kerala from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Sikkim', 'Gujarat', 'Kerala'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Sikkim vs Gujarat vs Kerala', width=550, height=320) return chart " 6101,Show the PM2.5 per 1000 km² (air quality density) for each state in 2017 as a bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): pm = data[data['Timestamp'].dt.year == 2017].groupby('state')['PM2.5'].mean().reset_index().dropna() df = pm.merge(states_data[['state','area (km2)']], on='state') df['PM2.5 per 1000 km²'] = df['PM2.5'] / df['area (km2)'] * 1000 df = df.sort_values('PM2.5 per 1000 km²', ascending=False) chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5 per 1000 km²:Q', title='PM2.5 per 1000 km²'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5 per 1000 km²:Q', scale=alt.Scale(scheme='orangered'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5 per 1000 km²:Q', format='.3f')] ).properties(title='Air Quality Density (PM2.5 per 1000 km²) by State – 2017', width=500, height=400) return chart " 6102,List the bottom 15 states with the lowest average PM10 in 2022 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 6103,Create a table of PM10 exceedance frequency above 100 µg/m³ by state for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6104,Determine the average PM10 level on Wednesdays in Chandigarh.," [{'op': 'FILTER', 'params': {'field': 'state', 'value': 'Chandigarh'}}] " 6105,Show the monthly average PM10 trend for Bhopal from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Bhopal'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Bhopal (2019–2024)', width=600, height=300) return chart " 6106,Which city recorded the peak average PM2.5 during the Post-Monsoon season of 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 6107,"Plot the yearly average PM2.5 trends for Telangana, Rajasthan, and Bihar from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Telangana', 'Rajasthan', 'Bihar'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Telangana vs Rajasthan vs Bihar', width=550, height=320) return chart " 6108,Show the monthly average PM2.5 for Akola in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Akola') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Akola 2017', width=450, height=280) " 6109,Show a monthly breakdown table of average PM2.5 for Guwahati in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Guwahati'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6110,"Visualize the monthly average PM10 for Chandigarh, Sikkim, and Karnataka in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chandigarh', 'Sikkim', 'Karnataka'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Chandigarh, Sikkim, UP – 2021', width=550, height=320) return chart " 6111,Determine the city with the 2nd lowest 25th percentile of PM10 in October 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 6112,Which station showed the second-minimum 25th percentile for PM2.5 in December 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 6113,Tabulate average PM2.5 for each city in Punjab across all months of 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Amritsar', 'Bathinda', 'Jalandhar', 'Khanna', 'Ludhiana', 'Mandi Gobindgarh', 'Patiala', 'Rupnagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6114,Which state had the 3rd lowest 25th percentile of PM10 in December 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 6115,Report which station registered the 3rd most minimal 25th percentile of PM2.5 throughout the Winter season of 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 6116,Show the monthly average PM10 trend for Dharuhera from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Dharuhera'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Dharuhera (2019–2024)', width=600, height=300) return chart " 6117,Which city registered the 2nd lowest 25th percentile of PM10 during October 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 6118,Plot the weekly average PM2.5 for Guwahati in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Guwahati') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Guwahati 2023', width=600, height=300) return chart " 6119,"Determine which state (excluding UTs) has the largest population among the top 5 most polluted states, based on 75th percentile of PM2.5 levels."," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 5, 'ret': 'state'}}] " 6120,"Tabulate PM2.5 statistics (mean, std, min, max) for each city in 2024."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6121,Create a table of PM2.5 standard violations (>60 µg/m³) per state in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6122,List states with their PM2.5 violation count and rate (>60 µg/m³) in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6123,Show the monthly average PM2.5 for Bhilai in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bhilai') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Bhilai 2018', width=450, height=280) " 6124,Tabulate the monthly mean PM10 levels for Kerala during 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6125,Tabulate the 20 citys with the least PM2.5 pollution in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 6126,Which state registered the highest 75th percentile of PM10 during April 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 6127,Tabulate average PM2.5 for each state across all months in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Arunachal Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Chhattisgarh', 'Delhi', 'Gujarat', 'Haryana', 'Jammu and Kashmir', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Meghalaya', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6128,"Show mean, median, minimum, and maximum PM2.5 for each state in 2018 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6129,"On March 31, 2022, which city recorded the highest 25th percentile for PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 6130,"In June 2020, identify the city with the 3rd highest 25th percentile of PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 6131,Report which state possessed the third lowest median PM10 throughout the Summer season of 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 6132,Show the number of days each state exceeded a PM2.5 threshold of 100 µg/m³ in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6133,"Visualize the monthly average PM10 for Mizoram, Jammu and Kashmir, and Meghalaya in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Mizoram', 'Jammu and Kashmir', 'Meghalaya'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Mizoram, Jammu and Kashmir, UP – 2024', width=550, height=320) return chart " 6134,Show the monthly average PM2.5 for Manguraha in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Manguraha') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Manguraha 2017', width=450, height=280) " 6135,Tabulate the 20 worst citys for average PM10 in 2022 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 6136,Create a table showing annual mean PM2.5 levels for Punjab (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6137,Plot the monthly average PM2.5 trend for Jharkhand from 2017 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Jharkhand'].copy() df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly Average PM2.5 Trend – Jharkhand (2017–2024)', width=600, height=300) return chart " 6138,How many times did Udupi city go above 90 µg/m³ of PM2.5 in 2017?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 90.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 6139,"Visualize the monthly average PM10 for Himachal Pradesh, Tripura, and Puducherry in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Himachal Pradesh', 'Tripura', 'Puducherry'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Himachal Pradesh, Tripura, UP – 2024', width=550, height=320) return chart " 6140,Which station had the highest 75th percentile of PM2.5 in July 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 6141,Show the monthly average PM2.5 for Moradabad in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Moradabad') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Moradabad 2019', width=450, height=280) " 6142,Which weekday in 2020 was linked to the third-highest average PM10 pollution levels?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'Timestamp'}}] " 6143,Create a heatmap showing the average PM2.5 by month (x-axis) and year (y-axis) for Karnataka.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Karnataka'].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Year:N', title='Year'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='Avg PM2.5'), tooltip=['Year:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Karnataka (Month × Year)', width=500, height=280) return chart " 6144,Determine the state exhibiting the 3rd lowest 75th percentile of PM10 over the Winter season of 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 6145,Show how many times PM2.5 exceeded 60 µg/m³ per day across states in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6146,"Visualize the monthly average PM10 for Telangana, Tamil Nadu, and Manipur in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Telangana', 'Tamil Nadu', 'Manipur'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Telangana, Tamil Nadu, UP – 2024', width=550, height=320) return chart " 6147,Show PM2.5 exceedances above the Indian standard (60 µg/m³) per year as a bar chart for West Bengal.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'West Bengal'].dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 60].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby('Year')['Timestamp'].nunique().reset_index() df.columns = ['Year','Days Exceeded'] chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('Year:N', title='Year'), y=alt.Y('Days Exceeded:Q', title='Days PM2.5 > 60 µg/m³'), tooltip=['Year:N','Days Exceeded:Q'] ).properties(title='Days West Bengal Exceeded Indian PM2.5 Standard (60 µg/m³) per Year', width=450, height=300) return chart " 6148,"Create a grouped bar chart comparing the average PM2.5 for Chandigarh, Jammu and Kashmir, and Assam across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chandigarh', 'Jammu and Kashmir', 'Assam'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 6149,"Compare the monthly average PM2.5 of Nagaur, Cuttack, and Siliguri in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Nagaur', 'Cuttack', 'Siliguri'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Nagaur vs Cuttack vs Siliguri – 2022', width=550, height=320) return chart " 6150,"On March 31, 2021, which city recorded the second-highest median PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 6151,Determine the state exhibiting the 2nd highest 75th percentile of PM10 over the Post-Monsoon season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 6152,Show a year-wise table of average PM2.5 for Mizoram from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Mizoram'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6153,Which station had the highest median PM10 in July 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 6154,"Report the state (excluding UTs) having the 3rd largest population among the top 3 most polluted states, when pollution is measured by 25th percentile of PM10 levels."," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 3, 'ret': 'state'}}] " 6155,Plot total NCAP funding vs total fund utilisation for each state as a grouped bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = ncap_funding_data.groupby('state')[ ['Total fund released','Utilisation as on June 2022']].sum().reset_index() df = df.melt(id_vars='state', var_name='Type', value_name='Amount (Cr)') chart = alt.Chart(df).mark_bar().encode( x=alt.X('state:N', title='State'), y=alt.Y('Amount (Cr):Q', title='Amount (Crores)'), color=alt.Color('Type:N', title=''), xOffset='Type:N', tooltip=['state:N','Type:N', alt.Tooltip('Amount (Cr):Q', format='.1f')] ).properties(title='NCAP Funding Released vs Utilised by State', width=550, height=320) return chart " 6156,Show a pivot table of monthly average PM2.5 by city for Kerala in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Eloor', 'Kannur', 'Kochi', 'Kollam', 'Thiruvananthapuram', 'Thrissur']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6157,Show a year-wise table of average PM2.5 for Raipur from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Raipur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6158,Show the monthly average PM2.5 for Bhiwani in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bhiwani') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Bhiwani 2018', width=450, height=280) " 6159,Which station had the highest 25th percentile of PM10 in November 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 6160,Generate a descriptive stats table for PM10 grouped by state in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6161,List the bottom 15 states with the lowest average PM2.5 in 2018 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 6162,Which Indian city registered the 3rd maximum PM10 levels for a single day in the previous decade?," [{'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'eq_rank', 'rank': -3}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'count'}}, {'op': 'SORT', 'params': {'col': 'count', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 6163,"Which state (excluding UTs) possesses the 3rd largest population within the top 5 most polluted states, determined by the 25th percentile of PM10 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 5, 'ret': 'state'}}] " 6164,Visualize the bottom 14 states with the lowest average PM2.5 in 2019 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2019] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(14, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 14 States by Average PM2.5 in 2019', width=500, height=300) return chart " 6165,How many times did Haryana exceed the WHO guideline for PM2.5 in 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 15.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 6166,Which city noted the minimum 25th percentile of PM10 during the Post-Monsoon season of 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 6167,"Create a grouped bar chart comparing the average PM2.5 for Jammu and Kashmir, Arunachal Pradesh, and West Bengal across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jammu and Kashmir', 'Arunachal Pradesh', 'West Bengal'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 6168,"In January 2021, identify the city with the 2nd lowest average PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 6169,"In December 2020, which city exhibited the lowest 75th percentile of PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 6170,"Create a grouped bar chart comparing the average PM2.5 for Uttar Pradesh, Nagaland, and Haryana across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttar Pradesh', 'Nagaland', 'Haryana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 6171,"Show the mean, median and standard deviation of PM2.5 per state in 2018 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6172,"Show the top 13 states by average PM10 in 2023 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2023] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(13, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 13 States by Average PM10 in 2023', width=500, height=300) return chart " 6173,Determine the highest PM10 reading from 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'PM10'}}] " 6174,Which state recorded the second-highest 75th percentile of PM10 for May 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 6175,"Create a grouped bar chart comparing the average PM2.5 for Meghalaya, Andhra Pradesh, and Karnataka across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Meghalaya', 'Andhra Pradesh', 'Karnataka'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 6176,Plot the distribution of PM2.5 values in Mizoram across all years using a histogram.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Mizoram'].dropna(subset=['PM2.5']) df = df[['PM2.5']] chart = alt.Chart(df).mark_bar(color='steelblue', opacity=0.75).encode( x=alt.X('PM2\.5:Q', bin=alt.Bin(maxbins=40), title='PM2.5 (µg/m³)'), y=alt.Y('count()', title='Number of Observations'), tooltip=[alt.Tooltip('PM2\.5:Q', bin=True), 'count()'] ).properties(title='PM2.5 Distribution – Mizoram (All Years)', width=500, height=300) return chart " 6177,"Plot the yearly average PM2.5 trends for Meghalaya, Karnataka, and Odisha from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Meghalaya', 'Karnataka', 'Odisha'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Meghalaya vs Karnataka vs Odisha', width=550, height=320) return chart " 6178,Which state possessed the 2nd lowest 75th percentile for PM2.5 in the Monsoon season of 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 6179,"In November 2019, identify the state with the lowest 75th percentile of PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 6180,Identify the station that registered the most minimal median PM10 during the Summer season of 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 6181,"Compare the monthly average PM2.5 of Kolkata, Balasore, and Puducherry in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Kolkata', 'Balasore', 'Puducherry'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Kolkata vs Balasore vs Puducherry – 2023', width=550, height=320) return chart " 6182,Determine the station exhibiting the 2nd highest median PM2.5 in December 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 6183,Determine the city showing the highest 25th percentile of PM10 for February 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 6184,"Identify the state (excluding UTs) with the 3rd smallest population among the top 5 most polluted states, based on median PM2.5 levels."," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 5, 'ret': 'state'}}] " 6185,List the bottom 20 states with the lowest average PM2.5 in 2019 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 6186,"Determine which state (excluding UTs) has the 2nd smallest population within the top 5 most polluted states, based on 75th percentile of PM10 levels."," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 5, 'ret': 'state'}}] " 6187,"Visualize the monthly average PM10 for Delhi, Arunachal Pradesh, and Telangana in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Delhi', 'Arunachal Pradesh', 'Telangana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Delhi, Arunachal Pradesh, UP – 2018', width=550, height=320) return chart " 6188,Show a table of average PM2.5 and PM10 for all states in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6189,List the average PM10 for Meghalaya broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Meghalaya'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6190,"Compare the monthly average PM2.5 of Ernakulam, Belgaum, and Ahmedabad in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Ernakulam', 'Belgaum', 'Ahmedabad'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Ernakulam vs Belgaum vs Ahmedabad – 2017', width=550, height=320) return chart " 6191,"Comparing December 2018 to October 2018, which state showed the second least significant drop in 25th percentile PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 6192,"For May 2020 compared to May 2019, which city registered the highest increase in the 75th percentile of PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 6193,"On August 15, 2019, which city experienced the third-highest PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 6194,Plot the rolling 30-day average PM2.5 for Madhya Pradesh in 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Madhya Pradesh') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Madhya Pradesh 2022', width=600, height=300) " 6195,Tabulate the yearly average PM10 trend for Karnataka across all years.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6196,Identify the station exhibiting the peak 75th percentile of PM10 during the Winter season of 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 6197,Show the monthly average PM2.5 for Churu in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Churu') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Churu 2019', width=450, height=280) " 6198,Which state demonstrates the 4th highest standard deviation of PM10 concentration relative to its population density?," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'std', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_capita', 'numerator': 'PM10', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'pm_per_capita', 'ascending': False}}] " 6199,List states with their PM10 violation count and rate (>100 µg/m³) in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6200,"In May 2024, report the city with the highest average PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 6201,"Plot the yearly average PM2.5 trends for Jammu and Kashmir, Maharashtra, and Kerala from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jammu and Kashmir', 'Maharashtra', 'Kerala'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Jammu and Kashmir vs Maharashtra vs Kerala', width=550, height=320) return chart " 6202,"Plot average PM2.5 (2017) vs state population as a scatter plot, labeling each point with the state name."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): pm = data[data['Timestamp'].dt.year == 2017].groupby('state')['PM2.5'].mean().reset_index().dropna() df = pm.merge(states_data, on='state') points = alt.Chart(df).mark_point(filled=True, size=80).encode( x=alt.X('population:Q', title='Population', axis=alt.Axis(format='~s')), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('population:Q', format=',')] ) labels = alt.Chart(df).mark_text(align='left', dx=5, fontSize=9).encode( x='population:Q', y='PM2\.5:Q', text='state:N' ) return (points + labels).properties(title='PM2.5 vs Population by State – 2017', width=500, height=400) " 6203,Report the city with the lowest median PM10 in June 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 6204,Plot the yearly average PM2.5 for the top 7 most polluted states from 2017 to 2024 as a multi-line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top5 = data.groupby('state')['PM2.5'].mean().nlargest(7).index.tolist() df = data[data['state'].isin(top5)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends – Top 7 Most Polluted States', width=600, height=350) return chart " 6205,Which station had the 2nd highest average PM2.5 in October 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 6206,Create a table of PM10 standard violations (>150 µg/m³) per state in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6207,List the bottom 5 citys with the lowest average PM10 in 2022 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 6208,Generate a cross-tab of state vs month for average PM10 in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Arunachal Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Chhattisgarh', 'Delhi', 'Gujarat', 'Haryana', 'Himachal Pradesh', 'Jammu and Kashmir', 'Jharkhand', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Meghalaya', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Sikkim', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh', 'Uttarakhand', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6209,"Create a grouped bar chart comparing the average PM2.5 for Meghalaya, Kerala, and Manipur across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Meghalaya', 'Kerala', 'Manipur'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 6210,Report the state with the 2nd lowest NCAP funding relative to the variance of its PM10 concentration in 2020 (FY 2019-20).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'var', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2020_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 6211,Bar chart of PM2.5 per capita (average PM2.5 × 1000 / population) for each state in 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): pm = data[data['Timestamp'].dt.year == 2018].groupby('state')['PM2.5'].mean().reset_index().dropna() df = pm.merge(states_data[['state','population']], on='state') df['PM2.5 per Capita (×1000)'] = df['PM2.5'] / df['population'] * 1e6 df = df.sort_values('PM2.5 per Capita (×1000)', ascending=False) chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5 per Capita (×1000):Q', title='PM2.5 per Million Population'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5 per Capita (×1000):Q', scale=alt.Scale(scheme='purples'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5 per Capita (×1000):Q', format='.4f')] ).properties(title='PM2.5 Per-Capita Pollution Index by State – 2018', width=500, height=400) return chart " 6212,How many stations in Tamil Nadu went above 75 µg/m³ of PM2.5 in the year 2017?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 75.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 6213,"Scatter plot PM2.5 vs PM10 for Rajasthan stations in 2018, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Rajasthan') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Rajasthan Stations 2018', width=450, height=350) " 6214,List citys with their PM10 violation count and rate (>100 µg/m³) in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6215,Name the state with the second-highest 25th percentile for PM10 in June 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 6216,How many times did Nagaland surpass 30 µg/m³ of PM2.5 in 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 30.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 6217,Show how average PM10 varied month by month for Gujarat in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Gujarat'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6218,Tabulate days with PM10 > 150 µg/m³ and exceedance percentage per state in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 150'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6219,Visualize the bottom 5 states with the lowest average PM2.5 in 2018 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2018] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(5, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 5 States by Average PM2.5 in 2018', width=500, height=300) return chart " 6220,Determine the state with the highest 75th percentile PM2.5 value in January 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 6221,Show a ranked table of the 10 most polluted states by average PM10 in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 6222,Generate a descriptive stats table for PM10 grouped by city in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6223,Which station exhibited the highest median PM2.5 during June 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 6224,Report the state with the 3rd highest average PM10 in January 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 6225,"Visualize the monthly average PM10 for Telangana, West Bengal, and Jharkhand in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Telangana', 'West Bengal', 'Jharkhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Telangana, West Bengal, UP – 2021', width=550, height=320) return chart " 6226,Determine the state with the 3rd highest median PM10 in June 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 6227,"Show the variability of PM10 across states in 2017 using mean, median, and standard deviation."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'q25', 'median', 'q75']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6228,Determine the station that showed the peak median PM10 over the Summer season of 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 6229,Which state recorded the 2nd lowest 25th percentile of PM10 in the Post-Monsoon season of 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 6230,"Plot the yearly average PM2.5 trends for Chandigarh, Uttar Pradesh, and Jammu and Kashmir from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chandigarh', 'Uttar Pradesh', 'Jammu and Kashmir'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Chandigarh vs Uttar Pradesh vs Jammu and Kashmir', width=550, height=320) return chart " 6231,Tabulate daily PM10 exceedances (above 100 µg/m³) per city for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6232,Which city experienced the highest median for PM10 in the Monsoon season of 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 6233,Which station noted the 2nd minimum 75th percentile of PM2.5 during the Post-Monsoon season of 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 6234,Show a pivot table of monthly average PM10 by city for Andhra Pradesh in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Tirupati']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6235,Which city experienced the third most significant drop in its average PM2.5 levels between October and December 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 6236,Show the monthly average PM2.5 for Dewas in 2023 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Dewas') & (data['Timestamp'].dt.year == 2023)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Dewas 2023', width=450, height=280) " 6237,How many stations in Himachal Pradesh went above the WHO guideline for PM10 in the year 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 15.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 6238,Show a cumulative area chart of PM2.5 readings for Barbil across 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Barbil') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Barbil 2024', width=600, height=300) return chart " 6239,Identify the city that registered the second highest PM10 level on 27 January 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 6240,"Compare the monthly average PM2.5 of Navi Mumbai, Purnia, and Jalna in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Navi Mumbai', 'Purnia', 'Jalna'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Navi Mumbai vs Purnia vs Jalna – 2022', width=550, height=320) return chart " 6241,"Plot the yearly average PM2.5 trends for Uttar Pradesh, Chhattisgarh, and Nagaland from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttar Pradesh', 'Chhattisgarh', 'Nagaland'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Uttar Pradesh vs Chhattisgarh vs Nagaland', width=550, height=320) return chart " 6242,Show a year-wise table of average PM10 for Meerut from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Meerut'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6243,Which 20 citys recorded the highest average PM2.5 levels in 2020? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 6244,"Compare the monthly average PM2.5 of Ambala, Brajrajnagar, and Guwahati in 2020 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Ambala', 'Brajrajnagar', 'Guwahati'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2020)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Ambala vs Brajrajnagar vs Guwahati – 2020', width=550, height=320) return chart " 6245,"In 2022, which state will rank with the third largest reduction in 75th percentile PM2.5 levels from October to December?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 6246,Determine the city exhibiting the 3rd lowest 75th percentile of PM2.5 in November 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 6247,Determine the station that recorded the most minimal median PM2.5 over the Monsoon season of 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 6248,Plot the weekly average PM2.5 for Bahadurgarh in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bahadurgarh') & (data['Timestamp'].dt.year == 2024)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Bahadurgarh 2024', width=600, height=300) return chart " 6249,Determine the station that showed the 2nd highest 25th percentile of PM10 over the Post-Monsoon season of 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 6250,Plot the weekly average PM2.5 for Nayagarh in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Nayagarh') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Nayagarh 2023', width=600, height=300) return chart " 6251,Tabulate population-adjusted PM2.5 levels for each state in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM2.5 per million', 'numerator': 'PM2.5', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'PM2.5 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6252,"Which state with a land area below 50,000 km² shows the 5th highest PM10 level, according to its 25th percentile PM10 level?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}] " 6253,"Tabulate PM2.5 levels, population, and land area per state in 2023."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': { 'map': { 'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6254,"Create a grouped bar chart comparing the average PM2.5 for Jammu and Kashmir, Andhra Pradesh, and Chandigarh across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jammu and Kashmir', 'Andhra Pradesh', 'Chandigarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 6255,Report the city with the lowest 25th percentile of PM2.5 in February 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 6256,Create a table of PM2.5 standard violations (>100 µg/m³) per city in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6257,Show a table of average PM10 per state in 2017 along with population.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6258,"In March 2021, identify the station with the highest 25th percentile of PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 6259,Create a month-wise summary of average PM2.5 for Guwahati in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Guwahati'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6260,"Plot the yearly average PM2.5 trends for Sikkim, Meghalaya, and Kerala from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Sikkim', 'Meghalaya', 'Kerala'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Sikkim vs Meghalaya vs Kerala', width=550, height=320) return chart " 6261,Which 5 states recorded the highest average PM10 levels in 2024? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 6262,Create a table of PM10 exceedance frequency above 100 µg/m³ by city for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6263,Generate a descriptive stats table for PM10 grouped by state in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'q25', 'median', 'q75']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6264,"Within the last five years in Dausa, on what date was the PM2.5 level the third lowest?"," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 5}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'Timestamp'}}] " 6265,Tabulate the 20 worst states for average PM2.5 in 2021 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 6266,"Create a faceted bar chart showing top 7 states by average PM2.5 per year for 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year.isin([2019,2020,2021,2022])].copy() df['Year'] = df['Timestamp'].dt.year agg = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() top = agg.groupby('Year').apply(lambda x: x.nlargest(7,'PM2.5')).reset_index(drop=True) chart = alt.Chart(top).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Avg PM2.5'), y=alt.Y('state:N', sort='-x'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet(facet='Year:O', columns=2).properties(title='Top 7 States by PM2.5 per Year') return chart " 6267,"Over the past four years in Davanagere, on which date was the PM2.5 level the third highest?"," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 4}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'Timestamp'}}] " 6268,What count of Jharkhand stations surpassed 45 µg/m³ of PM10 in 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 45.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 6269,Show the monthly average PM10 trend for Nashik from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Nashik'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Nashik (2019–2024)', width=600, height=300) return chart " 6270,How many times did Byrnihat city go above the WHO guideline for PM10 in 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 15.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 6271,How many times did Latur city exceed 30 µg/m³ of PM10 in 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 30.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 6272,Show the monthly average PM2.5 for Narnaul in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Narnaul') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Narnaul 2017', width=450, height=280) " 6273,During which year was the median PM2.5 level at its second-lowest?," [{'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'Timestamp'}}] " 6274,List the bottom 10 states with the lowest average PM2.5 in 2018 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 6275,Create a table of PM2.5 standard violations (>100 µg/m³) per state in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6276,Plot the weekly average PM2.5 for Hubballi in 2019 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Hubballi') & (data['Timestamp'].dt.year == 2019)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Hubballi 2019', width=600, height=300) return chart " 6277,"Create a grouped bar chart comparing the average PM2.5 for Uttarakhand, Maharashtra, and Tamil Nadu across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttarakhand', 'Maharashtra', 'Tamil Nadu'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 6278,"Considering all years, which January was associated with the second-lowest average PM10 levels?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'Timestamp'}}] " 6279,Create a summary table ranking the top 10 states by PM2.5 concentration in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 6280,Show a monthly bar chart of the number of days Punjab exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2017.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Punjab') & (data['Timestamp'].dt.year == 2017)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Punjab Exceeded WHO PM2.5 Guideline per Month – 2017', width=500, height=300) return chart " 6281,Visualize the bottom 8 states with the lowest average PM2.5 in 2023 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2023] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(8, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 8 States by Average PM2.5 in 2023', width=500, height=300) return chart " 6282,Identify the state that recorded the second highest 25th percentile of PM2.5 during the Summer season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 6283,Plot the top 13 states by average PM2.5 in 2019 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2019] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(13, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 13 States by Average PM2.5 in 2019', width=500, height=300) return chart " 6284,"Compare the monthly average PM2.5 of Byasanagar, Sonipat, and Jhansi in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Byasanagar', 'Sonipat', 'Jhansi'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Byasanagar vs Sonipat vs Jhansi – 2024', width=550, height=320) return chart " 6285,Show a heatmap of average PM2.5 for the top 8 most polluted states by month for 2019.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(8).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 8 Polluted States by Month (2019)', width=500, height=300) return chart " 6286,"Scatter plot PM2.5 vs PM10 for Telangana stations in 2020, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Telangana') & (data['Timestamp'].dt.year == 2020)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Telangana Stations 2020', width=450, height=350) " 6287,Create a table of PM2.5 standard violations (>100 µg/m³) per state in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6288,"Plot the yearly average PM2.5 trends for Delhi, Himachal Pradesh, and Karnataka from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Delhi', 'Himachal Pradesh', 'Karnataka'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Delhi vs Himachal Pradesh vs Karnataka', width=550, height=320) return chart " 6289,What date during the previous three years showed Indore's highest PM2.5 reading?," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 3}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'Timestamp'}}] " 6290,"Scatter plot PM2.5 vs PM10 for Tripura stations in 2017, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Tripura') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Tripura Stations 2017', width=450, height=350) " 6291,Which state exhibited the third-highest 75th percentile for PM10 during November 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 6292,Show a pivot table of monthly average PM2.5 by city for Odisha in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Odisha'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Brajrajnagar', 'Talcher']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6293,"In January 2022, report the city with the highest median PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 6294,List average PM2.5 by month for Uttar Pradesh in 2023 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6295,"In 2023, which state showed the second largest decrease in its average PM2.5 levels comparing December to October?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 6296,"Compare the monthly average PM2.5 of Narnaul, Bagalkot, and Kohima in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Narnaul', 'Bagalkot', 'Kohima'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Narnaul vs Bagalkot vs Kohima – 2023', width=550, height=320) return chart " 6297,Show a cumulative area chart of PM2.5 readings for Araria across 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Araria') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Araria 2021', width=600, height=300) return chart " 6298,"Determine which state (excluding UTs) has the smallest population among the top 10 most polluted states, based on 25th percentile of PM2.5 levels."," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 10, 'ret': 'state'}}] " 6299,Identify the station that recorded the 2nd lowest 75th percentile of PM10 value in August 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 6300,"Visualize the monthly average PM10 for Uttarakhand, Kerala, and Manipur in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttarakhand', 'Kerala', 'Manipur'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Uttarakhand, Kerala, UP – 2021', width=550, height=320) return chart " 6301,Show how many times PM10 exceeded 150 µg/m³ per day across citys in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6302,Show a year-wise table of average PM10 for Muzaffarpur from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Muzaffarpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6303,Show a heatmap of average PM2.5 for the top 13 most polluted states by month for 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(13).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 13 Polluted States by Month (2021)', width=500, height=300) return chart " 6304,Report which city possessed the 2nd highest median PM2.5 throughout the Winter season of 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 6305,Which state registered the peak median PM2.5 in the Summer season of 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 6306,"Visualize the monthly average PM10 for Arunachal Pradesh, Delhi, and Kerala in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Arunachal Pradesh', 'Delhi', 'Kerala'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Arunachal Pradesh, Delhi, UP – 2019', width=550, height=320) return chart " 6307,"Plot the yearly average PM2.5 trends for Mizoram, Tamil Nadu, and Chhattisgarh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Mizoram', 'Tamil Nadu', 'Chhattisgarh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Mizoram vs Tamil Nadu vs Chhattisgarh', width=550, height=320) return chart " 6308,Which state registered the lowest average PM2.5 during January 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 6309,"Compare the monthly average PM2.5 of Ankleshwar, Kashipur, and Bhiwani in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Ankleshwar', 'Kashipur', 'Bhiwani'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Ankleshwar vs Kashipur vs Bhiwani – 2023', width=550, height=320) return chart " 6310,Show a heatmap of average PM2.5 for the top 9 most polluted states by month for 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(9).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 9 Polluted States by Month (2022)', width=500, height=300) return chart " 6311,Which station registered the 2nd maximum 25th percentile of PM10 in the Summer season of 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 6312,Show the monthly average PM10 trend for Bhiwadi from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Bhiwadi'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Bhiwadi (2017–2022)', width=600, height=300) return chart " 6313,Show a ranked table of the 10 most polluted citys by average PM2.5 in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 6314,Tabulate days with PM10 > 150 µg/m³ and exceedance percentage per state in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 150'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6315,"Create a grouped bar chart comparing the average PM2.5 for Odisha, Chhattisgarh, and Andhra Pradesh across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Odisha', 'Chhattisgarh', 'Andhra Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 6316,Determine the state exhibiting the 3rd highest median PM2.5 over the Post-Monsoon season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 6317,Plot the rolling 30-day average PM2.5 for Tripura in 2018 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Tripura') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Tripura 2018', width=600, height=300) " 6318,"Create a grouped bar chart comparing the average PM2.5 for Bihar, West Bengal, and Himachal Pradesh across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Bihar', 'West Bengal', 'Himachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 6319,Tabulate both PM2.5 and PM10 averages by state for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6320,"Visualize the monthly average PM10 for Meghalaya, Chhattisgarh, and Haryana in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Meghalaya', 'Chhattisgarh', 'Haryana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Meghalaya, Chhattisgarh, UP – 2019', width=550, height=320) return chart " 6321,Report the state with the 2nd lowest average PM2.5 in February 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 6322,Which 5 citys recorded the highest average PM2.5 levels in 2022? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 6323,Tabulate the 10 worst states for average PM10 in 2023 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 6324,Generate a monthly average PM10 table for Uttar Pradesh for the year 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6325,Show the monthly average PM10 trend for Anantapur from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Anantapur'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Anantapur (2019–2024)', width=600, height=300) return chart " 6326,Plot the top 10 states by average PM2.5 in 2022 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2022] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(10, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 10 States by Average PM2.5 in 2022', width=500, height=300) return chart " 6327,List the average PM2.5 for Raipur broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Raipur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6328,"Compare the monthly average PM2.5 of Alwar, Varanasi, and Rairangpur in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Alwar', 'Varanasi', 'Rairangpur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Alwar vs Varanasi vs Rairangpur – 2018', width=550, height=320) return chart " 6329,"Plot the yearly average PM2.5 trends for Tripura, Jammu and Kashmir, and Mizoram from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tripura', 'Jammu and Kashmir', 'Mizoram'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Tripura vs Jammu and Kashmir vs Mizoram', width=550, height=320) return chart " 6330,"Tabulate the distribution of PM2.5 per city in 2020 including mean, median, and std."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6331,Which state registered the 3rd highest median PM2.5 during March 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 6332,Create a ranked table of the 5 best-performing states by PM2.5 in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 6333,"Identify the state (excluding UTs) with the 2nd largest population among the top 10 most polluted states, based on 75th percentile of PM10 levels."," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 10, 'ret': 'state'}}] " 6334,Create a ranked table of the 20 best-performing states by PM10 in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 6335,Show PM2.5 density (µg/m³ per km²) by state for 2022 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, { 'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM2.5 per km²', 'numerator': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)', 'PM2.5 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6336,Show the monthly average PM2.5 for Baghpat in 2022 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Baghpat') & (data['Timestamp'].dt.year == 2022)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Baghpat 2022', width=450, height=280) " 6337,Tabulate average PM2.5 for each city in Odisha across all months of 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Odisha'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Baripada', 'Bileipada', 'Brajrajnagar', 'Keonjhar', 'Nayagarh', 'Rourkela', 'Suakati', 'Talcher', 'Tensa']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6338,"In January 2018, report the state with the 3rd lowest 25th percentile of PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 6339,"In 2021, which day of the week corresponded to the third-lowest average PM10 pollution levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'Timestamp'}}] " 6340,"Visualize the monthly average PM10 for Mizoram, Himachal Pradesh, and Sikkim in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Mizoram', 'Himachal Pradesh', 'Sikkim'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Mizoram, Himachal Pradesh, UP – 2024', width=550, height=320) return chart " 6341,"Identify the state with the highest average PM2.5 concentration on January 5, 2023."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 6342,Create a table of PM10 standard violations (>100 µg/m³) per state in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6343,"Show the variability of PM10 across states in 2023 using mean, median, and standard deviation."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6344,Plot a grouped bar chart of average PM10 by season and year (2021–2024) for all of India.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): def season(m): if m in [12,1,2]: return 'Winter' elif m in [3,4,5]: return 'Summer' elif m in [6,7,8,9]: return 'Monsoon' else: return 'Post-Monsoon' df = data[data['Timestamp'].dt.year.isin([2021,2022,2023,2024])].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df['Season'] = df['Timestamp'].dt.month.apply(season) df = df.groupby(['Season','Year'])['PM10'].mean().reset_index().dropna() order = ['Winter','Summer','Post-Monsoon','Monsoon'] chart = alt.Chart(df).mark_bar().encode( x=alt.X('Season:N', sort=order, title='Season'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('Year:N', title='Year'), xOffset='Year:N', tooltip=['Season:N','Year:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Average PM10 by Season and Year (2021–2024)', width=500, height=320) return chart " 6345,Show a cumulative area chart of PM2.5 readings for Ghaziabad across 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ghaziabad') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Ghaziabad 2023', width=600, height=300) return chart " 6346,"In October 2018, which city registered the 3rd lowest median PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 6347,Tabulate average PM10 for each city in West Bengal across all months of 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'West Bengal'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Asansol', 'Durgapur', 'Haldia', 'Howrah', 'Kolkata', 'Siliguri']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6348,Show a cumulative area chart of PM2.5 readings for Singrauli across 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Singrauli') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Singrauli 2021', width=600, height=300) return chart " 6349,List states ranked by PM2.5 concentration relative to their area in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, { 'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM2.5 per km²', 'numerator': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)', 'PM2.5 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6350,Create a heatmap showing the average PM2.5 by month (x-axis) and year (y-axis) for Chhattisgarh.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Chhattisgarh'].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Year:N', title='Year'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='Avg PM2.5'), tooltip=['Year:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Chhattisgarh (Month × Year)', width=500, height=280) return chart " 6351,List the bottom 20 citys with the lowest average PM10 in 2021 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 6352,"Identify the state (excluding UTs) with the 2nd smallest population among the top 10 most polluted states, based on 75th percentile of PM10 levels."," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 10, 'ret': 'state'}}] " 6353,"Visualize the monthly average PM10 for Tripura, Madhya Pradesh, and Meghalaya in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tripura', 'Madhya Pradesh', 'Meghalaya'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Tripura, Madhya Pradesh, UP – 2023', width=550, height=320) return chart " 6354,Show a heatmap of average PM2.5 for the top 9 most polluted states by month for 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(9).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 9 Polluted States by Month (2018)', width=500, height=300) return chart " 6355,"On March 31, 2021, which state recorded the minimum average PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 6356,Identify a year in which Durgapur experienced its best air quality from 2018-2024.," [{'op': 'FILTER', 'params': {'field': 'city', 'value': 'Durgapur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'Timestamp'}}] " 6357,Show the monthly average PM2.5 for Dharuhera in 2024 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Dharuhera') & (data['Timestamp'].dt.year == 2024)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Dharuhera 2024', width=450, height=280) " 6358,Show a pivot table of monthly average PM10 by city for Tamil Nadu in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Chennai', 'Gummidipoondi', 'Thoothukudi']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6359,Show the monthly average PM10 trend for Ahmednagar from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Ahmednagar'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Ahmednagar (2019–2024)', width=600, height=300) return chart " 6360,"Visualize the monthly average PM10 for Meghalaya, Sikkim, and Mizoram in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Meghalaya', 'Sikkim', 'Mizoram'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Meghalaya, Sikkim, UP – 2022', width=550, height=320) return chart " 6361,"Plot the yearly average PM2.5 trends for Rajasthan, Meghalaya, and Mizoram from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Meghalaya', 'Mizoram'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Rajasthan vs Meghalaya vs Mizoram', width=550, height=320) return chart " 6362,Create a table showing annual mean PM10 levels for Durgapur (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Durgapur'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6363,List the top 10 states by average PM10 in 2019 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 6364,Create a summary table comparing mean PM2.5 and PM10 across states in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6365,Report the city with the 2nd lowest 25th percentile of PM10 in July 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 6366,Which station displayed the lowest average PM2.5 in April 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 6367,Which station experienced the second most significant drop in its 75th percentile PM10 levels between October and December 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 6368,Generate a city × month cross-tab of mean PM10 for Assam in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Assam'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Guwahati']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6369,Plot the rolling 30-day average PM2.5 for Karnataka in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Karnataka') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Karnataka 2023', width=600, height=300) " 6370,Tabulate days with PM2.5 > 60 µg/m³ and exceedance percentage per state in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6371,Identify the state that registered the most minimal median PM2.5 during the Monsoon season of 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 6372,Report the city with the highest 75th percentile of PM2.5 in October 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 6373,"On January 27, 2023, which city had the peak PM10 level?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 6374,Generate a year-by-year summary table of PM2.5 readings for Gwalior.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Gwalior'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6375,Which city possessed the 3rd highest 25th percentile for PM10 in the Summer season of 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 6376,Tabulate the yearly average PM10 trend for Moradabad across all years.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Moradabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6377,Show the monthly average PM10 trend for Sivasagar from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Sivasagar'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Sivasagar (2019–2024)', width=600, height=300) return chart " 6378,Show a bar chart of the top 15 cities by median PM2.5 in 2017.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2017] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(15, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 15 Cities by Median PM2.5 in 2017', width=500, height=300) return chart " 6379,"Which union territory with a land area below 1,000 km² shows the 2nd highest PM10 level, based on its total PM10 level?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'sum', 'col': 'PM10'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}] " 6380,"Between October 2019 and October 2020, which state saw the largest upsurge in average PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 6381,Report the city that had the highest 25th percentile of PM2.5 in June 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 6382,List citys with their PM2.5 violation count and rate (>100 µg/m³) in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6383,Show how average PM10 varied month by month for Tamil Nadu in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6384,Plot the rolling 30-day average PM2.5 for Tripura in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Tripura') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Tripura 2023', width=600, height=300) " 6385,Show the monthly average PM2.5 for Nagpur in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Nagpur') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Nagpur 2018', width=450, height=280) " 6386,Plot the weekly average PM2.5 for Pratapgarh in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Pratapgarh') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Pratapgarh 2023', width=600, height=300) return chart " 6387,Create a month-by-state breakdown table of mean PM10 for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Arunachal Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Chhattisgarh', 'Delhi', 'Gujarat', 'Haryana', 'Himachal Pradesh', 'Jammu and Kashmir', 'Jharkhand', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Meghalaya', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Sikkim', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh', 'Uttarakhand', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6388,"Show the top 12 states by average PM10 in 2021 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2021] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(12, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 12 States by Average PM10 in 2021', width=500, height=300) return chart " 6389,Which state recorded the 2nd highest average for PM2.5 in the Post-Monsoon season of 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 6390,Create a month-wise summary of average PM2.5 for Nagpur in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Nagpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6391,Plot the weekly average PM2.5 for Katni in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Katni') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Katni 2023', width=600, height=300) return chart " 6392,How many stations in Kashipur exceeded 30 µg/m³ of PM10 in the year 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 30.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 6393,"Identify the city with the highest 25th percentile for PM2.5 on March 31, 2021."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 6394,How many stations in Arunachal Pradesh surpassed the Indian guideline for PM10 in the year 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 60.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 6395,List citys with their PM10 violation count and rate (>100 µg/m³) in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6396,List the bottom 20 citys with the lowest average PM2.5 in 2017 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 6397,Report the state with the highest 75th percentile of PM2.5 in January 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 6398,"Visualize the monthly average PM10 for Andhra Pradesh, Telangana, and Kerala in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Telangana', 'Kerala'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Andhra Pradesh, Telangana, UP – 2018', width=550, height=320) return chart " 6399,"Create a grouped bar chart comparing the average PM2.5 for Uttar Pradesh, Puducherry, and Gujarat across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttar Pradesh', 'Puducherry', 'Gujarat'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 6400,Tabulate the top 5 citys for PM2.5 in 2019 along with their corresponding PM10 values.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 6401,Visualize the bottom 8 states with the lowest average PM2.5 in 2018 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2018] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(8, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 8 States by Average PM2.5 in 2018', width=500, height=300) return chart " 6402,"Compare the monthly average PM2.5 of Sagar, Rajsamand, and Durgapur in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Sagar', 'Rajsamand', 'Durgapur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Sagar vs Rajsamand vs Durgapur – 2024', width=550, height=320) return chart " 6403,Visualize the bottom 14 states with the lowest average PM2.5 in 2024 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2024] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(14, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 14 States by Average PM2.5 in 2024', width=500, height=300) return chart " 6404,Plot the rolling 30-day average PM2.5 for Meghalaya in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Meghalaya') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Meghalaya 2024', width=600, height=300) " 6405,Report the city that had the 2nd lowest median PM2.5 in June 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 6406,Generate a descriptive stats table for PM10 grouped by state in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6407,List average PM2.5 by month for Maharashtra in 2023 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6408,Generate a city × month cross-tab of mean PM10 for West Bengal in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'West Bengal'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Asansol', 'Howrah', 'Kolkata', 'Siliguri']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6409,Create a table with mean and standard deviation of PM10 by city in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6410,Plot the weekly average PM2.5 for Udaipur in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Udaipur') & (data['Timestamp'].dt.year == 2020)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Udaipur 2020', width=600, height=300) return chart " 6411,Show the number of days each city exceeded a PM2.5 threshold of 100 µg/m³ in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6412,Show the monthly average PM2.5 for Dindigul in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Dindigul') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Dindigul 2018', width=450, height=280) " 6413,"Visualize the monthly average PM10 for Mizoram, Sikkim, and Gujarat in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Mizoram', 'Sikkim', 'Gujarat'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Mizoram, Sikkim, UP – 2023', width=550, height=320) return chart " 6414,Show the monthly average PM2.5 for Rajasthan across each year from 2017 to 2024 as small multiples (faceted by year).," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Rajasthan'].copy() df['Year'] = df['Timestamp'].dt.year df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5'), tooltip=['Year:O','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet( facet=alt.Facet('Year:O', title='Year'), columns=4 ).properties(title='Monthly PM2.5 in Rajasthan by Year (2017–2024)') return chart " 6415,Generate a city × month cross-tab of mean PM2.5 for Haryana in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Haryana'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Faridabad', 'Gurugram', 'Panchkula', 'Rohtak']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6416,Which city had the 3rd lowest average PM10 in January 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 6417,"Scatter plot PM2.5 vs PM10 for Nagaland stations in 2019, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Nagaland') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Nagaland Stations 2019', width=450, height=350) " 6418,Which station showed the 3rd highest median PM10 in June 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 6419,Create a month-wise PM2.5 breakdown table across cities in Bihar for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Bihar'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Araria', 'Arrah', 'Aurangabad', 'Begusarai', 'Bettiah', 'Bhagalpur', 'Bihar Sharif', 'Chhapra', 'Gaya', 'Hajipur', 'Katihar', 'Kishanganj', 'Manguraha', 'Motihari', 'Munger', 'Muzaffarpur', 'Patna', 'Purnia', 'Rajgir', 'Saharsa', 'Samastipur', 'Sasaram', 'Siwan']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6420,Show a year-wise table of average PM2.5 for Varanasi from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Varanasi'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6421,Show a monthly breakdown table of average PM10 for Bengaluru in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Bengaluru'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6422,Determine the state exhibiting the highest average PM10 in April 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 6423,"Visualize the monthly average PM10 for Chhattisgarh, Gujarat, and Tripura in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chhattisgarh', 'Gujarat', 'Tripura'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Chhattisgarh, Gujarat, UP – 2024', width=550, height=320) return chart " 6424,Show a monthly bar chart of the number of days Madhya Pradesh exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Madhya Pradesh') & (data['Timestamp'].dt.year == 2022)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Madhya Pradesh Exceeded WHO PM2.5 Guideline per Month – 2022', width=500, height=300) return chart " 6425,Create a statistical summary table of PM2.5 readings by state for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6426,Which city exhibited the second largest decrease in its average PM2.5 levels between October and December of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 6427,"Visualize the monthly average PM10 for Mizoram, Jharkhand, and Andhra Pradesh in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Mizoram', 'Jharkhand', 'Andhra Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Mizoram, Jharkhand, UP – 2023', width=550, height=320) return chart " 6428,Create a statistical summary table of PM10 readings by state for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6429,Which state noted the peak 25th percentile of PM10 in the Winter season of 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 6430,"Scatter plot PM2.5 vs PM10 for Haryana stations in 2021, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Haryana') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Haryana Stations 2021', width=450, height=350) " 6431,List the average PM2.5 for Gwalior broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Gwalior'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6432,Show a year-wise table of average PM10 for Punjab from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6433,List average PM2.5 by month for Varanasi in 2022 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Varanasi'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6434,How many times did Karnataka surpass the WHO guideline for PM2.5 in the year 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 15.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 6435,List all states with their average PM2.5 and PM10 levels in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6436,"Comparing December 2020 to October 2020, which station showed the second most significant drop in median PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 6437,Show the monthly average PM10 trend for Tirupur from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Tirupur'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Tirupur (2017–2022)', width=600, height=300) return chart " 6438,Identify the state with the 3rd lowest 25th percentile of PM2.5 in March 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 6439,Determine the station with the 2nd highest 75th percentile of PM10 in April 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 6440,List the bottom 10 states with the lowest average PM10 in 2023 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 6441,List the top 5 citys by PM2.5 in 2024 with both PM2.5 and PM10 averages.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 6442,Identify the city that saw the least significant fall in median PM2.5 levels when comparing December 2018 to October 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 6443,Bar chart of PM2.5 per capita (average PM2.5 × 1000 / population) for each state in 2020.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): pm = data[data['Timestamp'].dt.year == 2020].groupby('state')['PM2.5'].mean().reset_index().dropna() df = pm.merge(states_data[['state','population']], on='state') df['PM2.5 per Capita (×1000)'] = df['PM2.5'] / df['population'] * 1e6 df = df.sort_values('PM2.5 per Capita (×1000)', ascending=False) chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5 per Capita (×1000):Q', title='PM2.5 per Million Population'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5 per Capita (×1000):Q', scale=alt.Scale(scheme='purples'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5 per Capita (×1000):Q', format='.4f')] ).properties(title='PM2.5 Per-Capita Pollution Index by State – 2020', width=500, height=400) return chart " 6444,Determine the state exhibiting the 2nd highest average PM2.5 over the Post-Monsoon season of 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 6445,Identify the state with the 2nd lowest 25th percentile of PM10 in April 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 6446,Which station recorded the 3rd highest 75th percentile of PM2.5 during the Post-Monsoon season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 6447,Which station had the 3rd lowest 75th percentile of PM2.5 in May 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 6448,Report the city that had the 2nd highest median PM2.5 in January 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 6449,Generate a city × month cross-tab of mean PM2.5 for Uttar Pradesh in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Agra', 'Baghpat', 'Bulandshahr', 'Ghaziabad', 'Greater Noida', 'Hapur', 'Kanpur', 'Lucknow', 'Meerut', 'Moradabad', 'Muzaffarnagar', 'Noida', 'Varanasi']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6450,"Create a grouped bar chart comparing the average PM2.5 for Madhya Pradesh, Chandigarh, and Punjab across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Madhya Pradesh', 'Chandigarh', 'Punjab'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 6451,"Which station showed the second-lowest average PM10 on March 31, 2024?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 6452,Report which station possessed the lowest median PM2.5 throughout the Winter season of 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 6453,Show a year-wise table of average PM2.5 for Indore from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Indore'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6454,"Which union territory having a land area exceeding 1,000 km² registers the 2nd minimum PM10 level, according to its average PM10 level?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}] " 6455,"Visualize the monthly average PM10 for Bihar, Meghalaya, and Haryana in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Bihar', 'Meghalaya', 'Haryana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Bihar, Meghalaya, UP – 2017', width=550, height=320) return chart " 6456,"In 2021, which station showed the second smallest decrease in its 25th percentile PM10 levels comparing December to October?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 6457,Plot the weekly average PM2.5 for Gurugram in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Gurugram') & (data['Timestamp'].dt.year == 2024)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Gurugram 2024', width=600, height=300) return chart " 6458,Show a cumulative area chart of PM2.5 readings for Bileipada across 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bileipada') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Bileipada 2022', width=600, height=300) return chart " 6459,Show a bar chart of the top 14 cities by median PM2.5 in 2017.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2017] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(14, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 14 Cities by Median PM2.5 in 2017', width=500, height=300) return chart " 6460,"Plot the yearly average PM2.5 trends for Jharkhand, Tripura, and West Bengal from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Tripura', 'West Bengal'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Jharkhand vs Tripura vs West Bengal', width=550, height=320) return chart " 6461,"Create a grouped bar chart comparing the average PM2.5 for Andhra Pradesh, Delhi, and Nagaland across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Delhi', 'Nagaland'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 6462,"Compare the monthly average PM2.5 of Puducherry, Raipur, and Boisar in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Puducherry', 'Raipur', 'Boisar'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Puducherry vs Raipur vs Boisar – 2023', width=550, height=320) return chart " 6463,How many times did Barbil city exceed 45 µg/m³ of PM10 in 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 45.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 6464,Identify the state with the highest average PM2.5 in January 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 6465,"Scatter plot PM2.5 vs PM10 for Tripura stations in 2023, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Tripura') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Tripura Stations 2023', width=450, height=350) " 6466,"Compare the monthly average PM2.5 of Ernakulam, Rourkela, and Bhagalpur in 2020 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Ernakulam', 'Rourkela', 'Bhagalpur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2020)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Ernakulam vs Rourkela vs Bhagalpur – 2020', width=550, height=320) return chart " 6467,Show a monthly bar chart of the number of days Tamil Nadu exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Tamil Nadu') & (data['Timestamp'].dt.year == 2024)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Tamil Nadu Exceeded WHO PM2.5 Guideline per Month – 2024', width=500, height=300) return chart " 6468,Report the state with the 4th lowest NCAP funding considering its total PM10 concentration in 2020 (FY 2019-20).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'sum', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2020_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 6469,Create a summary table ranking the top 20 citys by PM10 concentration in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 6470,Show the number of days each state exceeded a PM10 threshold of 100 µg/m³ in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6471,Tabulate the yearly average PM2.5 trend for Rajasthan across all years.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6472,Tabulate the 20 states with the least PM2.5 pollution in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 6473,List the top 10 citys by average PM10 in 2023 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 6474,Plot the average PM2.5 across all states in February 2023 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['Timestamp'].dt.year == 2023) & (data['Timestamp'].dt.month == 2)] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('PM2.5', ascending=False) chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='plasma'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Average PM2.5 by State – February 2023', width=500, height=400) return chart " 6475,Generate a city × month cross-tab of mean PM2.5 for Gujarat in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Gujarat'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Ahmedabad']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6476,Report the state with the 3rd lowest average PM10 in February 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 6477,List how many days each state breached the PM2.5 limit of 60 µg/m³ in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6478,Tabulate average and median PM2.5 for all citys in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6479,List the average PM2.5 for Durgapur broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Durgapur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6480,"Identify the city with the second-highest average PM2.5 level on January 5, 2021."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 6481,Create a month-wise PM2.5 breakdown table across cities in Assam for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Assam'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Guwahati']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6482,"Visualize the monthly average PM10 for Nagaland, Gujarat, and Tamil Nadu in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Nagaland', 'Gujarat', 'Tamil Nadu'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Nagaland, Gujarat, UP – 2019', width=550, height=320) return chart " 6483,Show the monthly average PM10 trend for Aurangabad from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Aurangabad'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Aurangabad (2019–2024)', width=600, height=300) return chart " 6484,Show the monthly average PM10 trend for Durgapur from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Durgapur'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Durgapur (2019–2024)', width=600, height=300) return chart " 6485,Create a table showing annual mean PM10 levels for Chennai (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Chennai'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6486,Show the monthly average PM2.5 for Kashipur in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Kashipur') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Kashipur 2019', width=450, height=280) " 6487,Show a cumulative area chart of PM2.5 readings for Ujjain across 2019.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ujjain') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Ujjain 2019', width=600, height=300) return chart " 6488,Tabulate the 15 citys with the least PM10 pollution in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 6489,Which city displayed the highest average PM2.5 in December 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 6490,Which station registered the 3rd maximum 25th percentile of PM10 during the Summer season of 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 6491,"Scatter plot PM2.5 vs PM10 for Punjab stations in 2023, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Punjab') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Punjab Stations 2023', width=450, height=350) " 6492,What count of Andhra Pradesh stations surpassed 45 µg/m³ of PM2.5 in 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 45.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 6493,List average PM2.5 by month for Thiruvananthapuram in 2022 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Thiruvananthapuram'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6494,Determine the city having the 5th highest NCAP funding relative to its 75th percentile of PM2.5 concentration in 2021 (FY 2020-21).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 6495,"Plot the yearly average PM2.5 trends for Gujarat, Himachal Pradesh, and Gujarat from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Gujarat', 'Himachal Pradesh', 'Gujarat'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Gujarat vs Himachal Pradesh vs Gujarat', width=550, height=320) return chart " 6496,"Plot the yearly average PM2.5 trends for Odisha, Sikkim, and Andhra Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Odisha', 'Sikkim', 'Andhra Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Odisha vs Sikkim vs Andhra Pradesh', width=550, height=320) return chart " 6497,"Visualize the monthly average PM10 for Rajasthan, Meghalaya, and Jammu and Kashmir in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Meghalaya', 'Jammu and Kashmir'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Rajasthan, Meghalaya, UP – 2021', width=550, height=320) return chart " 6498,"Create a grouped bar chart comparing the average PM2.5 for Nagaland, Odisha, and Puducherry across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Nagaland', 'Odisha', 'Puducherry'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 6499,"On March 31, 2024, which station had the second-highest median PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 6500,"In 2019, which week of the year corresponded to the third-highest median PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'week'}}] " 6501,"Create a grouped bar chart comparing the average PM2.5 for Puducherry, Karnataka, and Bihar across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'Karnataka', 'Bihar'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 6502,Tabulate the 15 citys with the least PM10 pollution in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 6503,"Tabulate PM2.5 statistics (mean, std, min, max) for each city in 2019."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6504,Report which station possessed the third highest 25th percentile of PM10 throughout the Summer season of 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 6505,Determine the city that recorded the most minimal average for PM10 over the Summer season of 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 6506,"Create a grouped bar chart comparing the average PM2.5 for Madhya Pradesh, Karnataka, and Kerala across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Madhya Pradesh', 'Karnataka', 'Kerala'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 6507,"Create a grouped bar chart comparing the average PM2.5 for Rajasthan, Jammu and Kashmir, and West Bengal across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Jammu and Kashmir', 'West Bengal'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 6508,On which date in the last two years did Chennai record its 3rd highest PM2.5 level?," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 2}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'Timestamp'}}] " 6509,List the bottom 15 states with the lowest average PM2.5 in 2017 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 6510,"Scatter plot PM2.5 vs PM10 for Chandigarh stations in 2017, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Chandigarh') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Chandigarh Stations 2017', width=450, height=350) " 6511,Show the monthly average PM2.5 for Delhi in 2023 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Delhi') & (data['Timestamp'].dt.year == 2023)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Delhi 2023', width=450, height=280) " 6512,What date during the previous three years showed Chittorgarh's 3rd lowest PM2.5 reading?," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 3}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'Timestamp'}}] " 6513,List the top 5 states by average PM10 in 2019 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 6514,How many times did Bhopal city surpass the WHO guideline for PM2.5 in 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 15.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 6515,Plot the monthly average PM2.5 trend for Manipur from 2017 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Manipur'].copy() df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly Average PM2.5 Trend – Manipur (2017–2024)', width=600, height=300) return chart " 6516,Generate a year-by-year summary table of PM2.5 readings for Kerala.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6517,Show the monthly average PM2.5 for Gorakhpur in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Gorakhpur') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Gorakhpur 2019', width=450, height=280) " 6518,Create a table showing PM2.5 spread (min to max) and central tendency per city for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6519,Tabulate days with PM10 > 100 µg/m³ and exceedance percentage per state in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6520,Show a cumulative area chart of PM2.5 readings for Munger across 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Munger') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Munger 2023', width=600, height=300) return chart " 6521,Create a bar chart of NCAP funding utilisation rate (%) for each state.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = ncap_funding_data.groupby('state')[ ['Total fund released','Utilisation as on June 2022']].sum().reset_index() df['Utilisation Rate (%)'] = (df['Utilisation as on June 2022'] / df['Total fund released'] * 100).round(1) df = df.sort_values('Utilisation Rate (%)', ascending=False) chart = alt.Chart(df).mark_bar().encode( x=alt.X('Utilisation Rate (%):Q', title='Utilisation Rate (%)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('Utilisation Rate (%):Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('Utilisation Rate (%):Q', format='.1f')] ).properties(title='NCAP Fund Utilisation Rate by State', width=500, height=320) return chart " 6522,Report the state that had the lowest average PM2.5 in May 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 6523,Which 20 states had the lowest mean PM10 in 2021? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 6524,"Which state with a land area below 50,000 km² shows the minimum PM10 level, according to its average PM10 level?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}] " 6525,Which 5 states recorded the highest average PM10 levels in 2021? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 6526,Tabulate mean PM10 alongside state population figures for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6527,Tabulate the top 20 citys for PM2.5 in 2022 along with their corresponding PM10 values.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 6528,Create a summary table ranking the top 5 states by PM10 concentration in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 6529,"Visualize the monthly average PM10 for West Bengal, Puducherry, and Uttarakhand in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['West Bengal', 'Puducherry', 'Uttarakhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: West Bengal, Puducherry, UP – 2023', width=550, height=320) return chart " 6530,Identify the station with the 2nd highest 75th percentile of PM2.5 for July 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 6531,"Visualize the monthly average PM10 for Andhra Pradesh, Assam, and Kerala in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Assam', 'Kerala'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Andhra Pradesh, Assam, UP – 2018', width=550, height=320) return chart " 6532,Show the monthly average PM2.5 for Damoh in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Damoh') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Damoh 2017', width=450, height=280) " 6533,"Visualize the monthly average PM10 for Karnataka, Meghalaya, and Uttarakhand in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Karnataka', 'Meghalaya', 'Uttarakhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Karnataka, Meghalaya, UP – 2023', width=550, height=320) return chart " 6534,"Show descriptive statistics of PM10 (mean, median, std, min, max) per city in 2020."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6535,Determine the city with the 3rd highest median PM10 in December 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 6536,Create a summary table comparing mean PM2.5 and PM10 across states in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6537,"Plot the yearly average PM2.5 trends for Andhra Pradesh, Jharkhand, and Jammu and Kashmir from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Jharkhand', 'Jammu and Kashmir'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Andhra Pradesh vs Jharkhand vs Jammu and Kashmir', width=550, height=320) return chart " 6538,Show a cumulative area chart of PM2.5 readings for Mumbai across 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Mumbai') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Mumbai 2024', width=600, height=300) return chart " 6539,Create a month-wise summary of average PM10 for Kerala in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6540,"In March 2022, identify the station with the lowest 25th percentile of PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 6541,"Comparing July 2019 with July 2020, which state experienced the largest increase in its 75th percentile PM10 level?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 6542,"Visualize the monthly average PM10 for Puducherry, Karnataka, and Bihar in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'Karnataka', 'Bihar'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Puducherry, Karnataka, UP – 2022', width=550, height=320) return chart " 6543,"Create a grouped bar chart comparing the average PM2.5 for Madhya Pradesh, West Bengal, and Rajasthan across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Madhya Pradesh', 'West Bengal', 'Rajasthan'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 6544,Show the monthly average PM2.5 for Chennai in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Chennai') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Chennai 2020', width=450, height=280) " 6545,Show the monthly average PM2.5 for Rupnagar in 2024 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Rupnagar') & (data['Timestamp'].dt.year == 2024)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Rupnagar 2024', width=450, height=280) " 6546,Generate a year-by-year summary table of PM10 readings for Prayagraj.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Prayagraj'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6547,"Visualize the monthly average PM10 for Punjab, Andhra Pradesh, and Nagaland in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Punjab', 'Andhra Pradesh', 'Nagaland'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Punjab, Andhra Pradesh, UP – 2019', width=550, height=320) return chart " 6548,"Which state showed the third-lowest average PM2.5 on March 31, 2018?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 6549,Show a table of the top 15 states by average PM2.5 in 2024 including their PM10 levels too.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 6550,"Compare the monthly average PM2.5 of Prayagraj, Udaipur, and Jaisalmer in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Prayagraj', 'Udaipur', 'Jaisalmer'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Prayagraj vs Udaipur vs Jaisalmer – 2018', width=550, height=320) return chart " 6551,Name the state with the third-lowest 75th percentile for PM10 in May 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 6552,Create a month-wise summary of average PM10 for Andhra Pradesh in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6553,"Visualize the monthly average PM10 for Manipur, Manipur, and Chhattisgarh in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Manipur', 'Manipur', 'Chhattisgarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Manipur, Manipur, UP – 2022', width=550, height=320) return chart " 6554,Tabulate the yearly average PM10 trend for Uttar Pradesh across all years.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6555,"Create a grouped bar chart comparing the average PM2.5 for Kerala, Chandigarh, and Telangana across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Kerala', 'Chandigarh', 'Telangana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 6556,Tabulate the 10 citys with the least PM10 pollution in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 6557,How many times did Punjab city surpass 90 µg/m³ of PM10 in 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 90.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 6558,Generate a year-by-year summary table of PM2.5 readings for Bengaluru.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Bengaluru'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6559,"Plot the yearly average PM2.5 trends for Madhya Pradesh, West Bengal, and Chhattisgarh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Madhya Pradesh', 'West Bengal', 'Chhattisgarh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Madhya Pradesh vs West Bengal vs Chhattisgarh', width=550, height=320) return chart " 6560,Name the city that was second in terms of highest average PM2.5 for June 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 6561,List average PM2.5 by month for Agra in 2018 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Agra'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6562,Show the monthly average PM10 trend for Bhiwani from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Bhiwani'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Bhiwani (2019–2024)', width=600, height=300) return chart " 6563,Tabulate the 10 citys with the least PM10 pollution in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 6564,Determine the station exhibiting the most minimal 25th percentile of PM10 over the Winter season of 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 6565,Show the monthly average PM2.5 for Balasore in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Balasore') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Balasore 2019', width=450, height=280) " 6566,"In June 2019, identify the state with the highest average PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 6567,Plot the rolling 30-day average PM2.5 for West Bengal in 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'West Bengal') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – West Bengal 2022', width=600, height=300) " 6568,Identify the station with the highest 25th percentile of PM2.5 for December 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 6569,Which station showed the 2nd lowest median PM2.5 in August 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 6570,Tabulate the yearly average PM10 trend for Agra across all years.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Agra'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6571,Report which city registered the peak 25th percentile of PM2.5 throughout the Summer season of 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 6572,"Over the past two years in Kohima, on which date was the PM2.5 level the lowest?"," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 2}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'Timestamp'}}] " 6573,"Plot the yearly average PM2.5 trends for Uttarakhand, Telangana, and Rajasthan from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttarakhand', 'Telangana', 'Rajasthan'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Uttarakhand vs Telangana vs Rajasthan', width=550, height=320) return chart " 6574,Determine the state with the 2nd highest 25th percentile of PM2.5 in July 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 6575,Show a table of the top 10 states by average PM2.5 in 2022 including their PM10 levels too.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 6576,Show a cumulative area chart of PM2.5 readings for Bengaluru across 2017.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bengaluru') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Bengaluru 2017', width=600, height=300) return chart " 6577,Create a table of PM10 exceedance frequency above 150 µg/m³ by city for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 150'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6578,"Within the last three years in Araria, on what date was the PM2.5 level the second highest?"," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 3}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'Timestamp'}}] " 6579,Plot the average PM2.5 across all states in February 2022 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['Timestamp'].dt.year == 2022) & (data['Timestamp'].dt.month == 2)] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('PM2.5', ascending=False) chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='plasma'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Average PM2.5 by State – February 2022', width=500, height=400) return chart " 6580,Which station had the 2nd highest 25th percentile of PM2.5 in April 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 6581,"Plot the yearly average PM2.5 trends for Rajasthan, Uttarakhand, and Madhya Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Uttarakhand', 'Madhya Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Rajasthan vs Uttarakhand vs Madhya Pradesh', width=550, height=320) return chart " 6582,Plot the weekly average PM2.5 for Darbhanga in 2021 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Darbhanga') & (data['Timestamp'].dt.year == 2021)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Darbhanga 2021', width=600, height=300) return chart " 6583,"In November 2020, identify the state with the 3rd lowest average PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 6584,Show the monthly average PM10 trend for Baghpat from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Baghpat'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Baghpat (2019–2024)', width=600, height=300) return chart " 6585,"Show the top 10 states by average PM10 in 2020 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2020] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(10, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 10 States by Average PM10 in 2020', width=500, height=300) return chart " 6586,Plot the rolling 30-day average PM2.5 for Andhra Pradesh in 2019 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Andhra Pradesh') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Andhra Pradesh 2019', width=600, height=300) " 6587,Report the station with the 2nd highest 75th percentile of PM10 in January 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 6588,List how many days each state breached the PM2.5 limit of 100 µg/m³ in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6589,Tabulate NCAP funding and how much was utilised by each state.," [ {'op': 'SOURCE', 'params': {'table': 'ncap'}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Total Fund (Cr)', 'col': 'Total fund released', 'fn': 'sum'}, {'alias': 'Utilised (Cr)', 'col': 'Utilisation as on June 2022', 'fn': 'sum'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': {'denominator': 'Total Fund (Cr)', 'new_col': 'Utilisation %', 'numerator': 'Utilised (Cr)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Total Fund (Cr)'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6590,Which city noted the maximum average PM2.5 level?," [{'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 6591,"Visualize the monthly average PM10 for Andhra Pradesh, Puducherry, and Jharkhand in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Puducherry', 'Jharkhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Andhra Pradesh, Puducherry, UP – 2023', width=550, height=320) return chart " 6592,"Plot the yearly average PM2.5 trends for Puducherry, Telangana, and Sikkim from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'Telangana', 'Sikkim'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Puducherry vs Telangana vs Sikkim', width=550, height=320) return chart " 6593,"Visualize the monthly average PM10 for Tamil Nadu, Chhattisgarh, and Punjab in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Chhattisgarh', 'Punjab'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Tamil Nadu, Chhattisgarh, UP – 2019', width=550, height=320) return chart " 6594,List the bottom 5 states with the lowest average PM10 in 2022 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 6595,Generate a table showing the 15 most polluted citys based on mean PM10 for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 6596,List how many days each state breached the PM10 limit of 100 µg/m³ in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6597,Plot the top 5 states by average PM2.5 in 2023 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2023] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(5, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 5 States by Average PM2.5 in 2023', width=500, height=300) return chart " 6598,Create a month-by-state breakdown table of mean PM10 for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Delhi', 'Jharkhand', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Punjab', 'Rajasthan', 'Telangana', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6599,Plot the rolling 30-day average PM2.5 for Tamil Nadu in 2017 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Tamil Nadu') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Tamil Nadu 2017', width=600, height=300) " 6600,Plot the weekly average PM2.5 for Mysuru in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Mysuru') & (data['Timestamp'].dt.year == 2020)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Mysuru 2020', width=600, height=300) return chart " 6601,Show a cumulative area chart of PM2.5 readings for Jalandhar across 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Jalandhar') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Jalandhar 2023', width=600, height=300) return chart " 6602,Report the city with the 4th lowest NCAP funding relative to its 75th percentile of PM10 concentration in 2022 (FY 2021-22).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2022_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 6603,"Create a faceted bar chart showing top 12 states by average PM2.5 per year for 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year.isin([2019,2020,2021,2022])].copy() df['Year'] = df['Timestamp'].dt.year agg = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() top = agg.groupby('Year').apply(lambda x: x.nlargest(12,'PM2.5')).reset_index(drop=True) chart = alt.Chart(top).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Avg PM2.5'), y=alt.Y('state:N', sort='-x'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet(facet='Year:O', columns=2).properties(title='Top 12 States by PM2.5 per Year') return chart " 6604,"Scatter plot PM2.5 vs PM10 for Mizoram stations in 2019, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Mizoram') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Mizoram Stations 2019', width=450, height=350) " 6605,Tabulate average PM10 for each city in Karnataka across all months of 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Bagalkot', 'Belgaum', 'Bengaluru', 'Bidar', 'Chamarajanagar', 'Chikkaballapur', 'Chikkamagaluru', 'Davanagere', 'Dharwad', 'Gadag', 'Hassan', 'Haveri', 'Hubballi', 'Kalaburagi', 'Karwar', 'Kolar', 'Koppal', 'Madikeri', 'Mangalore', 'Mysuru', 'Ramanagara', 'Shivamogga', 'Udupi', 'Vijayapura', 'Yadgir']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6606,Show the monthly average PM2.5 for Puducherry across each year from 2017 to 2024 as small multiples (faceted by year).," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Puducherry'].copy() df['Year'] = df['Timestamp'].dt.year df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5'), tooltip=['Year:O','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet( facet=alt.Facet('Year:O', title='Year'), columns=4 ).properties(title='Monthly PM2.5 in Puducherry by Year (2017–2024)') return chart " 6607,List the top 20 states by average PM2.5 in 2023 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 6608,"Scatter plot PM2.5 vs PM10 for Delhi stations in 2020, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Delhi') & (data['Timestamp'].dt.year == 2020)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Delhi Stations 2020', width=450, height=350) " 6609,Generate a table showing the 15 most polluted citys based on mean PM10 for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 6610,"Visualize the monthly average PM10 for Maharashtra, Haryana, and Chhattisgarh in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Maharashtra', 'Haryana', 'Chhattisgarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Maharashtra, Haryana, UP – 2021', width=550, height=320) return chart " 6611,Show the monthly average PM10 trend for Hassan from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Hassan'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Hassan (2019–2024)', width=600, height=300) return chart " 6612,Tabulate the top 20 citys for PM2.5 in 2021 along with their corresponding PM10 values.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 6613,Create a month-wise summary of average PM2.5 for Andhra Pradesh in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6614,Tabulate average PM2.5 for each city in Uttar Pradesh across all months of 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Agra', 'Baghpat', 'Bulandshahr', 'Ghaziabad', 'Greater Noida', 'Hapur', 'Kanpur', 'Lucknow', 'Meerut', 'Moradabad', 'Muzaffarnagar', 'Noida', 'Varanasi']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6615,Tabulate days with PM10 > 150 µg/m³ and exceedance percentage per state in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 150'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6616,Determine the state exhibiting the 3rd lowest 25th percentile of PM10 over the Winter season of 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 6617,List the top 10 states by PM2.5 in 2019 with both PM2.5 and PM10 averages.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 6618,Create a table of PM2.5 standard violations (>100 µg/m³) per state in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6619,How many times did Bangalore city go above 75 µg/m³ of PM10 in 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 75.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 6620,List states with their PM10 violation count and rate (>150 µg/m³) in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 150'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6621,Create a table of PM2.5 per unit area for all states in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, { 'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM2.5 per km²', 'numerator': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)', 'PM2.5 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6622,Plot the distribution of PM2.5 values in Karnataka across all years using a histogram.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Karnataka'].dropna(subset=['PM2.5']) df = df[['PM2.5']] chart = alt.Chart(df).mark_bar(color='steelblue', opacity=0.75).encode( x=alt.X('PM2\.5:Q', bin=alt.Bin(maxbins=40), title='PM2.5 (µg/m³)'), y=alt.Y('count()', title='Number of Observations'), tooltip=[alt.Tooltip('PM2\.5:Q', bin=True), 'count()'] ).properties(title='PM2.5 Distribution – Karnataka (All Years)', width=500, height=300) return chart " 6623,"Scatter plot PM2.5 vs PM10 for Uttarakhand stations in 2023, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Uttarakhand') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Uttarakhand Stations 2023', width=450, height=350) " 6624,Create a state × year breakdown table of mean PM10 from 2017 to 2024.," [ { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Delhi', 'Haryana', 'Jharkhand', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Odisha', 'Punjab', 'Rajasthan', 'Telangana', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'year', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6625,"Plot the yearly average PM2.5 trends for Bihar, Rajasthan, and Mizoram from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Bihar', 'Rajasthan', 'Mizoram'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Bihar vs Rajasthan vs Mizoram', width=550, height=320) return chart " 6626,Report which state possessed the third highest median PM10 throughout the Monsoon season of 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 6627,Identify the station with the highest average PM10 in September 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 6628,"Scatter plot PM2.5 vs PM10 for Jammu and Kashmir stations in 2019, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Jammu and Kashmir') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Jammu and Kashmir Stations 2019', width=450, height=350) " 6629,Show the monthly average PM10 trend for Hyderabad from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Hyderabad'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Hyderabad (2017–2022)', width=600, height=300) return chart " 6630,Generate a year-by-year summary table of PM10 readings for Maharashtra.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6631,Show a monthly bar chart of the number of days Rajasthan exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Rajasthan') & (data['Timestamp'].dt.year == 2024)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Rajasthan Exceeded WHO PM2.5 Guideline per Month – 2024', width=500, height=300) return chart " 6632,Generate a table showing the 5 most polluted states based on mean PM2.5 for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 6633,"Scatter plot PM2.5 vs PM10 for Sikkim stations in 2021, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Sikkim') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Sikkim Stations 2021', width=450, height=350) " 6634,Show a bar chart of the top 12 cities by median PM2.5 in 2017.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2017] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(12, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 12 Cities by Median PM2.5 in 2017', width=500, height=300) return chart " 6635,Identify the state that showed the highest rise in its 75th percentile PM2.5 level from June 2019 to June 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 6636,Generate a year-by-year summary table of PM2.5 readings for Muzaffarpur.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Muzaffarpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6637,Plot the rolling 30-day average PM2.5 for Mizoram in 2018 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Mizoram') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Mizoram 2018', width=600, height=300) " 6638,Show the monthly average PM2.5 for Panipat in 2024 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Panipat') & (data['Timestamp'].dt.year == 2024)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Panipat 2024', width=450, height=280) " 6639,Which city recorded the highest 75th percentile of PM10 in February 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 6640,Create a summary table comparing mean PM2.5 and PM10 across citys in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6641,Report the city with the 2nd highest median PM10 in April 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 6642,"Visualize the monthly average PM10 for Karnataka, Odisha, and Jammu and Kashmir in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Karnataka', 'Odisha', 'Jammu and Kashmir'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Karnataka, Odisha, UP – 2024', width=550, height=320) return chart " 6643,Show the monthly average PM2.5 for Motihari in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Motihari') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Motihari 2018', width=450, height=280) " 6644,Tabulate average PM10 for each city in Punjab across all months of 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Amritsar', 'Bathinda', 'Jalandhar', 'Khanna', 'Ludhiana', 'Mandi Gobindgarh', 'Patiala', 'Rupnagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6645,Show the monthly average PM2.5 for Chhal in 2023 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Chhal') & (data['Timestamp'].dt.year == 2023)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Chhal 2023', width=450, height=280) " 6646,How many times did Nagaland go above the Indian guideline for PM10 in 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 60.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 6647,Generate a year-by-year summary table of PM10 readings for Madhya Pradesh.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6648,"Create a grouped bar chart comparing the average PM2.5 for Chhattisgarh, Jharkhand, and Haryana across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chhattisgarh', 'Jharkhand', 'Haryana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 6649,Show a cumulative area chart of PM2.5 readings for Baripada across 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Baripada') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Baripada 2022', width=600, height=300) return chart " 6650,"Scatter plot PM2.5 vs PM10 for Nagaland stations in 2020, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Nagaland') & (data['Timestamp'].dt.year == 2020)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Nagaland Stations 2020', width=450, height=350) " 6651,Show a cumulative area chart of PM2.5 readings for Bhiwani across 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bhiwani') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Bhiwani 2024', width=600, height=300) return chart " 6652,Create a ranked table of the 5 best-performing states by PM2.5 in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 6653,Show a cumulative area chart of PM2.5 readings for Visakhapatnam across 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Visakhapatnam') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Visakhapatnam 2022', width=600, height=300) return chart " 6654,Tabulate average PM2.5 for each city in West Bengal across all months of 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'West Bengal'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Asansol', 'Barrackpore', 'Durgapur', 'Haldia', 'Howrah', 'Kolkata', 'Siliguri']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6655,"Visualize the monthly average PM10 for Chhattisgarh, Andhra Pradesh, and Assam in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chhattisgarh', 'Andhra Pradesh', 'Assam'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Chhattisgarh, Andhra Pradesh, UP – 2023', width=550, height=320) return chart " 6656,Which station experienced the second most significant drop in its 75th percentile PM2.5 levels between October and December 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 6657,"Create a grouped bar chart comparing the average PM2.5 for Rajasthan, West Bengal, and Manipur across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'West Bengal', 'Manipur'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 6658,List states with their average PM2.5 and area for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6659,Identify the station that saw the second most significant fall in average PM2.5 levels when comparing December 2021 to October 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 6660,List the top 10 citys by PM2.5 in 2019 with both PM2.5 and PM10 averages.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 6661,"Compare the monthly average PM2.5 of Perundurai, Nagaon, and Purnia in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Perundurai', 'Nagaon', 'Purnia'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Perundurai vs Nagaon vs Purnia – 2023', width=550, height=320) return chart " 6662,Show a cumulative area chart of PM2.5 readings for Bilaspur across 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bilaspur') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Bilaspur 2022', width=600, height=300) return chart " 6663,Create a table of PM10 exceedance frequency above 100 µg/m³ by state for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6664,"Visualize the monthly average PM10 for Uttarakhand, Odisha, and Delhi in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttarakhand', 'Odisha', 'Delhi'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Uttarakhand, Odisha, UP – 2024', width=550, height=320) return chart " 6665,"Create a grouped bar chart comparing the average PM2.5 for Telangana, Manipur, and Bihar across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Telangana', 'Manipur', 'Bihar'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 6666,Show the monthly average PM2.5 for Sangli in 2024 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Sangli') & (data['Timestamp'].dt.year == 2024)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Sangli 2024', width=450, height=280) " 6667,Determine the state exhibiting the 3rd lowest 25th percentile of PM2.5 in August 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 6668,Identify the state that showed the second lowest median PM2.5 during the Monsoon season of 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 6669,Determine the state with the third-highest median PM10 concentration in October 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 6670,"Plot the yearly average PM2.5 trends for Jammu and Kashmir, Delhi, and Haryana from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jammu and Kashmir', 'Delhi', 'Haryana'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Jammu and Kashmir vs Delhi vs Haryana', width=550, height=320) return chart " 6671,Create a table of PM2.5 exceedance frequency above 100 µg/m³ by city for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6672,Which station had the third-highest 75th percentile for PM2.5 in April 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 6673,Show a monthly breakdown table of average PM2.5 for Solapur in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Solapur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6674,Which station experienced the 3rd highest median for PM10 in the Summer season of 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 6675,"In 2024, which city will rank with the largest reduction in average PM10 levels from October to December?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 6676,"In February 2022, identify the station with the 3rd lowest 75th percentile of PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 6677,Which station registered the minimum 75th percentile of PM10 in the Post-Monsoon season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 6678,"On March 31, 2019, which state had the second-highest average PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 6679,Tabulate the monthly mean PM2.5 levels for Mizoram during 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Mizoram'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6680,"Compare the monthly average PM2.5 of Pithampur, Palwal , and Dhanbad in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Pithampur', 'Palwal ', 'Dhanbad'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Pithampur vs Palwal vs Dhanbad – 2022', width=550, height=320) return chart " 6681,"Create a grouped bar chart comparing the average PM2.5 for Himachal Pradesh, Karnataka, and Delhi across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Himachal Pradesh', 'Karnataka', 'Delhi'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 6682,Tabulate the 5 citys with the least PM10 pollution in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 6683,List the top 15 citys by average PM2.5 in 2024 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 6684,"Create a table showing top 15 citys ranked by PM2.5 in 2017, also showing PM10."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 6685,Show the monthly average PM2.5 for Madhya Pradesh across each year from 2017 to 2024 as small multiples (faceted by year).," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Madhya Pradesh'].copy() df['Year'] = df['Timestamp'].dt.year df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5'), tooltip=['Year:O','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet( facet=alt.Facet('Year:O', title='Year'), columns=4 ).properties(title='Monthly PM2.5 in Madhya Pradesh by Year (2017–2024)') return chart " 6686,"Plot the yearly average PM2.5 trends for Andhra Pradesh, Madhya Pradesh, and Odisha from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Madhya Pradesh', 'Odisha'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Andhra Pradesh vs Madhya Pradesh vs Odisha', width=550, height=320) return chart " 6687,Generate a descriptive stats table for PM2.5 grouped by city in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6688,Identify a week showing Panipat's minimum PM2.5 levels across the specified years.," [{'op': 'FILTER', 'params': {'field': 'city', 'value': 'Panipat'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'week'}}] " 6689,Report which station registered the most minimal 25th percentile of PM10 throughout the Monsoon season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 6690,"On March 31, 2023, which state recorded the second-highest 25th percentile of PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 6691,"Show mean, median, minimum, and maximum PM10 for each city in 2022 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6692,"Comparing December 2024 to October 2024, which city showed the most significant drop in median PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 6693,Report the city with the 3rd lowest median PM10 in February 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 6694,"Visualize the monthly average PM10 for Chandigarh, Puducherry, and Puducherry in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chandigarh', 'Puducherry', 'Puducherry'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Chandigarh, Puducherry, UP – 2019', width=550, height=320) return chart " 6695,"Plot the yearly average PM2.5 trends for Assam, Tripura, and Telangana from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Assam', 'Tripura', 'Telangana'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Assam vs Tripura vs Telangana', width=550, height=320) return chart " 6696,Show the monthly average PM10 trend for Jalandhar from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Jalandhar'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Jalandhar (2019–2024)', width=600, height=300) return chart " 6697,Identify the station exhibiting the peak 75th percentile of PM2.5 during the Summer season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 6698,"Tabulate PM10 levels, population, and land area per state in 2023."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6699,List the bottom 20 states with the lowest average PM10 in 2018 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 6700,"Show descriptive statistics of PM2.5 (mean, median, std, min, max) per city in 2018."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'q25', 'median', 'q75']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6701,"Scatter plot PM2.5 vs PM10 for Jammu and Kashmir stations in 2017, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Jammu and Kashmir') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Jammu and Kashmir Stations 2017', width=450, height=350) " 6702,Which 10 states recorded the highest average PM2.5 levels in 2021? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 6703,Create a month-wise PM10 breakdown table across cities in Andhra Pradesh for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Amaravati', 'Rajamahendravaram', 'Tirupati', 'Visakhapatnam']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6704,Which 15 citys recorded the highest average PM2.5 levels in 2022? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 6705,Create a month-wise PM2.5 breakdown table across cities in Kerala for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Eloor', 'Kannur', 'Kochi', 'Kollam', 'Thiruvananthapuram', 'Thrissur']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6706,Tabulate the 10 worst citys for average PM10 in 2018 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 6707,Show PM2.5 density (µg/m³ per km²) by state for 2020 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, { 'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM2.5 per km²', 'numerator': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)', 'PM2.5 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6708,Plot the weekly average PM2.5 for Vijayapura in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Vijayapura') & (data['Timestamp'].dt.year == 2020)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Vijayapura 2020', width=600, height=300) return chart " 6709,Create a table of PM2.5 exceedance frequency above 100 µg/m³ by city for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6710,"Visualize the monthly average PM10 for Karnataka, Assam, and Puducherry in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Karnataka', 'Assam', 'Puducherry'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Karnataka, Assam, UP – 2019', width=550, height=320) return chart " 6711,Which state noted the 2nd minimum median PM2.5 during the Winter season of 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 6712,Tabulate days with PM10 > 150 µg/m³ and exceedance percentage per state in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 150'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6713,Plot the weekly average PM2.5 for Boisar in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Boisar') & (data['Timestamp'].dt.year == 2024)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Boisar 2024', width=600, height=300) return chart " 6714,Determine which state got the 2nd highest NCAP funding with respect to its average PM10 concentration in 2021 (FY 2020-21).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 6715,"In July 2021, report the station with the 3rd lowest average PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 6716,Which city had the 3rd highest average PM10 in January 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 6717,"Plot the yearly average PM2.5 trends for Mizoram, Arunachal Pradesh, and Chhattisgarh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Mizoram', 'Arunachal Pradesh', 'Chhattisgarh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Mizoram vs Arunachal Pradesh vs Chhattisgarh', width=550, height=320) return chart " 6718,"In December 2021, report the station with the highest average PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 6719,Which state recorded the third-lowest average PM10 reading for September 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 6720,Show the monthly average PM2.5 for Raipur in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Raipur') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Raipur 2019', width=450, height=280) " 6721,"In February 2023, report the state with the 3rd highest median PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 6722,"In October 2020, report the station with the highest 25th percentile of PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 6723,Which station had the highest 25th percentile of PM10 in October 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 6724,"In May 2024, report the state with the 2nd highest median PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 6725,Report the city that had the 2nd highest 25th percentile of PM2.5 in August 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 6726,Identify the state with the 2nd highest average PM2.5 for February 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 6727,Which station registered the 3rd highest 25th percentile of PM10 during July 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 6728,Determine the station with the highest average PM2.5 value in March 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 6729,Tabulate the yearly average PM2.5 trend for Himachal Pradesh across all years.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Himachal Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6730,Tabulate average PM10 for each city in Rajasthan across all months of 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Ajmer', 'Alwar', 'Banswara', 'Baran', 'Barmer', 'Bharatpur', 'Bhilwara', 'Bhiwadi', 'Bikaner', 'Bundi', 'Chittorgarh', 'Churu', 'Dausa', 'Dholpur', 'Dungarpur', 'Hanumangarh', 'Jaipur', 'Jaisalmer', 'Jalore', 'Jhalawar', 'Jhunjhunu', 'Jodhpur', 'Karauli', 'Kota', 'Nagaur', 'Pali', 'Pratapgarh', 'Rajsamand', 'Sawai Madhopur', 'Sikar', 'Sirohi', 'Sri Ganganagar', 'Tonk', 'Udaipur']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6731,Show the number of days each city exceeded a PM10 threshold of 100 µg/m³ in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6732,Create a table showing annual mean PM2.5 levels for Meghalaya (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Meghalaya'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6733,Generate a table showing the 5 most polluted states based on mean PM10 for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 6734,Determine which state was granted the 4th highest NCAP funding considering the standard deviation of its PM10 concentration in 2020 (FY 2019-20).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'std', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2020_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 6735,Create a table showing annual mean PM10 levels for Indore (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Indore'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6736,Identify the state that registered the second lowest median PM2.5 during the Summer season of 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 6737,Show average PM2.5 per state in 2024 with area in km².," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6738,Tabulate the monthly mean PM10 levels for Bihar during 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Bihar'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6739,Which station showed the lowest 75th percentile for PM10 in the Summer season of 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 6740,"Visualize the monthly average PM10 for Jharkhand, Delhi, and Himachal Pradesh in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Delhi', 'Himachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Jharkhand, Delhi, UP – 2022', width=550, height=320) return chart " 6741,"Plot the yearly average PM2.5 trends for Arunachal Pradesh, Punjab, and Arunachal Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Arunachal Pradesh', 'Punjab', 'Arunachal Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Arunachal Pradesh vs Punjab vs Arunachal Pradesh', width=550, height=320) return chart " 6742,"On March 31, 2021, which station recorded the second-lowest median PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 6743,"Plot the yearly average PM2.5 trends for Bihar, Arunachal Pradesh, and Chandigarh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Bihar', 'Arunachal Pradesh', 'Chandigarh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Bihar vs Arunachal Pradesh vs Chandigarh', width=550, height=320) return chart " 6744,"Create a grouped bar chart comparing the average PM2.5 for Jharkhand, Arunachal Pradesh, and Kerala across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Arunachal Pradesh', 'Kerala'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 6745,Which station had the 3rd highest 75th percentile of PM10 in December 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 6746,Show the monthly average PM10 trend for Siliguri from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Siliguri'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Siliguri (2019–2024)', width=600, height=300) return chart " 6747,Show a pivot table of monthly average PM10 by city for Uttar Pradesh in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Ghaziabad', 'Moradabad', 'Noida', 'Varanasi']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6748,"Visualize the monthly average PM10 for Maharashtra, Bihar, and Andhra Pradesh in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Maharashtra', 'Bihar', 'Andhra Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Maharashtra, Bihar, UP – 2018', width=550, height=320) return chart " 6749,Identify the station with the 2nd highest 25th percentile of PM10 for October 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 6750,Report which state registered the third highest median PM2.5 throughout the Monsoon season of 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 6751,Show a cumulative area chart of PM2.5 readings for Dhanbad across 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Dhanbad') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Dhanbad 2024', width=600, height=300) return chart " 6752,Determine which city had the 5th lowest NCAP funding relative to its 25th percentile of PM10 concentration in 2020 (FY 2019-20).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2020_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 6753,Which state registered the 3rd highest 25th percentile of PM2.5 during April 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 6754,Show the PM2.5 per 1000 km² (air quality density) for each state in 2021 as a bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): pm = data[data['Timestamp'].dt.year == 2021].groupby('state')['PM2.5'].mean().reset_index().dropna() df = pm.merge(states_data[['state','area (km2)']], on='state') df['PM2.5 per 1000 km²'] = df['PM2.5'] / df['area (km2)'] * 1000 df = df.sort_values('PM2.5 per 1000 km²', ascending=False) chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5 per 1000 km²:Q', title='PM2.5 per 1000 km²'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5 per 1000 km²:Q', scale=alt.Scale(scheme='orangered'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5 per 1000 km²:Q', format='.3f')] ).properties(title='Air Quality Density (PM2.5 per 1000 km²) by State – 2021', width=500, height=400) return chart " 6755,"Scatter plot PM2.5 vs PM10 for Delhi stations in 2024, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Delhi') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Delhi Stations 2024', width=450, height=350) " 6756,Show a ranked table of the 20 most polluted states by average PM2.5 in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 6757,Create a month-wise PM10 breakdown table across cities in Uttar Pradesh for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Agra', 'Bulandshahr', 'Firozabad', 'Ghaziabad', 'Gorakhpur', 'Greater Noida', 'Hapur', 'Kanpur', 'Lucknow', 'Meerut', 'Moradabad', 'Muzaffarnagar', 'Noida', 'Prayagraj', 'Varanasi', 'Vrindavan']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6758,Show a bar chart of the top 12 cities by median PM2.5 in 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2021] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(12, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 12 Cities by Median PM2.5 in 2021', width=500, height=300) return chart " 6759,Show a cumulative area chart of PM2.5 readings for Kolar across 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Kolar') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Kolar 2018', width=600, height=300) return chart " 6760,"Create a grouped bar chart comparing the average PM2.5 for Andhra Pradesh, Arunachal Pradesh, and Telangana across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Arunachal Pradesh', 'Telangana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 6761,"For the year 2019, which weekday had the second-highest average PM2.5 pollution levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'Timestamp'}}] " 6762,"Which state (excluding Union Territories) has the 3rd minimum land area among the top 5 most polluted states, according to the 25th percentile of PM10 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 5, 'ret': 'state'}}] " 6763,How many times did Karnataka exceed 30 µg/m³ of PM10 in 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 30.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 6764,On which date in the past three years did Dindigul register its peak PM10 level?," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 3}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'Timestamp'}}] " 6765,Identify the station that recorded the 2nd lowest 75th percentile of PM10 value in August 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 6766,Which state recorded the 2nd highest 75th percentile of PM2.5 in the Post-Monsoon season of 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 6767,Show a monthly breakdown table of average PM2.5 for Ahmedabad in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Ahmedabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6768,Show a ranked table of the 20 most polluted citys by average PM2.5 in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 6769,"Create a grouped bar chart comparing the average PM2.5 for Tripura, Rajasthan, and Rajasthan across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tripura', 'Rajasthan', 'Rajasthan'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 6770,Report the city that had the 3rd highest 25th percentile of PM2.5 in August 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 6771,Which city experienced the highest median for PM10 in the Summer season of 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 6772,"Visualize the monthly average PM10 for West Bengal, Bihar, and Andhra Pradesh in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['West Bengal', 'Bihar', 'Andhra Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: West Bengal, Bihar, UP – 2018', width=550, height=320) return chart " 6773,Show annual average PM10 for Bhopal as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Bhopal'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6774,Show a heatmap of average PM2.5 for the top 13 most polluted states by month for 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(13).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 13 Polluted States by Month (2023)', width=500, height=300) return chart " 6775,"Between May 2019 and May 2020, which state saw the largest upswing in average PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 6776,Show a ranked table of the 15 most polluted citys by average PM10 in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 6777,Show a pivot table of monthly average PM2.5 by city for Haryana in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Haryana'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Ambala', 'Bahadurgarh', 'Ballabgarh', 'Bhiwani', 'Charkhi Dadri', 'Dharuhera', 'Faridabad', 'Fatehabad', 'Gurugram', 'Hisar', 'Jind', 'Kaithal', 'Karnal', 'Kurukshetra', 'Mandikhera', 'Manesar', 'Narnaul', 'Palwal', 'Panchkula', 'Panipat', 'Rohtak', 'Sirsa', 'Sonipat', 'Yamuna Nagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6778,Show a table of the 20 cleanest states by average PM10 in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 6779,"Which state experienced the second-highest PM2.5 measurements on January 14, 2021?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 6780,Show the monthly average PM10 trend for Aizawl from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Aizawl'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Aizawl (2017–2022)', width=600, height=300) return chart " 6781,"Create a table showing top 10 states ranked by PM2.5 in 2017, also showing PM10."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 6782,Tabulate the 15 worst citys for average PM10 in 2020 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 6783,Tabulate days with PM2.5 > 100 µg/m³ and exceedance percentage per state in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6784,"Visualize the monthly average PM10 for Maharashtra, Uttarakhand, and Uttarakhand in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Maharashtra', 'Uttarakhand', 'Uttarakhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Maharashtra, Uttarakhand, UP – 2021', width=550, height=320) return chart " 6785,"Create a grouped bar chart comparing the average PM2.5 for Meghalaya, Rajasthan, and Odisha across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Meghalaya', 'Rajasthan', 'Odisha'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 6786,Create a ranked table of the 10 best-performing states by PM10 in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 6787,Report the state with the 3rd lowest 25th percentile of PM2.5 in May 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 6788,Show a pivot table of monthly average PM2.5 by city for Punjab in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Amritsar', 'Bathinda', 'Jalandhar', 'Khanna', 'Ludhiana', 'Mandi Gobindgarh', 'Patiala', 'Rupnagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6789,Which city had the 2nd highest median PM10 in November 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 6790,"Plot the yearly average PM2.5 trends for Uttar Pradesh, Nagaland, and Assam from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttar Pradesh', 'Nagaland', 'Assam'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Uttar Pradesh vs Nagaland vs Assam', width=550, height=320) return chart " 6791,"Create a grouped bar chart comparing the average PM2.5 for Tripura, Sikkim, and Rajasthan across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tripura', 'Sikkim', 'Rajasthan'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 6792,"On March 31, 2020, which station had the second-lowest 75th percentile for PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 6793,Which state registered the 2nd maximum 25th percentile of PM2.5 in the Post-Monsoon season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 6794,Plot the weekly average PM2.5 for Bharatpur in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bharatpur') & (data['Timestamp'].dt.year == 2024)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Bharatpur 2024', width=600, height=300) return chart " 6795,Tabulate the yearly average PM2.5 trend for Assam across all years.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Assam'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6796,Show a ranked table of the 10 most polluted states by average PM2.5 in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 6797,"Scatter plot PM2.5 vs PM10 for Meghalaya stations in 2024, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Meghalaya') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Meghalaya Stations 2024', width=450, height=350) " 6798,Which 10 citys had the lowest mean PM10 in 2018? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 6799,Report the station with the 3rd highest 75th percentile of PM10 in October 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 6800,"In August 2023, identify the city with the 3rd lowest median PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 6801,"Plot the yearly average PM2.5 trends for Rajasthan, Sikkim, and Andhra Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Sikkim', 'Andhra Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Rajasthan vs Sikkim vs Andhra Pradesh', width=550, height=320) return chart " 6802,Plot the rolling 30-day average PM2.5 for Haryana in 2018 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Haryana') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Haryana 2018', width=600, height=300) " 6803,Show the number of days each state exceeded a PM2.5 threshold of 100 µg/m³ in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6804,Show how average PM2.5 varied month by month for Chandigarh in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Chandigarh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6805,"Visualize the monthly average PM10 for Telangana, Puducherry, and Arunachal Pradesh in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Telangana', 'Puducherry', 'Arunachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Telangana, Puducherry, UP – 2017', width=550, height=320) return chart " 6806,Report the state with the 3rd lowest average PM10 in November 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 6807,List states with their PM10 violation count and rate (>100 µg/m³) in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6808,Show PM2.5 density (µg/m³ per km²) by state for 2018 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, { 'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM2.5 per km²', 'numerator': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)', 'PM2.5 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6809,Which station registered the 3rd lowest 75th percentile of PM10 during July 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 6810,List states by PM2.5 concentration per million inhabitants in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM2.5 per million', 'numerator': 'PM2.5', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'PM2.5 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6811,Determine the state exhibiting the 2nd most minimal median PM10 over the Winter season of 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 6812,"Identify the season in 2021 (Winter, Summer, Monsoon, Post-Monsoon) that registered the third-highest median PM10 levels."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'season'}}] " 6813,"In 2023, which weekday experienced the maximum 25th percentile of PM2.5 pollution concentrations?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'Timestamp'}}] " 6814,"Visualize the monthly average PM10 for Odisha, Sikkim, and Uttar Pradesh in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Odisha', 'Sikkim', 'Uttar Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Odisha, Sikkim, UP – 2023', width=550, height=320) return chart " 6815,Create a month-wise summary of average PM10 for Thiruvananthapuram in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Thiruvananthapuram'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6816,"In 2019, which season (Winter, Summer, Monsoon, Post-Monsoon) experienced the maximum median PM2.5 concentrations?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'season'}}] " 6817,"Which state showed the third-lowest average PM10 on March 31, 2018?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 6818,How many times did Telangana surpass 45 µg/m³ of PM2.5 in the year 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 45.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 6819,List states with their PM2.5 violation count and rate (>60 µg/m³) in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6820,Identify the state with the 3rd lowest 25th percentile of PM10 for March 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 6821,Create a summary table comparing mean PM2.5 and PM10 across states in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6822,Identify the station with the lowest average PM2.5 in July 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 6823,Show a monthly bar chart of the number of days Manipur exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Manipur') & (data['Timestamp'].dt.year == 2022)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Manipur Exceeded WHO PM2.5 Guideline per Month – 2022', width=500, height=300) return chart " 6824,Report the state with the highest median PM2.5 in August 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 6825,"Visualize the monthly average PM10 for Tamil Nadu, Maharashtra, and Kerala in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Maharashtra', 'Kerala'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Tamil Nadu, Maharashtra, UP – 2024', width=550, height=320) return chart " 6826,Tabulate the monthly mean PM2.5 levels for Hyderabad during 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Hyderabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6827,Determine the city with the lowest median PM2.5 in May 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 6828,"Plot the yearly average PM2.5 trends for Telangana, Odisha, and Assam from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Telangana', 'Odisha', 'Assam'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Telangana vs Odisha vs Assam', width=550, height=320) return chart " 6829,Report which state possessed the lowest 75th percentile for PM10 throughout the Winter season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 6830,What number of Jharkhand stations went above the WHO guideline for PM2.5 in 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 15.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 6831,Report the city with the highest 75th percentile of PM10 in December 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 6832,"Compare the monthly average PM2.5 of Shillong, Palwal , and Jodhpur in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Shillong', 'Palwal ', 'Jodhpur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Shillong vs Palwal vs Jodhpur – 2022', width=550, height=320) return chart " 6833,"Create a grouped bar chart comparing the average PM2.5 for Himachal Pradesh, Haryana, and Kerala across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Himachal Pradesh', 'Haryana', 'Kerala'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 6834,"Create a comprehensive state summary with PM10, population, and area for 2024."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6835,"Show the mean, median and standard deviation of PM2.5 per city in 2023 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6836,"Create a grouped bar chart comparing the average PM2.5 for Uttar Pradesh, Uttarakhand, and Assam across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttar Pradesh', 'Uttarakhand', 'Assam'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 6837,Create a statistical summary table of PM2.5 readings by city for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6838,"Create a grouped bar chart comparing the average PM2.5 for Rajasthan, Manipur, and Arunachal Pradesh across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Manipur', 'Arunachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 6839,"Visualize the monthly average PM10 for Kerala, Tamil Nadu, and Rajasthan in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Kerala', 'Tamil Nadu', 'Rajasthan'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Kerala, Tamil Nadu, UP – 2019', width=550, height=320) return chart " 6840,"Considering all years, which January had the third-lowest median PM2.5 levels?"," [{'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'Timestamp'}}] " 6841,Which state showed the maximum average PM10 level of all time?," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 6842,"Show average PM2.5, PM10 and the number of monitoring stations per state in 2022."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}, {'alias': 'Station Count', 'col': 'station', 'fn': 'nunique'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6843,Which state showed the 2nd lowest average for PM10 in the Monsoon season of 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 6844,Show how many times PM10 exceeded 100 µg/m³ per day across citys in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6845,Create a month-wise summary of average PM10 for Agra in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Agra'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6846,Show a ranked table of the 20 most polluted states by average PM10 in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 6847,Tabulate population-adjusted PM10 levels for each state in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM10 per million', 'numerator': 'PM10', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'PM10 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6848,Show PM10 exceedance count and rate (%) above 150 µg/m³ per city in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 150'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6849,Which 5 states had the lowest mean PM10 in 2019? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 6850,Show the monthly average PM2.5 for Arunachal Pradesh across each year from 2017 to 2024 as small multiples (faceted by year).," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Arunachal Pradesh'].copy() df['Year'] = df['Timestamp'].dt.year df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5'), tooltip=['Year:O','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet( facet=alt.Facet('Year:O', title='Year'), columns=4 ).properties(title='Monthly PM2.5 in Arunachal Pradesh by Year (2017–2024)') return chart " 6851,Which state registered the 2nd lowest average PM2.5 during December 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 6852,"Create a grouped bar chart comparing the average PM2.5 for Manipur, Tripura, and Kerala across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Manipur', 'Tripura', 'Kerala'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 6853,Show a monthly breakdown table of average PM2.5 for West Bengal in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'West Bengal'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6854,Show PM2.5 averages in a state × month matrix for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Delhi', 'Gujarat', 'Haryana', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Meghalaya', 'Odisha', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6855,"Visualize the monthly average PM10 for West Bengal, Nagaland, and Madhya Pradesh in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['West Bengal', 'Nagaland', 'Madhya Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: West Bengal, Nagaland, UP – 2023', width=550, height=320) return chart " 6856,Tabulate days with PM10 > 150 µg/m³ and exceedance percentage per state in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 150'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6857,Identify the city that recorded the highest 25th percentile of PM2.5 value in March 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 6858,Tabulate average PM10 for each city in Maharashtra across all months of 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Aurangabad', 'Kalyan', 'Mumbai', 'Nagpur', 'Nashik', 'Navi Mumbai', 'Pune', 'Solapur', 'Thane']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6859,Show a heatmap of average PM2.5 for the top 15 most polluted states by month for 2019.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(15).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 15 Polluted States by Month (2019)', width=500, height=300) return chart " 6860,How many times did Mira-Bhayandar city exceed 75 µg/m³ of PM10 in the year 2017?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 75.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 6861,Identify the city with the 3rd highest median PM2.5 for May 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 6862,Create a table of PM2.5 per unit area for all states in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, { 'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM2.5 per km²', 'numerator': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)', 'PM2.5 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6863,"Identify the station with the second-highest average PM10 concentration on January 5, 2022."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 6864,"Scatter plot PM2.5 vs PM10 for Himachal Pradesh stations in 2021, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Himachal Pradesh') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Himachal Pradesh Stations 2021', width=450, height=350) " 6865,Generate a monthly average PM2.5 table for Bengaluru for the year 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Bengaluru'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6866,Determine the city that showed the 3rd lowest 75th percentile of PM2.5 over the Post-Monsoon season of 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 6867,How many times did Chandigarh go above 45 µg/m³ of PM2.5 in 2017?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 45.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 6868,Plot the weekly average PM2.5 for Vijayawada in 2019 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Vijayawada') & (data['Timestamp'].dt.year == 2019)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Vijayawada 2019', width=600, height=300) return chart " 6869,Which station had the 2nd highest 25th percentile of PM2.5 in November 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 6870,"Which station showed the second-lowest PM2.5 concentrations on August 15, 2020?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 6871,Show a monthly bar chart of the number of days Andhra Pradesh exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Andhra Pradesh') & (data['Timestamp'].dt.year == 2018)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Andhra Pradesh Exceeded WHO PM2.5 Guideline per Month – 2018', width=500, height=300) return chart " 6872,"For the period October to December 2021, which station had the second smallest decrease in median PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 6873,Which city noted the 3rd minimum 25th percentile of PM2.5 during the Monsoon season of 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 6874,Report the station that had the lowest 75th percentile of PM2.5 in January 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 6875,Tabulate days with PM10 > 100 µg/m³ and exceedance percentage per state in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6876,Find the station with the second-minimum 25th percentile for PM2.5 in August 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 6877,"Compare the monthly average PM2.5 of Yadgir, Panchkula, and Thiruvananthapuram in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Yadgir', 'Panchkula', 'Thiruvananthapuram'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Yadgir vs Panchkula vs Thiruvananthapuram – 2018', width=550, height=320) return chart " 6878,Visualize the bottom 14 states with the lowest average PM2.5 in 2023 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2023] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(14, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 14 States by Average PM2.5 in 2023', width=500, height=300) return chart " 6879,Create a month-wise PM2.5 breakdown table across cities in Bihar for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Bihar'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Gaya', 'Muzaffarpur', 'Patna']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6880,Identify the station with the 2nd highest 25th percentile of PM10 for August 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 6881,Show a cumulative area chart of PM2.5 readings for Hyderabad across 2020.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Hyderabad') & (data['Timestamp'].dt.year == 2020)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Hyderabad 2020', width=600, height=300) return chart " 6882,"Scatter plot PM2.5 vs PM10 for Haryana stations in 2019, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Haryana') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Haryana Stations 2019', width=450, height=350) " 6883,Report which station possessed the 2nd highest median PM10 throughout the Monsoon season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 6884,Tabulate days with PM2.5 > 60 µg/m³ and exceedance percentage per state in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6885,Show how average PM2.5 varied month by month for West Bengal in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'West Bengal'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6886,Which station recorded the highest 75th percentile of PM10 in November 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 6887,List states with their average PM10 and area for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6888,Which city registered the 3rd maximum median PM10 in the Summer season of 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 6889,"Create a grouped bar chart comparing the average PM2.5 for Himachal Pradesh, Delhi, and Himachal Pradesh across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Himachal Pradesh', 'Delhi', 'Himachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 6890,Which 15 citys had the lowest mean PM2.5 in 2023? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 6891,Identify the station that recorded the 2nd highest 75th percentile of PM10 value in October 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 6892,Show a cumulative area chart of PM2.5 readings for Kohima across 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Kohima') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Kohima 2021', width=600, height=300) return chart " 6893,Show a monthly bar chart of the number of days Bihar exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Bihar') & (data['Timestamp'].dt.year == 2022)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Bihar Exceeded WHO PM2.5 Guideline per Month – 2022', width=500, height=300) return chart " 6894,Show a pivot table of monthly average PM10 by city for Karnataka in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Bengaluru']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6895,Show a year-wise table of average PM2.5 for Pune from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Pune'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6896,"In the year 2020, which week recorded the highest 75th percentile for PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'week'}}] " 6897,Report the city with the 2nd highest average PM2.5 in July 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 6898,Show a bar chart of the top 8 cities by median PM2.5 in 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2021] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(8, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 8 Cities by Median PM2.5 in 2021', width=500, height=300) return chart " 6899,How many times did Puducherry city exceed 75 µg/m³ of PM2.5 in the year 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 75.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 6900,Generate a city × month cross-tab of mean PM10 for Maharashtra in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Aurangabad', 'Kalyan', 'Mumbai', 'Nagpur', 'Nashik', 'Navi Mumbai', 'Pune', 'Solapur', 'Thane']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6901,Show a cumulative area chart of PM2.5 readings for Hyderabad across 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Hyderabad') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Hyderabad 2018', width=600, height=300) return chart " 6902,"Tabulate the distribution of PM2.5 per city in 2022 including mean, median, and std."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6903,Tabulate the yearly average PM2.5 trend for Jaipur across all years.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Jaipur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6904,How many times did Jammu and Kashmir exceed 30 µg/m³ of PM10 in 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 30.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 6905,List states by PM2.5 concentration per million inhabitants in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM2.5 per million', 'numerator': 'PM2.5', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'PM2.5 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6906,List the bottom 20 states with the lowest average PM10 in 2021 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 6907,"Create a grouped bar chart comparing the average PM2.5 for West Bengal, Tamil Nadu, and Jharkhand across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['West Bengal', 'Tamil Nadu', 'Jharkhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 6908,"Visualize the monthly average PM10 for Telangana, Gujarat, and West Bengal in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Telangana', 'Gujarat', 'West Bengal'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Telangana, Gujarat, UP – 2017', width=550, height=320) return chart " 6909,Show annual average PM2.5 for Kerala as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6910,Identify the station with the 2nd lowest median PM10 in August 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 6911,"Compare the monthly average PM2.5 of Panipat, Kalyan, and Hisar in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Panipat', 'Kalyan', 'Hisar'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Panipat vs Kalyan vs Hisar – 2019', width=550, height=320) return chart " 6912,Show a monthly breakdown table of average PM2.5 for Bengaluru in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Bengaluru'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6913,Which city noted the 2nd maximum average PM2.5 level?," [{'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 6914,Determine the city exhibiting the 3rd lowest 75th percentile of PM10 in November 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 6915,Show the number of days each city exceeded a PM2.5 threshold of 60 µg/m³ in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6916,Determine the city with the 2nd highest 75th percentile of PM2.5 in December 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 6917,Identify the station with the 3rd lowest average PM10 in July 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 6918,How many stations in Mizoram went above the Indian guideline for PM10 in the year 2017?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 60.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 6919,Show a pivot table of monthly average PM2.5 by state for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Delhi', 'Gujarat', 'Haryana', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6920,"Compare the monthly average PM2.5 of Raichur, Barrackpore, and Navi Raichur in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Raichur', 'Barrackpore', 'Navi Raichur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Raichur vs Barrackpore vs Navi Raichur – 2024', width=550, height=320) return chart " 6921,"Plot the yearly average PM2.5 trends for Punjab, West Bengal, and Chhattisgarh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Punjab', 'West Bengal', 'Chhattisgarh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Punjab vs West Bengal vs Chhattisgarh', width=550, height=320) return chart " 6922,Create a summary table ranking the top 20 citys by PM2.5 concentration in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 6923,Plot the top 9 states by average PM2.5 in 2019 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2019] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(9, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 9 States by Average PM2.5 in 2019', width=500, height=300) return chart " 6924,Identify the state possessing the highest 25th percentile of PM2.5 concentration adjusted for population density.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_capita', 'numerator': 'PM2.5', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'pm_per_capita', 'ascending': False}}] " 6925,"Show a table of average PM2.5, population, and area for all states in 2018."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': { 'map': { 'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6926,"Compare the monthly average PM2.5 of Malegaon, Alwar, and Fatehabad in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Malegaon', 'Alwar', 'Fatehabad'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Malegaon vs Alwar vs Fatehabad – 2023', width=550, height=320) return chart " 6927,"For the period October to December 2019, which city had the second smallest decrease in 75th percentile PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 6928,Report the station with the 3rd lowest average PM10 in May 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 6929,Show how many times PM10 exceeded 100 µg/m³ per day across citys in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6930,Show a cross-tab of state vs year for average PM2.5 levels.," [ { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Bihar', 'Delhi', 'Gujarat', 'Haryana', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Odisha', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Uttar Pradesh']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'year', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6931,Report the state with the highest 75th percentile of PM2.5 in September 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 6932,"Scatter plot PM2.5 vs PM10 for Telangana stations in 2018, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Telangana') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Telangana Stations 2018', width=450, height=350) " 6933,"Show a table of average PM2.5, population, and area for all states in 2019."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': { 'map': { 'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6934,List the bottom 20 states with the lowest average PM2.5 in 2020 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 6935,"Create a grouped bar chart comparing the average PM2.5 for Haryana, Chhattisgarh, and Odisha across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Chhattisgarh', 'Odisha'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 6936,"Show the mean, median and standard deviation of PM2.5 per city in 2017 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6937,Show a monthly breakdown table of average PM2.5 for Tamil Nadu in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6938,"Visualize the monthly average PM10 for Rajasthan, Madhya Pradesh, and Odisha in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Madhya Pradesh', 'Odisha'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Rajasthan, Madhya Pradesh, UP – 2023', width=550, height=320) return chart " 6939,List the bottom 10 citys with the lowest average PM10 in 2018 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 6940,Show a pivot table of monthly average PM2.5 by city for Odisha in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Odisha'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Brajrajnagar', 'Talcher']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6941,Create a table of state PM10 levels and geographic area for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6942,Plot the rolling 30-day average PM2.5 for Puducherry in 2018 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Puducherry') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Puducherry 2018', width=600, height=300) " 6943,Identify the city with the 3rd highest NCAP funding considering its median PM2.5 concentration in 2021 (FY 2020-21).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 6944,Report which city experienced the 2nd highest average PM10 throughout the Post-Monsoon season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 6945,"Compare the monthly average PM2.5 of Solapur, Ambala, and Ramanagara in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Solapur', 'Ambala', 'Ramanagara'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Solapur vs Ambala vs Ramanagara – 2024', width=550, height=320) return chart " 6946,Plot the rolling 30-day average PM2.5 for Himachal Pradesh in 2017 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Himachal Pradesh') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Himachal Pradesh 2017', width=600, height=300) " 6947,"Visualize the monthly average PM10 for Andhra Pradesh, Telangana, and Uttar Pradesh in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Telangana', 'Uttar Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Andhra Pradesh, Telangana, UP – 2018', width=550, height=320) return chart " 6948,Show how many times PM10 exceeded 150 µg/m³ per day across citys in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6949,Generate a table showing the 20 most polluted citys based on mean PM10 for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 6950,"Compare the monthly average PM2.5 of Malegaon, Kadapa, and Patna in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Malegaon', 'Kadapa', 'Patna'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Malegaon vs Kadapa vs Patna – 2022', width=550, height=320) return chart " 6951,Show a table of the 10 cleanest citys by average PM2.5 in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 6952,Determine the station exhibiting the lowest median PM2.5 in August 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 6953,"Compare the monthly average PM2.5 of Yadgir, Dholpur, and Barrackpore in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Yadgir', 'Dholpur', 'Barrackpore'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Yadgir vs Dholpur vs Barrackpore – 2023', width=550, height=320) return chart " 6954,Identify the state that recorded the 2nd lowest 75th percentile of PM10 value in February 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 6955,Visualize the bottom 8 states with the lowest average PM2.5 in 2022 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2022] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(8, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 8 States by Average PM2.5 in 2022', width=500, height=300) return chart " 6956,Plot the distribution of PM2.5 values in Punjab across all years using a histogram.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Punjab'].dropna(subset=['PM2.5']) df = df[['PM2.5']] chart = alt.Chart(df).mark_bar(color='steelblue', opacity=0.75).encode( x=alt.X('PM2\.5:Q', bin=alt.Bin(maxbins=40), title='PM2.5 (µg/m³)'), y=alt.Y('count()', title='Number of Observations'), tooltip=[alt.Tooltip('PM2\.5:Q', bin=True), 'count()'] ).properties(title='PM2.5 Distribution – Punjab (All Years)', width=500, height=300) return chart " 6957,Identify the station that registered the third lowest average for PM2.5 during the Post-Monsoon season of 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 6958,"Visualize the monthly average PM10 for Madhya Pradesh, Chandigarh, and Rajasthan in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Madhya Pradesh', 'Chandigarh', 'Rajasthan'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Madhya Pradesh, Chandigarh, UP – 2019', width=550, height=320) return chart " 6959,Which city had the lowest average PM10 in August 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 6960,"Identify the state with the highest median PM10 on March 31, 2019."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 6961,Report the city that had the 3rd highest average PM2.5 in September 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 6962,"Plot the yearly average PM2.5 trends for Himachal Pradesh, Maharashtra, and Nagaland from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Himachal Pradesh', 'Maharashtra', 'Nagaland'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Himachal Pradesh vs Maharashtra vs Nagaland', width=550, height=320) return chart " 6963,Generate a monthly average PM2.5 table for Muzaffarpur for the year 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Muzaffarpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6964,What city holds the position of third-lowest for the 25th percentile of PM2.5 in January 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 6965,Tabulate the yearly average PM10 trend for Lucknow across all years.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Lucknow'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6966,"Show the top 7 states by average PM10 in 2023 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2023] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(7, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 7 States by Average PM10 in 2023', width=500, height=300) return chart " 6967,Identify the station with the 3rd highest 25th percentile of PM10 for September 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 6968,Show the monthly average PM10 trend for Faridabad from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Faridabad'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Faridabad (2019–2024)', width=600, height=300) return chart " 6969,Show a pivot table of monthly average PM10 by city for Haryana in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Haryana'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Ambala', 'Bahadurgarh', 'Ballabgarh', 'Bhiwani', 'Dharuhera', 'Fatehabad', 'Gurugram', 'Hisar', 'Jind', 'Karnal', 'Kurukshetra', 'Mandikhera', 'Manesar', 'Narnaul', 'Palwal', 'Panipat', 'Sirsa', 'Sonipat', 'Yamuna Nagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6970,Show the monthly average PM2.5 for Belapur in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Belapur') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Belapur 2018', width=450, height=280) " 6971,"Visualize the monthly average PM10 for Puducherry, Rajasthan, and Sikkim in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'Rajasthan', 'Sikkim'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Puducherry, Rajasthan, UP – 2018', width=550, height=320) return chart " 6972,"Compare the monthly average PM2.5 of Ludhiana, Bhubaneswar, and Jalna in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Ludhiana', 'Bhubaneswar', 'Jalna'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Ludhiana vs Bhubaneswar vs Jalna – 2022', width=550, height=320) return chart " 6973,Show a cumulative area chart of PM2.5 readings for Kochi across 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Kochi') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Kochi 2022', width=600, height=300) return chart " 6974,Plot the rolling 30-day average PM2.5 for Rajasthan in 2019 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Rajasthan') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Rajasthan 2019', width=600, height=300) " 6975,"Plot the yearly average PM2.5 trends for Rajasthan, Sikkim, and Punjab from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Sikkim', 'Punjab'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Rajasthan vs Sikkim vs Punjab', width=550, height=320) return chart " 6976,Show a table of the top 15 states by average PM2.5 in 2023 including their PM10 levels too.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 6977,"Show the top 8 states by average PM10 in 2017 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2017] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(8, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 8 States by Average PM10 in 2017', width=500, height=300) return chart " 6978,Determine the state with the lowest median PM2.5 in March 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 6979,Identify the station that recorded the third highest 25th percentile of PM10 during the Summer season of 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 6980,Visualize the bottom 7 states with the lowest average PM2.5 in 2018 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2018] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(7, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 7 States by Average PM2.5 in 2018', width=500, height=300) return chart " 6981,Show how average PM10 varied month by month for Thiruvananthapuram in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Thiruvananthapuram'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6982,Which city had the lowest 75th percentile of PM2.5 in August 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 6983,Show a ranked table of the 10 most polluted states by average PM2.5 in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 6984,Show average PM2.5 per capita by state in 2020 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM2.5 per million', 'numerator': 'PM2.5', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'PM2.5 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6985,"For the year 2023, which season (Winter, Summer, Monsoon, Post-Monsoon) had the second-highest average PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'season'}}] " 6986,"Visualize the monthly average PM10 for Odisha, Uttarakhand, and Kerala in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Odisha', 'Uttarakhand', 'Kerala'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Odisha, Uttarakhand, UP – 2024', width=550, height=320) return chart " 6987,Determine the state with the lowest 25th percentile of PM10 in July 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 6988,Create a month-wise summary of average PM10 for Meghalaya in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Meghalaya'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6989,Show the monthly average PM2.5 for Maharashtra across each year from 2017 to 2024 as small multiples (faceted by year).," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Maharashtra'].copy() df['Year'] = df['Timestamp'].dt.year df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5'), tooltip=['Year:O','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet( facet=alt.Facet('Year:O', title='Year'), columns=4 ).properties(title='Monthly PM2.5 in Maharashtra by Year (2017–2024)') return chart " 6990,Determine the state which was granted the 2nd lowest NCAP funding considering its 75th percentile of PM10 concentration in 2021 (FY 2020-21).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 6991,"In the year 2024, which weekday recorded the second-highest 25th percentile for PM2.5 pollution levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'Timestamp'}}] " 6992,List the average PM10 for Ghaziabad broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Ghaziabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6993,Generate a city × month cross-tab of mean PM10 for Madhya Pradesh in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Bhopal', 'Damoh', 'Dewas', 'Gwalior', 'Indore', 'Jabalpur', 'Katni', 'Maihar', 'Mandideep', 'Pithampur', 'Ratlam', 'Sagar', 'Satna', 'Singrauli', 'Ujjain']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6994,Tabulate days with PM2.5 > 60 µg/m³ and exceedance percentage per state in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6995,Show a table of the 20 cleanest states by average PM2.5 in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 6996,Show annual average PM2.5 for Chandigarh as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Chandigarh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6997,"Show the top 5 states by average PM10 in 2021 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2021] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(5, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 5 States by Average PM10 in 2021', width=500, height=300) return chart " 6998,Tabulate daily PM10 exceedances (above 150 µg/m³) per state for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 6999,"Plot the yearly average PM2.5 trends for Uttar Pradesh, Himachal Pradesh, and Nagaland from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttar Pradesh', 'Himachal Pradesh', 'Nagaland'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Uttar Pradesh vs Himachal Pradesh vs Nagaland', width=550, height=320) return chart " 7000,List the bottom 10 citys with the lowest average PM2.5 in 2024 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 7001,Create a table showing annual mean PM2.5 levels for Kota (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Kota'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7002,Show a heatmap of average PM2.5 for the top 8 most polluted states by month for 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(8).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 8 Polluted States by Month (2023)', width=500, height=300) return chart " 7003,List states with their average PM10 and area for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7004,"Visualize the monthly average PM10 for Kerala, Haryana, and Uttar Pradesh in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Kerala', 'Haryana', 'Uttar Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Kerala, Haryana, UP – 2022', width=550, height=320) return chart " 7005,How many times did Andhra Pradesh go above the WHO guideline for PM2.5 in the year 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 15.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 7006,Which state recorded the highest 25th percentile of PM10 in July 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 7007,"Visualize the monthly average PM10 for Punjab, Chandigarh, and Arunachal Pradesh in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Punjab', 'Chandigarh', 'Arunachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Punjab, Chandigarh, UP – 2021', width=550, height=320) return chart " 7008,Which station had the 3rd lowest 25th percentile of PM10 in July 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 7009,"Tabulate PM2.5 levels, population, and land area per state in 2021."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': { 'map': { 'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7010,Report the state with the highest 75th percentile of PM2.5 in April 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 7011,Show the monthly average PM10 trend for Jalandhar from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Jalandhar'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Jalandhar (2017–2022)', width=600, height=300) return chart " 7012,Identify the station that saw the third least significant fall in 25th percentile PM10 levels when comparing December 2024 to October 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 7013,"In July 2022, which state registered the 3rd highest 25th percentile of PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 7014,Show a bar chart of the top 12 cities by median PM2.5 in 2020.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2020] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(12, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 12 Cities by Median PM2.5 in 2020', width=500, height=300) return chart " 7015,"Scatter plot PM2.5 vs PM10 for Jharkhand stations in 2023, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Jharkhand') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Jharkhand Stations 2023', width=450, height=350) " 7016,Identify the state exhibiting the second highest average PM2.5 during the Monsoon season of 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 7017,List citys with their PM2.5 violation count and rate (>60 µg/m³) in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7018,Tabulate the 15 worst citys for average PM2.5 in 2021 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 7019,Create a summary table comparing mean PM2.5 and PM10 across states in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7020,Generate a table showing the 5 most polluted citys based on mean PM10 for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 7021,List states with their PM10 violation count and rate (>100 µg/m³) in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7022,Determine the state that has the 5th lowest average PM10 concentration adjusted for population density.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_capita', 'numerator': 'PM10', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'pm_per_capita', 'ascending': True}}] " 7023,List how many days each state breached the PM2.5 limit of 60 µg/m³ in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7024,"Which state (excluding Union Territories) possesses the 2nd largest land area among the top 5 most polluted states, based on the 25th percentile of PM2.5 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 5, 'ret': 'state'}}] " 7025,"Create a grouped bar chart comparing the average PM2.5 for Telangana, Jammu and Kashmir, and Andhra Pradesh across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Telangana', 'Jammu and Kashmir', 'Andhra Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 7026,Show a cumulative area chart of PM2.5 readings for Satna across 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Satna') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Satna 2022', width=600, height=300) return chart " 7027,"Plot the yearly average PM2.5 trends for Tamil Nadu, Telangana, and Jharkhand from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Telangana', 'Jharkhand'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Tamil Nadu vs Telangana vs Jharkhand', width=550, height=320) return chart " 7028,"Visualize the monthly average PM10 for Rajasthan, Karnataka, and Chandigarh in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Karnataka', 'Chandigarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Rajasthan, Karnataka, UP – 2023', width=550, height=320) return chart " 7029,Show a monthly breakdown table of average PM2.5 for Varanasi in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Varanasi'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7030,Plot the weekly average PM2.5 for Kolar in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Kolar') & (data['Timestamp'].dt.year == 2020)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Kolar 2020', width=600, height=300) return chart " 7031,Tabulate daily PM2.5 exceedances (above 60 µg/m³) per city for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7032,Create a table of PM2.5 exceedance frequency above 60 µg/m³ by city for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7033,Determine the station that showed the 3rd highest median PM10 over the Post-Monsoon season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 7034,"Visualize the monthly average PM10 for Sikkim, Tamil Nadu, and Himachal Pradesh in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Sikkim', 'Tamil Nadu', 'Himachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Sikkim, Tamil Nadu, UP – 2022', width=550, height=320) return chart " 7035,Show a monthly bar chart of the number of days Chandigarh exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Chandigarh') & (data['Timestamp'].dt.year == 2022)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Chandigarh Exceeded WHO PM2.5 Guideline per Month – 2022', width=500, height=300) return chart " 7036,Create a month-wise PM2.5 breakdown table across cities in Kerala for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Eloor', 'Kannur', 'Kochi', 'Kollam', 'Kozhikode', 'Thiruvananthapuram', 'Thrissur']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7037,"Create a grouped bar chart comparing the average PM2.5 for Chandigarh, Jammu and Kashmir, and Andhra Pradesh across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chandigarh', 'Jammu and Kashmir', 'Andhra Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 7038,"Plot the yearly average PM2.5 trends for Jharkhand, Telangana, and Uttarakhand from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Telangana', 'Uttarakhand'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Jharkhand vs Telangana vs Uttarakhand', width=550, height=320) return chart " 7039,List average PM10 by month for Noida in 2021 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Noida'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7040,"Create a grouped bar chart comparing the average PM2.5 for Sikkim, Tamil Nadu, and Jharkhand across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Sikkim', 'Tamil Nadu', 'Jharkhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 7041,List the top 5 citys by average PM10 in 2021 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 7042,Which city possessed the 2nd lowest median for PM10 in the Post-Monsoon season of 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 7043,"Create a grouped bar chart comparing the average PM2.5 for Assam, Meghalaya, and Bihar across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Assam', 'Meghalaya', 'Bihar'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 7044,Which state documented the highest PM2.5 levels amidst the COVID-19 lockdown in April 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 7045,Which state registered the minimum median PM10 in the Winter season of 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 7046,"Plot the yearly average PM2.5 trends for Tamil Nadu, Punjab, and Gujarat from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Punjab', 'Gujarat'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Tamil Nadu vs Punjab vs Gujarat', width=550, height=320) return chart " 7047,Plot the rolling 30-day average PM2.5 for Odisha in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Odisha') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Odisha 2024', width=600, height=300) " 7048,Show the monthly average PM10 trend for Bhagalpur from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Bhagalpur'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Bhagalpur (2019–2024)', width=600, height=300) return chart " 7049,Show the monthly average PM10 trend for Mangalore from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Mangalore'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Mangalore (2017–2022)', width=600, height=300) return chart " 7050,Show a year-wise table of average PM10 for Agra from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Agra'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7051,Show the monthly average PM10 trend for Manesar from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Manesar'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Manesar (2019–2024)', width=600, height=300) return chart " 7052,Show a scatter plot of total NCAP funding vs average PM2.5 (2022) per state.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): pm = data[data['Timestamp'].dt.year == 2022].groupby('state')['PM2.5'].mean().reset_index() funding = ncap_funding_data.groupby('state')['Total fund released'].sum().reset_index() df = pm.merge(funding, on='state').dropna() chart = alt.Chart(df).mark_point(filled=True, size=100).encode( x=alt.X('Total fund released:Q', title='Total NCAP Funding (Cr)'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 – 2022 (µg/m³)'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('Total fund released:Q', format='.1f')] ).properties(title='NCAP Funding vs Average PM2.5 by State (2022)', width=450, height=350) return chart " 7053,Which city showed the lowest 75th percentile of PM2.5 in July 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 7054,Determine the city with NCAP funding that has the 4th highest PM10 levels.," [{'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}] " 7055,"Visualize the monthly average PM10 for Nagaland, Jharkhand, and Gujarat in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Nagaland', 'Jharkhand', 'Gujarat'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Nagaland, Jharkhand, UP – 2018', width=550, height=320) return chart " 7056,"Which state showed the minimum 75th percentile for PM2.5 on March 31, 2024?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 7057,Generate a monthly average PM10 table for Nagpur for the year 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Nagpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7058,Report the city with the 2nd highest 25th percentile of PM2.5 in January 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 7059,"Show the mean, median and standard deviation of PM2.5 per city in 2022 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7060,Tabulate daily PM2.5 exceedances (above 60 µg/m³) per city for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7061,Determine which state shows the lowest variance of PM2.5 concentration adjusted for population density.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'var', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_capita', 'numerator': 'PM2.5', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'pm_per_capita', 'ascending': True}}] " 7062,List states by PM10 concentration per million inhabitants in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM10 per million', 'numerator': 'PM10', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'PM10 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7063,Which 15 citys had the lowest mean PM10 in 2024? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 7064,Tabulate population-adjusted PM10 levels for each state in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM10 per million', 'numerator': 'PM10', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'PM10 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7065,Which station had the 3rd highest 75th percentile of PM2.5 in July 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 7066,Show a cumulative area chart of PM2.5 readings for Shivamogga across 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Shivamogga') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Shivamogga 2023', width=600, height=300) return chart " 7067,What date over the previous three years noted Chikkaballapur's highest PM10 reading?," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 3}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'Timestamp'}}] " 7068,"Create a grouped bar chart comparing the average PM2.5 for Tamil Nadu, Rajasthan, and Telangana across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Rajasthan', 'Telangana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 7069,"Create a grouped bar chart comparing the average PM2.5 for Tripura, Delhi, and Chandigarh across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tripura', 'Delhi', 'Chandigarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 7070,Create a table showing annual mean PM2.5 levels for Durgapur (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Durgapur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7071,Which state recorded the 3rd lowest 25th percentile of PM10 in September 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 7072,Visualize the bottom 11 states with the lowest average PM2.5 in 2018 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2018] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(11, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 11 States by Average PM2.5 in 2018', width=500, height=300) return chart " 7073,"Create a comprehensive state summary with PM2.5, population, and area for 2021."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': { 'map': { 'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7074,Show the monthly average PM2.5 for Raipur in 2024 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Raipur') & (data['Timestamp'].dt.year == 2024)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Raipur 2024', width=450, height=280) " 7075,Show the monthly average PM10 trend for Kashipur from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Kashipur'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Kashipur (2019–2024)', width=600, height=300) return chart " 7076,"Compare the monthly average PM2.5 of Srinagar, Dharuhera, and Panipat in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Srinagar', 'Dharuhera', 'Panipat'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Srinagar vs Dharuhera vs Panipat – 2022', width=550, height=320) return chart " 7077,Show the number of days each city exceeded a PM10 threshold of 150 µg/m³ in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7078,Which city experienced the 2nd highest 75th percentile for PM10 in the Winter season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 7079,"Scatter plot PM2.5 vs PM10 for Manipur stations in 2019, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Manipur') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Manipur Stations 2019', width=450, height=350) " 7080,Show a monthly bar chart of the number of days Meghalaya exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Meghalaya') & (data['Timestamp'].dt.year == 2021)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Meghalaya Exceeded WHO PM2.5 Guideline per Month – 2021', width=500, height=300) return chart " 7081,Report the city with the 4th lowest NCAP funding relative to the variance of its PM10 concentration in 2021 (FY 2020-21).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'var', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 7082,"Identify the city that recorded the third most minimal PM10 level on January 27, 2022."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 7083,Which station possessed the 2nd lowest median for PM10 in the Summer season of 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 7084,"Considering all years, which January was associated with the lowest 25th percentile of PM10 levels?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'Timestamp'}}] " 7085,"Create a grouped bar chart comparing the average PM2.5 for West Bengal, Arunachal Pradesh, and Meghalaya across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['West Bengal', 'Arunachal Pradesh', 'Meghalaya'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 7086,Visualize the bottom 15 states with the lowest average PM2.5 in 2024 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2024] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(15, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 15 States by Average PM2.5 in 2024', width=500, height=300) return chart " 7087,"Report which state, among those with a population exceeding the median, receives the 2nd highest per capita NCAP funding."," [{'op': 'COMPUTE', 'params': {'new_col': 'funding_per_capita', 'numerator': 'total_fund', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'funding_per_capita', 'ascending': False}}] " 7088,How many times did Gujarat go above 90 µg/m³ of PM2.5 in the year 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 90.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 7089,"Create a grouped bar chart comparing the average PM2.5 for Andhra Pradesh, Delhi, and Jammu and Kashmir across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Delhi', 'Jammu and Kashmir'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 7090,Which station possessed the 3rd highest 75th percentile for PM10 in the Monsoon season of 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 7091,Report the city with the 2nd highest median PM10 in August 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 7092,Create a ranked table of the 15 best-performing states by PM10 in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 7093,"Which state with a land area below 50,000 km² shows the 3rd highest PM10 level, according to its median PM10 level?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}] " 7094,Show a pivot table of monthly average PM10 by city for Karnataka in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Bagalkot', 'Belgaum', 'Bengaluru', 'Bidar', 'Chamarajanagar', 'Chikkaballapur', 'Chikkamagaluru', 'Davanagere', 'Dharwad', 'Gadag', 'Hassan', 'Haveri', 'Hubballi', 'Kalaburagi', 'Koppal', 'Madikeri', 'Mangalore', 'Mysuru', 'Raichur', 'Ramanagara', 'Shivamogga', 'Tumakuru', 'Udupi', 'Vijayapura', 'Yadgir']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7095,Show the monthly average PM2.5 for Tirunelveli in 2022 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Tirunelveli') & (data['Timestamp'].dt.year == 2022)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Tirunelveli 2022', width=450, height=280) " 7096,Which city registered the lowest 25th percentile of PM10 during September 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 7097,Report the state that had the 3rd lowest 25th percentile of PM2.5 in June 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 7098,Show a pivot table of monthly average PM10 by city for West Bengal in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'West Bengal'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Durgapur']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7099,Create a month-wise summary of average PM2.5 for Andhra Pradesh in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7100,"Plot the yearly average PM2.5 trends for Andhra Pradesh, Gujarat, and Karnataka from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Gujarat', 'Karnataka'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Andhra Pradesh vs Gujarat vs Karnataka', width=550, height=320) return chart " 7101,Create a month-wise PM2.5 breakdown table across cities in Rajasthan for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Ajmer', 'Alwar', 'Bhiwadi', 'Jaipur', 'Jodhpur', 'Kota', 'Pali', 'Udaipur']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7102,"Which state (excluding Union Territories) has the 2nd highest land area among the top 5 most polluted states, according to average PM2.5 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 5, 'ret': 'state'}}] " 7103,Create a month-wise PM2.5 breakdown table across cities in Kerala for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Eloor', 'Ernakulam', 'Kannur', 'Kochi', 'Kollam', 'Kozhikode', 'Thiruvananthapuram', 'Thrissur']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7104,Create a per-capita PM2.5 summary table by state for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM2.5 per million', 'numerator': 'PM2.5', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'PM2.5 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7105,Identify the city that recorded the third highest 25th percentile of PM2.5 during the Summer season of 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 7106,Show how many times PM10 exceeded 150 µg/m³ per day across states in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7107,Generate a table showing the 5 most polluted citys based on mean PM10 for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 7108,Show the monthly average PM2.5 for Ankleshwar in 2023 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ankleshwar') & (data['Timestamp'].dt.year == 2023)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Ankleshwar 2023', width=450, height=280) " 7109,"Visualize the monthly average PM10 for Tamil Nadu, Uttarakhand, and Punjab in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Uttarakhand', 'Punjab'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Tamil Nadu, Uttarakhand, UP – 2022', width=550, height=320) return chart " 7110,"Create a grouped bar chart comparing the average PM2.5 for Delhi, West Bengal, and Meghalaya across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Delhi', 'West Bengal', 'Meghalaya'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 7111,Show the monthly average PM10 trend for Ankleshwar from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Ankleshwar'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Ankleshwar (2017–2022)', width=600, height=300) return chart " 7112,Create a statistical summary table of PM2.5 readings by state for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7113,"On March 31, 2020, which city recorded the second-highest median PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 7114,Create a table showing PM10 levels and population for each state in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7115,Generate a cross-tab of state vs month for average PM10 in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Delhi', 'Karnataka', 'Maharashtra', 'Telangana', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7116,Report the state with the 3rd lowest 25th percentile of PM2.5 in March 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 7117,"Create a grouped bar chart comparing the average PM2.5 for Chandigarh, Kerala, and Telangana across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chandigarh', 'Kerala', 'Telangana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 7118,Determine the station that recorded the 3rd highest median PM2.5 over the Monsoon season of 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 7119,Plot the monthly average PM2.5 trend for Karnataka from 2017 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Karnataka'].copy() df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly Average PM2.5 Trend – Karnataka (2017–2024)', width=600, height=300) return chart " 7120,"Scatter plot PM2.5 vs PM10 for Tripura stations in 2024, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Tripura') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Tripura Stations 2024', width=450, height=350) " 7121,Which 15 states had the lowest mean PM10 in 2019? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 7122,How many stations in Andhra Pradesh exceeded 75 µg/m³ of PM2.5 in the year 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 75.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 7123,Which city had the lowest 75th percentile of PM10 in March 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 7124,List how many days each state breached the PM2.5 limit of 100 µg/m³ in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7125,Identify the city that recorded the 2nd highest 25th percentile of PM2.5 value in January 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 7126,Report the city that had the 2nd highest 75th percentile of PM10 in March 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 7127,Tabulate daily PM10 exceedances (above 150 µg/m³) per city for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7128,Generate a city × month cross-tab of mean PM2.5 for Odisha in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Odisha'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Brajrajnagar', 'Talcher']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7129,"Plot the yearly average PM2.5 trends for Rajasthan, Haryana, and West Bengal from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Haryana', 'West Bengal'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Rajasthan vs Haryana vs West Bengal', width=550, height=320) return chart " 7130,Generate a table showing the 10 most polluted states based on mean PM10 for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 7131,Show the number of days each city exceeded a PM10 threshold of 150 µg/m³ in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7132,"Plot the yearly average PM2.5 trends for Nagaland, Nagaland, and Puducherry from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Nagaland', 'Nagaland', 'Puducherry'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Nagaland vs Nagaland vs Puducherry', width=550, height=320) return chart " 7133,"Create a grouped bar chart comparing the average PM2.5 for Puducherry, Himachal Pradesh, and Bihar across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'Himachal Pradesh', 'Bihar'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 7134,Plot the weekly average PM2.5 for Prayagraj in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Prayagraj') & (data['Timestamp'].dt.year == 2024)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Prayagraj 2024', width=600, height=300) return chart " 7135,"Plot the yearly average PM2.5 trends for Delhi, Manipur, and Himachal Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Delhi', 'Manipur', 'Himachal Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Delhi vs Manipur vs Himachal Pradesh', width=550, height=320) return chart " 7136,"Show the mean, median and standard deviation of PM2.5 per state in 2024 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7137,List states ranked by PM2.5 concentration relative to their area in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, { 'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM2.5 per km²', 'numerator': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)', 'PM2.5 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7138,Show the monthly average PM2.5 for Dhule in 2024 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Dhule') & (data['Timestamp'].dt.year == 2024)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Dhule 2024', width=450, height=280) " 7139,"In 2018, which season (Winter, Summer, Monsoon, Post-Monsoon) experienced the second-lowest median PM10 concentrations?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'season'}}] " 7140,"Identify the state with the second-lowest PM2.5 concentrations on August 15, 2022."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 7141,"Compare the monthly average PM2.5 of Yamuna Nagar, Visakhapatnam, and Mangalore in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Yamuna Nagar', 'Visakhapatnam', 'Mangalore'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Yamuna Nagar vs Visakhapatnam vs Mangalore – 2018', width=550, height=320) return chart " 7142,"Visualize the monthly average PM10 for Karnataka, Jharkhand, and West Bengal in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Karnataka', 'Jharkhand', 'West Bengal'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Karnataka, Jharkhand, UP – 2019', width=550, height=320) return chart " 7143,Identify the city with the 3rd highest average PM2.5 for May 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 7144,Which 5 citys recorded the highest average PM10 levels in 2021? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 7145,Plot the weekly average PM2.5 for Amaravati in 2017 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Amaravati') & (data['Timestamp'].dt.year == 2017)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Amaravati 2017', width=600, height=300) return chart " 7146,Plot the weekly average PM2.5 for Khanna in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Khanna') & (data['Timestamp'].dt.year == 2020)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Khanna 2020', width=600, height=300) return chart " 7147,Which city had the lowest 25th percentile of PM10 in August 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 7148,Show the monthly average PM2.5 for Palkalaiperur in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Palkalaiperur') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Palkalaiperur 2020', width=450, height=280) " 7149,"Taking all years into account, which September was associated with the third-highest average PM10 levels?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'Timestamp'}}] " 7150,Create a table of state PM2.5 levels and geographic area for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7151,"Which state with a land area greater than 50,000 km² shows the maximum PM10 level, according to its variance of PM10 level?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'var', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}] " 7152,What is the median PM10 level on Thursdays in Karauli?," [{'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karauli'}}] " 7153,Show the monthly average PM10 trend for Salem from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Salem'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Salem (2017–2022)', width=600, height=300) return chart " 7154,How many times did Uttar Pradesh surpass 45 µg/m³ of PM10 in 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 45.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 7155,Tabulate both PM2.5 and PM10 averages by state for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7156,Generate a year-by-year summary table of PM2.5 readings for Kolkata.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Kolkata'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7157,"Show the top 10 states by average PM10 in 2017 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2017] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(10, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 10 States by Average PM10 in 2017', width=500, height=300) return chart " 7158,Show annual average PM2.5 for Raipur as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Raipur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7159,Which station had the highest 75th percentile of PM10 in October 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 7160,Show the monthly average PM2.5 for Raichur in 2022 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Raichur') & (data['Timestamp'].dt.year == 2022)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Raichur 2022', width=450, height=280) " 7161,Determine the station exhibiting the most minimal median PM10 over the Summer season of 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 7162,Tabulate the 15 worst states for average PM2.5 in 2022 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 7163,Create a table showing PM10 spread (min to max) and central tendency per city for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7164,"On January 27, 2019, which city documented the third highest PM10 level?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 7165,Generate a year-by-year summary table of PM10 readings for Bihar.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Bihar'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7166,"Create a grouped bar chart comparing the average PM2.5 for Odisha, Sikkim, and Bihar across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Odisha', 'Sikkim', 'Bihar'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 7167,Show a box plot of PM2.5 distribution for each state in 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2023].dropna(subset=['PM2.5']) df = df[['state','PM2.5']] state_order = df.groupby('state')['PM2.5'].median().sort_values(ascending=False).index.tolist() chart = alt.Chart(df).mark_boxplot(extent='min-max').encode( x=alt.X('PM2\.5:Q', title='PM2.5 (µg/m³)'), y=alt.Y('state:N', sort=state_order, title='State'), color=alt.Color('state:N', legend=None) ).properties(title='PM2.5 Distribution by State – 2023', width=500, height=450) return chart " 7168,"Tabulate PM10 statistics (mean, std, min, max) for each city in 2018."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7169,Which 20 states recorded the highest average PM2.5 levels in 2020? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 7170,Show how many times PM10 exceeded 150 µg/m³ per day across states in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7171,"Visualize the monthly average PM10 for Tripura, Meghalaya, and Kerala in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tripura', 'Meghalaya', 'Kerala'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Tripura, Meghalaya, UP – 2022', width=550, height=320) return chart " 7172,"Visualize the monthly average PM10 for Bihar, Andhra Pradesh, and Punjab in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Bihar', 'Andhra Pradesh', 'Punjab'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Bihar, Andhra Pradesh, UP – 2024', width=550, height=320) return chart " 7173,"Create a grouped bar chart comparing the average PM2.5 for Puducherry, West Bengal, and Andhra Pradesh across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'West Bengal', 'Andhra Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 7174,Show the monthly average PM10 trend for Surat from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Surat'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Surat (2019–2024)', width=600, height=300) return chart " 7175,Plot the weekly average PM2.5 for Kota in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Kota') & (data['Timestamp'].dt.year == 2024)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Kota 2024', width=600, height=300) return chart " 7176,Report the state that had the 2nd highest average PM10 in March 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 7177,"Visualize the monthly average PM10 for Manipur, Odisha, and Uttarakhand in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Manipur', 'Odisha', 'Uttarakhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Manipur, Odisha, UP – 2024', width=550, height=320) return chart " 7178,Which 5 states recorded the highest average PM10 levels in 2020? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 7179,Generate a city × month cross-tab of mean PM10 for Tamil Nadu in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Chennai', 'Gummidipoondi', 'Thoothukudi']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7180,Show a year-wise table of average PM2.5 for Agra from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Agra'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7181,List average PM2.5 by month for Ahmedabad in 2020 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Ahmedabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7182,Which city registered the peak 75th percentile of PM10 in the Summer season of 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 7183,Show the monthly average PM10 trend for Nandesari from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Nandesari'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Nandesari (2017–2022)', width=600, height=300) return chart " 7184,"Visualize the monthly average PM10 for Kerala, Chandigarh, and Tripura in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Kerala', 'Chandigarh', 'Tripura'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Kerala, Chandigarh, UP – 2019', width=550, height=320) return chart " 7185,"In October 2021, identify the station with the lowest median PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 7186,"Scatter plot PM2.5 vs PM10 for Uttar Pradesh stations in 2020, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Uttar Pradesh') & (data['Timestamp'].dt.year == 2020)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Uttar Pradesh Stations 2020', width=450, height=350) " 7187,Identify the city that recorded the 2nd highest 25th percentile of PM10 value in July 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 7188,Show the monthly average PM2.5 for Patna in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Patna') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Patna 2020', width=450, height=280) " 7189,Plot the top 12 states by average PM2.5 in 2018 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2018] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(12, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 12 States by Average PM2.5 in 2018', width=500, height=300) return chart " 7190,Show the monthly average PM2.5 for Vijayapura in 2023 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Vijayapura') & (data['Timestamp'].dt.year == 2023)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Vijayapura 2023', width=450, height=280) " 7191,During which financial year was the total NCAP funding release the 3rd smallest among cities?," [] " 7192,"Visualize the monthly average PM10 for Chhattisgarh, Telangana, and Telangana in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chhattisgarh', 'Telangana', 'Telangana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Chhattisgarh, Telangana, UP – 2024', width=550, height=320) return chart " 7193,Tabulate the monthly mean PM2.5 levels for Kerala during 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Kerala'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7194,Which city had the 2nd lowest median PM2.5 in June 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 7195,Show a bar chart of the top 9 cities by median PM2.5 in 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2024] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(9, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 9 Cities by Median PM2.5 in 2024', width=500, height=300) return chart " 7196,"Create a grouped bar chart comparing the average PM2.5 for Mizoram, Jammu and Kashmir, and Meghalaya across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Mizoram', 'Jammu and Kashmir', 'Meghalaya'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 7197,Plot the distribution of PM2.5 values in Haryana across all years using a histogram.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Haryana'].dropna(subset=['PM2.5']) df = df[['PM2.5']] chart = alt.Chart(df).mark_bar(color='steelblue', opacity=0.75).encode( x=alt.X('PM2\.5:Q', bin=alt.Bin(maxbins=40), title='PM2.5 (µg/m³)'), y=alt.Y('count()', title='Number of Observations'), tooltip=[alt.Tooltip('PM2\.5:Q', bin=True), 'count()'] ).properties(title='PM2.5 Distribution – Haryana (All Years)', width=500, height=300) return chart " 7198,Identify the state that saw the least significant fall in median PM2.5 levels when comparing December 2018 to October 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 7199,"Plot the yearly average PM2.5 trends for Jammu and Kashmir, Sikkim, and Rajasthan from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jammu and Kashmir', 'Sikkim', 'Rajasthan'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Jammu and Kashmir vs Sikkim vs Rajasthan', width=550, height=320) return chart " 7200,"Show descriptive statistics of PM10 (mean, median, std, min, max) per state in 2019."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7201,Show the monthly average PM10 trend for Khanna from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Khanna'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Khanna (2017–2022)', width=600, height=300) return chart " 7202,Show how average PM10 varied month by month for Assam in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Assam'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7203,"Visualize the monthly average PM10 for Punjab, Uttarakhand, and Assam in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Punjab', 'Uttarakhand', 'Assam'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Punjab, Uttarakhand, UP – 2022', width=550, height=320) return chart " 7204,Determine the city exhibiting the highest average PM2.5 in January 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 7205,Tabulate days with PM2.5 > 100 µg/m³ and exceedance percentage per city in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7206,Show the monthly average PM10 trend for Sivasagar from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Sivasagar'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Sivasagar (2017–2022)', width=600, height=300) return chart " 7207,List the top 10 states by PM2.5 in 2024 with both PM2.5 and PM10 averages.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 7208,Tabulate the monthly mean PM2.5 levels for Uttar Pradesh during 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7209,Which city recorded the 2nd highest median PM2.5 in the Summer season of 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 7210,Show how average PM10 varied month by month for Chennai in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Chennai'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7211,"Scatter plot PM2.5 vs PM10 for Puducherry stations in 2020, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Puducherry') & (data['Timestamp'].dt.year == 2020)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Puducherry Stations 2020', width=450, height=350) " 7212,Generate a city × month cross-tab of mean PM2.5 for Karnataka in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Bagalkot', 'Belgaum', 'Bengaluru', 'Chamarajanagar', 'Chikkaballapur', 'Chikkamagaluru', 'Davanagere', 'Dharwad', 'Gadag', 'Hassan', 'Haveri', 'Hubballi', 'Kalaburagi', 'Koppal', 'Madikeri', 'Mangalore', 'Mysuru', 'Raichur', 'Ramanagara', 'Shivamogga', 'Tumakuru', 'Vijayapura', 'Yadgir']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7213,"Compare the monthly average PM2.5 of Bhilwara, Kunjemura, and Bhiwadi in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Bhilwara', 'Kunjemura', 'Bhiwadi'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Bhilwara vs Kunjemura vs Bhiwadi – 2024', width=550, height=320) return chart " 7214,Plot the weekly average PM2.5 for Madikeri in 2021 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Madikeri') & (data['Timestamp'].dt.year == 2021)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Madikeri 2021', width=600, height=300) return chart " 7215,"Visualize the monthly average PM10 for Bihar, Karnataka, and Gujarat in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Bihar', 'Karnataka', 'Gujarat'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Bihar, Karnataka, UP – 2021', width=550, height=320) return chart " 7216,Plot the rolling 30-day average PM2.5 for Jammu and Kashmir in 2017 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Jammu and Kashmir') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Jammu and Kashmir 2017', width=600, height=300) " 7217,"Show the top 15 states by average PM10 in 2020 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2020] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(15, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 15 States by Average PM10 in 2020', width=500, height=300) return chart " 7218,Show a cumulative area chart of PM2.5 readings for Hyderabad across 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Hyderabad') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Hyderabad 2023', width=600, height=300) return chart " 7219,Identify the station that saw the second least significant fall in median PM2.5 levels when comparing December 2023 to October 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 7220,Generate a descriptive stats table for PM10 grouped by city in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7221,Show PM2.5 exceedance count and rate (%) above 100 µg/m³ per state in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7222,Tabulate average PM2.5 for each city in Odisha across all months of 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Odisha'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Brajrajnagar', 'Talcher']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7223,Create a month-wise summary of average PM2.5 for Ahmedabad in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Ahmedabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7224,Which city showed the 3rd highest 75th percentile of PM10 in May 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 7225,"On March 31, 2024, which station had the second-lowest 25th percentile for PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 7226,Show the monthly average PM2.5 for Nagaon in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Nagaon') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Nagaon 2018', width=450, height=280) " 7227,"Scatter plot PM2.5 vs PM10 for Meghalaya stations in 2020, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Meghalaya') & (data['Timestamp'].dt.year == 2020)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Meghalaya Stations 2020', width=450, height=350) " 7228,Identify the station exhibiting the third most minimal median PM10 during the Monsoon season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 7229,Find the city with the third-lowest mean PM10 concentration in May 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 7230,Create a table of PM2.5 standard violations (>100 µg/m³) per state in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7231,Report which station possessed the third lowest 25th percentile of PM2.5 throughout the Monsoon season of 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 7232,"Identify the season in 2022 (Winter, Summer, Monsoon, Post-Monsoon) that registered the highest average PM2.5 levels."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'season'}}] " 7233,Report the state with the highest median PM2.5 in July 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 7234,Show a monthly bar chart of the number of days Haryana exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2017.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Haryana') & (data['Timestamp'].dt.year == 2017)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Haryana Exceeded WHO PM2.5 Guideline per Month – 2017', width=500, height=300) return chart " 7235,List the bottom 5 states with the lowest average PM10 in 2021 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 7236,Which city displayed the 3rd highest 25th percentile of PM10 in August 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 7237,Show a year-wise table of average PM2.5 for Jaipur from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Jaipur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7238,"Compare the monthly average PM2.5 of Ahmedabad, Jaisalmer, and Patna in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Ahmedabad', 'Jaisalmer', 'Patna'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Ahmedabad vs Jaisalmer vs Patna – 2019', width=550, height=320) return chart " 7239,"In October 2022, identify the station with the 2nd lowest median PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 7240,How many times did Bihar surpass 90 µg/m³ of PM10 in the year 2017?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 90.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 7241,Determine which state exhibits the 4th highest 75th percentile of PM10 concentration normalized by population density.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_capita', 'numerator': 'PM10', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'pm_per_capita', 'ascending': False}}] " 7242,"Show the top 8 states by average PM10 in 2024 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2024] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(8, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 8 States by Average PM10 in 2024', width=500, height=300) return chart " 7243,"On August 15, 2021, which city registered the second-lowest PM10 concentrations?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 7244,Generate a city × month cross-tab of mean PM10 for Bihar in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Bihar'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Araria', 'Arrah', 'Aurangabad', 'Bettiah', 'Bhagalpur', 'Bihar Sharif', 'Chhapra', 'Gaya', 'Hajipur', 'Katihar', 'Kishanganj', 'Manguraha', 'Motihari', 'Munger', 'Muzaffarpur', 'Patna', 'Purnia', 'Rajgir', 'Saharsa', 'Samastipur', 'Sasaram', 'Siwan']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7245,List the average PM2.5 for Tripura broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tripura'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7246,Tabulate average PM2.5 for each city in Bihar across all months of 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Bihar'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Gaya', 'Muzaffarpur', 'Patna']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7247,"Create a scatter plot of PM2.5 vs PM10 for all stations in 2022, colored by state."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2022] df = df.groupby(['station','state'])[['PM2.5','PM10']].mean().reset_index().dropna() chart = alt.Chart(df).mark_point(opacity=0.6, size=60).encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['station:N','state:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='PM2.5 vs PM10 by Station – 2022', width=500, height=400) return chart " 7248,Create a month-wise PM10 breakdown table across cities in Uttar Pradesh for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Agra', 'Baghpat', 'Bareilly', 'Bulandshahr', 'Firozabad', 'Ghaziabad', 'Gorakhpur', 'Greater Noida', 'Hapur', 'Jhansi', 'Kanpur', 'Khurja', 'Lucknow', 'Meerut', 'Moradabad', 'Muzaffarnagar', 'Noida', 'Prayagraj', 'Varanasi', 'Vrindavan']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7249,Visualize the bottom 15 states with the lowest average PM2.5 in 2018 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2018] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(15, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 15 States by Average PM2.5 in 2018', width=500, height=300) return chart " 7250,"Compare the monthly average PM2.5 of Virudhunagar, Visakhapatnam, and Virudhunagar in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Virudhunagar', 'Visakhapatnam', 'Virudhunagar'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Virudhunagar vs Visakhapatnam vs Virudhunagar – 2019', width=550, height=320) return chart " 7251,Show the monthly average PM2.5 for Angul in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Angul') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Angul 2017', width=450, height=280) " 7252,Plot the weekly average PM2.5 for Chikkamagaluru in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Chikkamagaluru') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Chikkamagaluru 2023', width=600, height=300) return chart " 7253,"Compare the monthly average PM2.5 of Ratlam, Amritsar, and Nagaur in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Ratlam', 'Amritsar', 'Nagaur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Ratlam vs Amritsar vs Nagaur – 2022', width=550, height=320) return chart " 7254,Show a monthly bar chart of the number of days Andhra Pradesh exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Andhra Pradesh') & (data['Timestamp'].dt.year == 2024)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Andhra Pradesh Exceeded WHO PM2.5 Guideline per Month – 2024', width=500, height=300) return chart " 7255,Tabulate the top 20 citys for PM2.5 in 2019 along with their corresponding PM10 values.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 7256,Report the city that was granted the 5th highest NCAP funding with respect to its median PM10 concentration in 2020 (FY 2019-20).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2020_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 7257,Plot the weekly average PM2.5 for Bettiah in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bettiah') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Bettiah 2023', width=600, height=300) return chart " 7258,Determine the city exhibiting the highest 75th percentile of PM10 in November 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 7259,Show a heatmap of average PM2.5 for the top 5 most polluted states by month for 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(5).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 5 Polluted States by Month (2022)', width=500, height=300) return chart " 7260,"Create a grouped bar chart comparing the average PM2.5 for Haryana, Manipur, and Madhya Pradesh across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Manipur', 'Madhya Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 7261,Which 10 citys had the lowest mean PM2.5 in 2020? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 7262,Which state experienced the 3rd highest median for PM10 in the Summer season of 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 7263,Show a bar chart of the top 6 cities by median PM2.5 in 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2018] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(6, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 6 Cities by Median PM2.5 in 2018', width=500, height=300) return chart " 7264,Show the monthly average PM2.5 for Udaipur in 2022 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Udaipur') & (data['Timestamp'].dt.year == 2022)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Udaipur 2022', width=450, height=280) " 7265,"Which union territory possesses the 2nd smallest land area among the top 2 most polluted union territories, based on the 75th percentile of PM2.5 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 2, 'ret': 'state'}}] " 7266,Which station displayed the lowest 25th percentile of PM2.5 in April 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 7267,Which state had the 2nd lowest 75th percentile of PM10 in July 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 7268,"Visualize the monthly average PM10 for Odisha, Karnataka, and Mizoram in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Odisha', 'Karnataka', 'Mizoram'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Odisha, Karnataka, UP – 2023', width=550, height=320) return chart " 7269,"In February 2024, report the station with the 2nd highest 75th percentile of PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 7270,Determine which state exhibits the 2nd lowest variance of PM10 concentration normalized by population density.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'var', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_capita', 'numerator': 'PM10', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'pm_per_capita', 'ascending': True}}] " 7271,"On March 31, 2024, which state recorded the highest 25th percentile for PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 7272,Generate a year-by-year summary table of PM10 readings for Tamil Nadu.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7273,"Within the last four years in Coimbatore, on what date was the PM2.5 level the second lowest?"," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 4}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'Timestamp'}}] " 7274,"Across all recorded years, which March showed the third-lowest average PM2.5 concentration?"," [{'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'Timestamp'}}] " 7275,Generate a dual-pollutant summary table (PM2.5 and PM10) by city for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7276,Show a heatmap of average PM2.5 for the top 15 most polluted states by month for 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(15).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 15 Polluted States by Month (2024)', width=500, height=300) return chart " 7277,Determine the city that ranked second for the highest median PM2.5 in April 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 7278,Tabulate the 20 worst citys for average PM10 in 2021 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 7279,Show a cumulative area chart of PM2.5 readings for Davanagere across 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Davanagere') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Davanagere 2021', width=600, height=300) return chart " 7280,Show PM2.5 exceedance count and rate (%) above 100 µg/m³ per city in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7281,Which state recorded the peak median PM2.5 in the Post-Monsoon season of 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 7282,Report the city with the 3rd highest 25th percentile of PM2.5 in March 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 7283,Which state recorded the 3rd lowest median PM10 in the Post-Monsoon season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 7284,List the average PM10 for Guwahati broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Guwahati'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7285,Show the monthly average PM10 trend for Mumbai from 2018 to 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Mumbai'].copy() df = df[(df['Timestamp'].dt.year >= 2018) & (df['Timestamp'].dt.year <= 2023)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Mumbai (2018–2023)', width=600, height=300) return chart " 7286,Generate a table showing the 15 most polluted states based on mean PM2.5 for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 7287,Show a ranked table of the 15 most polluted citys by average PM2.5 in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 7288,Which state recorded the 2nd highest 75th percentile of PM10 in July 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 7289,Tabulate the monthly mean PM2.5 levels for Indore during 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Indore'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7290,"Plot the yearly average PM2.5 trends for Madhya Pradesh, Haryana, and Himachal Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Madhya Pradesh', 'Haryana', 'Himachal Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Madhya Pradesh vs Haryana vs Himachal Pradesh', width=550, height=320) return chart " 7291,Identify the state with the 3rd highest 25th percentile of PM2.5 in August 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 7292,"Create a grouped bar chart comparing the average PM2.5 for Jharkhand, Andhra Pradesh, and Jharkhand across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Andhra Pradesh', 'Jharkhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 7293,"Visualize the monthly average PM10 for Rajasthan, Arunachal Pradesh, and Assam in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Rajasthan', 'Arunachal Pradesh', 'Assam'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Rajasthan, Arunachal Pradesh, UP – 2023', width=550, height=320) return chart " 7294,Which 5 citys recorded the highest average PM10 levels in 2018? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 7295,Which state registered the lowest 75th percentile of PM2.5 during February 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 7296,"In Hosur, which date in the previous four years registered the third-highest PM2.5 concentration?"," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 4}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'Timestamp'}}] " 7297,List the top 20 states by PM2.5 in 2019 with both PM2.5 and PM10 averages.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 7298,Show a monthly breakdown table of average PM2.5 for Bhilai in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Bhilai'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7299,Create a summary table comparing mean PM2.5 and PM10 across citys in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7300,Show a monthly bar chart of the number of days Puducherry exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Puducherry') & (data['Timestamp'].dt.year == 2023)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Puducherry Exceeded WHO PM2.5 Guideline per Month – 2023', width=500, height=300) return chart " 7301,"Show the mean, median and standard deviation of PM2.5 per city in 2019 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7302,Show the monthly average PM2.5 for Vatva in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Vatva') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Vatva 2020', width=450, height=280) " 7303,Which station had the 3rd lowest median PM10 in September 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 7304,Tabulate area-adjusted PM10 (per km²) for each state in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM10 per km²', 'numerator': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)', 'PM10 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7305,"Identify the season in 2020 (Winter, Summer, Monsoon, Post-Monsoon) that registered the highest 25th percentile of PM2.5 levels."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'season'}}] " 7306,Create a table of PM10 standard violations (>100 µg/m³) per city in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7307,Show a cumulative area chart of PM2.5 readings for Yadgir across 2019.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Yadgir') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Yadgir 2019', width=600, height=300) return chart " 7308,Create a statistical summary table of PM10 readings by state for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7309,"Compare the monthly average PM2.5 of Vijayapura, Angul, and Thanjavur in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Vijayapura', 'Angul', 'Thanjavur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Vijayapura vs Angul vs Thanjavur – 2022', width=550, height=320) return chart " 7310,Show the monthly average PM10 trend for Ambala from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Ambala'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Ambala (2019–2024)', width=600, height=300) return chart " 7311,Plot the weekly average PM2.5 for Hubballi in 2021 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Hubballi') & (data['Timestamp'].dt.year == 2021)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Hubballi 2021', width=600, height=300) return chart " 7312,Report the city with the highest 75th percentile of PM2.5 in October 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 7313,Which state possessed the 2nd lowest median for PM10 in the Summer season of 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 7314,Report the city with the 4th highest NCAP funding relative to the standard deviation of its PM10 concentration in 2020 (FY 2019-20).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'std', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2020_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 7315,Which state possessed the 3rd highest average for PM10 in the Winter season of 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 7316,"Compare the monthly average PM2.5 of Srinagar, Muzaffarpur, and Pimpri-Chinchwad in 2020 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Srinagar', 'Muzaffarpur', 'Pimpri-Chinchwad'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2020)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Srinagar vs Muzaffarpur vs Pimpri-Chinchwad – 2020', width=550, height=320) return chart " 7317,Plot the weekly average PM2.5 for Chennai in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Chennai') & (data['Timestamp'].dt.year == 2020)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Chennai 2020', width=600, height=300) return chart " 7318,Show a year-wise table of average PM10 for Guwahati from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Guwahati'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7319,Show the monthly average PM2.5 for Pune in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Pune') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Pune 2018', width=450, height=280) " 7320,Generate a city × month cross-tab of mean PM10 for Tamil Nadu in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Ariyalur', 'Chengalpattu', 'Chennai', 'Cuddalore', 'Gummidipoondi', 'Ooty', 'Palkalaiperur', 'Ramanathapuram', 'Thoothukudi', 'Tirupur', 'Vellore', 'Virudhunagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7321,Tabulate days with PM10 > 100 µg/m³ and exceedance percentage per city in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7322,Show a cumulative area chart of PM2.5 readings for Bengaluru across 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bengaluru') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Bengaluru 2021', width=600, height=300) return chart " 7323,Which 15 states had the lowest mean PM2.5 in 2023? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 7324,"Compare the monthly average PM2.5 of Sirohi, Talcher, and Manguraha in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Sirohi', 'Talcher', 'Manguraha'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Sirohi vs Talcher vs Manguraha – 2024', width=550, height=320) return chart " 7325,Show a heatmap of average PM2.5 for the top 15 most polluted states by month for 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(15).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 15 Polluted States by Month (2018)', width=500, height=300) return chart " 7326,Which station had the third-lowest average PM2.5 in December 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 7327,Show annual average PM10 for Mizoram as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Mizoram'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7328,"Create a grouped bar chart comparing the average PM2.5 for Meghalaya, Karnataka, and Karnataka across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Meghalaya', 'Karnataka', 'Karnataka'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 7329,"Plot the yearly average PM2.5 trends for Jammu and Kashmir, Delhi, and Madhya Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jammu and Kashmir', 'Delhi', 'Madhya Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Jammu and Kashmir vs Delhi vs Madhya Pradesh', width=550, height=320) return chart " 7330,"Visualize the monthly average PM10 for West Bengal, Arunachal Pradesh, and Kerala in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['West Bengal', 'Arunachal Pradesh', 'Kerala'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: West Bengal, Arunachal Pradesh, UP – 2019', width=550, height=320) return chart " 7331,Report the state with the lowest 25th percentile of PM2.5 in August 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 7332,Determine the station with the 3rd lowest average PM10 in May 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 7333,"For the year 2022, which week had the third-highest 25th percentile for PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'week'}}] " 7334,"Visualize the monthly average PM10 for Tripura, Jammu and Kashmir, and Assam in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tripura', 'Jammu and Kashmir', 'Assam'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Tripura, Jammu and Kashmir, UP – 2024', width=550, height=320) return chart " 7335,"Visualize the monthly average PM10 for Karnataka, Jharkhand, and Uttar Pradesh in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Karnataka', 'Jharkhand', 'Uttar Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Karnataka, Jharkhand, UP – 2017', width=550, height=320) return chart " 7336,Create a table with mean and standard deviation of PM2.5 by city in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7337,"In 2018, which week of the year corresponded to the third-lowest 75th percentile for PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'week'}}] " 7338,Tabulate the 5 states with the least PM2.5 pollution in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 7339,Show a year-wise table of average PM10 for Bihar from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Bihar'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7340,Show a pivot table of monthly average PM2.5 by city for Maharashtra in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Kalyan', 'Mumbai', 'Nagpur', 'Nashik', 'Navi Mumbai', 'Pune', 'Solapur']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7341,List states with their PM10 violation count and rate (>100 µg/m³) in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7342,Show the monthly average PM2.5 for Andhra Pradesh across each year from 2017 to 2024 as small multiples (faceted by year).," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Andhra Pradesh'].copy() df['Year'] = df['Timestamp'].dt.year df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5'), tooltip=['Year:O','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet( facet=alt.Facet('Year:O', title='Year'), columns=4 ).properties(title='Monthly PM2.5 in Andhra Pradesh by Year (2017–2024)') return chart " 7343,How many times did Haryana go above 90 µg/m³ of PM10 in the year 2017?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 90.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 7344,Show how average PM2.5 varied month by month for Pune in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Pune'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7345,Create a table of state PM10 levels and geographic area for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7346,Determine the station that recorded the third most minimal PM2.5 level on 27 January 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 7347,"Create a table showing top 15 citys ranked by PM2.5 in 2019, also showing PM10."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 7348,"Scatter plot PM2.5 vs PM10 for Telangana stations in 2023, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Telangana') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Telangana Stations 2023', width=450, height=350) " 7349,Show a bar chart of the top 7 cities by median PM2.5 in 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2018] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(7, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 7 Cities by Median PM2.5 in 2018', width=500, height=300) return chart " 7350,Create a month-wise PM2.5 breakdown table across cities in Madhya Pradesh for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Bhopal', 'Damoh', 'Dewas', 'Gwalior', 'Indore', 'Jabalpur', 'Katni', 'Maihar', 'Mandideep', 'Pithampur', 'Ratlam', 'Sagar', 'Satna', 'Singrauli', 'Ujjain']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7351,Show the monthly average PM2.5 for Cuttack in 2024 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Cuttack') & (data['Timestamp'].dt.year == 2024)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Cuttack 2024', width=450, height=280) " 7352,Plot the weekly average PM2.5 for Chandrapur in 2019 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Chandrapur') & (data['Timestamp'].dt.year == 2019)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Chandrapur 2019', width=600, height=300) return chart " 7353,Show PM10 density (µg/m³ per km²) by state for 2022 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM10 per km²', 'numerator': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)', 'PM10 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7354,Determine the state exhibiting the 2nd highest average PM10 in December 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 7355,Generate a city × month cross-tab of mean PM10 for Andhra Pradesh in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Amaravati', 'Anantapur', 'Chittoor', 'Kadapa', 'Rajamahendravaram', 'Tirupati', 'Vijayawada', 'Visakhapatnam']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7356,Show a bar chart comparing the 75th percentile PM2.5 of all states in winter 2021 (November–February).," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.month.isin([11,12,1,2])] df = df[df['Timestamp'].dt.year.isin([2021,2022])] df = df.groupby('state')['PM2.5'].quantile(0.75).reset_index().dropna() df.columns = ['state','PM2.5_p75'] df = df.sort_values('PM2.5_p75', ascending=False) chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5_p75:Q', title='75th Percentile PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5_p75:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5_p75:Q', format='.1f', title='P75 PM2.5')] ).properties(title='75th Percentile PM2.5 by State – Winter 2021', width=500, height=400) return chart " 7357,"Compare the monthly average PM2.5 of Manguraha, Bathinda, and Ujjain in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Manguraha', 'Bathinda', 'Ujjain'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Manguraha vs Bathinda vs Ujjain – 2019', width=550, height=320) return chart " 7358,"Plot the yearly average PM2.5 trends for Manipur, West Bengal, and Assam from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Manipur', 'West Bengal', 'Assam'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Manipur vs West Bengal vs Assam', width=550, height=320) return chart " 7359,Show the monthly average PM2.5 for Araria in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Araria') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Araria 2019', width=450, height=280) " 7360,"Tabulate the distribution of PM10 per city in 2024 including mean, median, and std."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'q25', 'median', 'q75']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7361,Show a table of the top 20 states by average PM2.5 in 2018 including their PM10 levels too.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 7362,Which 15 states had the lowest mean PM2.5 in 2019? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 7363,How many times did Barmer city surpass 90 µg/m³ of PM10 in 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 90.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 7364,Create a table showing PM2.5 spread (min to max) and central tendency per city for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7365,Show the monthly average PM2.5 for Brajrajnagar in 2024 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Brajrajnagar') & (data['Timestamp'].dt.year == 2024)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Brajrajnagar 2024', width=450, height=280) " 7366,Which city registered the 3rd highest 75th percentile of PM2.5 during September 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 7367,Show a heatmap of average PM2.5 for the top 12 most polluted states by month for 2017.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(12).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 12 Polluted States by Month (2017)', width=500, height=300) return chart " 7368,Which station showed the third-lowest 25th percentile for PM2.5 in April 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 7369,Show the monthly average PM2.5 for Howrah in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Howrah') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Howrah 2019', width=450, height=280) " 7370,Show a pivot table of monthly average PM10 by city for Bihar in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Bihar'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Araria', 'Arrah', 'Aurangabad', 'Bettiah', 'Bhagalpur', 'Bihar Sharif', 'Chhapra', 'Gaya', 'Hajipur', 'Katihar', 'Kishanganj', 'Manguraha', 'Motihari', 'Munger', 'Muzaffarpur', 'Patna', 'Purnia', 'Rajgir', 'Saharsa', 'Samastipur', 'Sasaram', 'Siwan']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7371,"Show the top 15 states by average PM10 in 2024 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2024] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(15, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 15 States by Average PM10 in 2024', width=500, height=300) return chart " 7372,Which station had the 2nd highest 25th percentile of PM2.5 in October 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 7373,Show a pivot table of monthly average PM10 by city for Assam in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Assam'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Guwahati']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7374,"Plot the yearly average PM2.5 trends for Telangana, Tripura, and Gujarat from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Telangana', 'Tripura', 'Gujarat'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Telangana vs Tripura vs Gujarat', width=550, height=320) return chart " 7375,"Which state having a land area less than 50,000 km² registers the 2nd minimum PM10 level, based on its 25th percentile PM10 level?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}] " 7376,"Create a grouped bar chart comparing the average PM2.5 for Tripura, Jammu and Kashmir, and West Bengal across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tripura', 'Jammu and Kashmir', 'West Bengal'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 7377,Create a table showing annual mean PM2.5 levels for Telangana (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Telangana'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7378,"Create a grouped bar chart comparing the average PM2.5 for Nagaland, Kerala, and Chhattisgarh across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Nagaland', 'Kerala', 'Chhattisgarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 7379,Which state registered the peak average PM10 in the Monsoon season of 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 7380,Which state recorded the 3rd lowest 25th percentile of PM10 in July 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 7381,Plot the weekly average PM2.5 for Amritsar in 2019 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Amritsar') & (data['Timestamp'].dt.year == 2019)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Amritsar 2019', width=600, height=300) return chart " 7382,Which state received the lowest NCAP funding relative to the standard deviation of its PM2.5 concentration in 2021 (FY 2020-21)?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'std', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 7383,List states with their PM10 violation count and rate (>150 µg/m³) in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 150'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7384,Determine the state that recorded the maximum PM2.5 level on 27 January 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 7385,"Create a grouped bar chart comparing the average PM2.5 for Chandigarh, Arunachal Pradesh, and Punjab across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chandigarh', 'Arunachal Pradesh', 'Punjab'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 7386,"Visualize the monthly average PM10 for Jammu and Kashmir, Nagaland, and West Bengal in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jammu and Kashmir', 'Nagaland', 'West Bengal'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Jammu and Kashmir, Nagaland, UP – 2022', width=550, height=320) return chart " 7387,Which city had the 3rd lowest 25th percentile of PM2.5 in November 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 7388,"For 2018, identify the season (Winter, Summer, Monsoon, Post-Monsoon) with the second-highest median PM2.5 levels."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'season'}}] " 7389,Report which state possessed the 2nd highest 25th percentile of PM2.5 throughout the Winter season of 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 7390,"Create a grouped bar chart comparing the average PM2.5 for Tamil Nadu, Sikkim, and Manipur across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Sikkim', 'Manipur'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 7391,Identify the state with the 5th highest standard deviation of PM10 concentration in relation to its population density.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'std', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_capita', 'numerator': 'PM10', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'pm_per_capita', 'ascending': False}}] " 7392,List the bottom 5 citys with the lowest average PM10 in 2024 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 7393,Create a table showing PM10 spread (min to max) and central tendency per state for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7394,Generate a city × month cross-tab of mean PM2.5 for Uttar Pradesh in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Agra', 'Kanpur', 'Lucknow', 'Varanasi']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7395,"Compare the monthly average PM2.5 of Suakati, Tirupur, and Noida in 2019 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Suakati', 'Tirupur', 'Noida'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2019)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Suakati vs Tirupur vs Noida – 2019', width=550, height=320) return chart " 7396,"Visualize the monthly average PM10 for West Bengal, Delhi, and Mizoram in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['West Bengal', 'Delhi', 'Mizoram'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: West Bengal, Delhi, UP – 2023', width=550, height=320) return chart " 7397,"Create a table showing top 20 states ranked by PM2.5 in 2022, also showing PM10."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 7398,What number of Kerala stations went above 30 µg/m³ of PM2.5 in 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 30.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 7399,Which state recorded the 3rd lowest 75th percentile of PM10 during the Summer season of 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 7400,Which station registered the 2nd lowest 75th percentile of PM10 during September 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 7401,Visualize the bottom 12 states with the lowest average PM2.5 in 2018 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2018] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(12, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 12 States by Average PM2.5 in 2018', width=500, height=300) return chart " 7402,Plot a heatmap of average PM10 by state (y-axis) and month (x-axis) for 2017.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2017].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM10'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), title='Avg PM10'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='PM10 Heatmap by State and Month – 2017', width=500, height=400) return chart " 7403,List how many days each state breached the PM10 limit of 150 µg/m³ in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7404,Show the monthly average PM2.5 for Belgaum in 2024 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Belgaum') & (data['Timestamp'].dt.year == 2024)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Belgaum 2024', width=450, height=280) " 7405,"Identify the state with the second-highest median PM2.5 on March 31, 2020."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 7406,Show the monthly average PM2.5 for Alwar in 2023 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Alwar') & (data['Timestamp'].dt.year == 2023)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Alwar 2023', width=450, height=280) " 7407,Identify the city with the 5th highest NCAP funding considering the standard deviation of its PM2.5 concentration in 2020 (FY 2019-20).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'std', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2020_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 7408,Show the monthly average PM2.5 for Vapi in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Vapi') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Vapi 2020', width=450, height=280) " 7409,Show a monthly bar chart of the number of days Uttarakhand exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Uttarakhand') & (data['Timestamp'].dt.year == 2024)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Uttarakhand Exceeded WHO PM2.5 Guideline per Month – 2024', width=500, height=300) return chart " 7410,Tabulate area-adjusted PM2.5 (per km²) for each state in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, { 'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM2.5 per km²', 'numerator': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)', 'PM2.5 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7411,Show the monthly average PM2.5 for Barrackpore in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Barrackpore') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Barrackpore 2019', width=450, height=280) " 7412,"Show a table of average PM10, population, and area for all states in 2018."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7413,Plot the top 13 states by average PM2.5 in 2024 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2024] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(13, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 13 States by Average PM2.5 in 2024', width=500, height=300) return chart " 7414,"Create a grouped bar chart comparing the average PM2.5 for Tamil Nadu, Gujarat, and Chandigarh across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Gujarat', 'Chandigarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 7415,Plot the rolling 30-day average PM2.5 for Sikkim in 2017 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Sikkim') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Sikkim 2017', width=600, height=300) " 7416,"Compare the monthly average PM2.5 of Howrah, Sonipat, and Pune in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Howrah', 'Sonipat', 'Pune'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Howrah vs Sonipat vs Pune – 2023', width=550, height=320) return chart " 7417,Determine the city exhibiting the 2nd highest 75th percentile of PM2.5 over the Winter season of 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 7418,"For the period October to December 2023, which city had the second smallest decrease in 25th percentile PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 7419,Show the monthly average PM10 trend for Maihar from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Maihar'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Maihar (2017–2022)', width=600, height=300) return chart " 7420,Tabulate area-adjusted PM10 (per km²) for each state in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM10 per km²', 'numerator': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)', 'PM10 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7421,Create a table with mean and standard deviation of PM10 by state in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7422,Report the state with the 3rd highest 25th percentile of PM10 in June 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 7423,"Over the past two years in Dehradun, on which date was the PM10 level the third lowest?"," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 2}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'Timestamp'}}] " 7424,"Create a grouped bar chart comparing the average PM2.5 for Madhya Pradesh, Jammu and Kashmir, and Madhya Pradesh across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Madhya Pradesh', 'Jammu and Kashmir', 'Madhya Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 7425,Generate a table showing the 20 most polluted citys based on mean PM2.5 for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 7426,"On March 31, 2022, which city had the second-highest 75th percentile of PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 7427,"Plot the yearly average PM2.5 trends for Gujarat, Tripura, and Telangana from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Gujarat', 'Tripura', 'Telangana'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Gujarat vs Tripura vs Telangana', width=550, height=320) return chart " 7428,List states ranked by PM10 concentration relative to their area in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM10 per km²', 'numerator': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)', 'PM10 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7429,Create a summary table ranking the top 15 states by PM10 concentration in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 7430,"On January 5, 2023, which state recorded the second-highest average PM2.5 reading?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 7431,"Create a grouped bar chart comparing the average PM2.5 for Jammu and Kashmir, Puducherry, and Uttar Pradesh across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jammu and Kashmir', 'Puducherry', 'Uttar Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 7432,"Compare the monthly average PM2.5 of Brajrajnagar, Aurangabad, and Kaithal in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Brajrajnagar', 'Aurangabad', 'Kaithal'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Brajrajnagar vs Aurangabad vs Kaithal – 2018', width=550, height=320) return chart " 7433,Show a cumulative area chart of PM2.5 readings for Vrindavan across 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Vrindavan') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Vrindavan 2024', width=600, height=300) return chart " 7434,"In August 2020, which station exhibited the highest average PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 7435,Which station showed the highest average PM2.5 value in December 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 7436,"Create a grouped bar chart comparing the average PM2.5 for Jharkhand, Madhya Pradesh, and Punjab across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Madhya Pradesh', 'Punjab'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 7437,"In August 2022, identify the state with the 3rd lowest average PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 7438,Which station noted the 2nd minimum 25th percentile of PM2.5 in the Summer season of 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 7439,Show a monthly bar chart of the number of days Rajasthan exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Rajasthan') & (data['Timestamp'].dt.year == 2022)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Rajasthan Exceeded WHO PM2.5 Guideline per Month – 2022', width=500, height=300) return chart " 7440,"Tabulate the distribution of PM2.5 per city in 2021 including mean, median, and std."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7441,Show the number of days each state exceeded a PM2.5 threshold of 100 µg/m³ in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7442,Show the monthly average PM10 trend for Dehradun from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Dehradun'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Dehradun (2019–2024)', width=600, height=300) return chart " 7443,List all states with their average PM10 and population for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7444,Tabulate the monthly mean PM2.5 levels for Telangana during 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Telangana'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7445,Show a pivot table of monthly average PM10 by city for Rajasthan in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Ajmer', 'Alwar', 'Bhiwadi', 'Jaipur', 'Jodhpur', 'Kota', 'Pali', 'Udaipur']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7446,Tabulate the 5 worst citys for average PM10 in 2022 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 7447,Create a table showing annual mean PM2.5 levels for Solapur (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Solapur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7448,Identify the city with the 2nd lowest median PM2.5 in January 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 7449,Plot the rolling 30-day average PM2.5 for Chhattisgarh in 2017 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Chhattisgarh') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Chhattisgarh 2017', width=600, height=300) " 7450,Show annual average PM2.5 for Delhi as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Delhi'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7451,Create a month-wise PM10 breakdown table across cities in Uttar Pradesh for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Agra', 'Baghpat', 'Bareilly', 'Bulandshahr', 'Firozabad', 'Ghaziabad', 'Gorakhpur', 'Greater Noida', 'Hapur', 'Jhansi', 'Kanpur', 'Khurja', 'Lucknow', 'Meerut', 'Moradabad', 'Muzaffarnagar', 'Prayagraj', 'Varanasi', 'Vrindavan']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7452,Create a summary table ranking the top 10 citys by PM2.5 concentration in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 7453,How many stations in Madhya Pradesh went above 45 µg/m³ of PM10 in the year 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 45.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 7454,"Compare the monthly average PM2.5 of Latur, Dehradun, and Vijayawada in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Latur', 'Dehradun', 'Vijayawada'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Latur vs Dehradun vs Vijayawada – 2024', width=550, height=320) return chart " 7455,Show a ranked table of the 20 most polluted states by average PM2.5 in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 7456,"Which city had the second-highest average PM10 reading on January 5, 2022?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 7457,Tabulate the 15 citys with the least PM10 pollution in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 7458,Which state had the highest average PM10 in September 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 7459,"Compare the monthly average PM2.5 of Raichur, Virudhunagar, and Chamarajanagar in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Raichur', 'Virudhunagar', 'Chamarajanagar'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Raichur vs Virudhunagar vs Chamarajanagar – 2023', width=550, height=320) return chart " 7460,Plot the rolling 30-day average PM2.5 for Jammu and Kashmir in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Jammu and Kashmir') & (data['Timestamp'].dt.year == 2020)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Jammu and Kashmir 2020', width=600, height=300) " 7461,Tabulate the 10 worst states for average PM10 in 2018 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 7462,Plot the rolling 30-day average PM2.5 for Karnataka in 2017 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Karnataka') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Karnataka 2017', width=600, height=300) " 7463,"Create a grouped bar chart comparing the average PM2.5 for Delhi, Sikkim, and Telangana across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Delhi', 'Sikkim', 'Telangana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 7464,Tabulate the yearly average PM2.5 trend for Nashik across all years.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Nashik'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7465,Which Indian station registered the 3rd minimum PM2.5 levels for a single day in the previous decade?," [{'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'count'}}, {'op': 'SORT', 'params': {'col': 'count', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 7466,"Compare the monthly average PM2.5 of Pune, Rupnagar, and Karauli in 2020 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Pune', 'Rupnagar', 'Karauli'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2020)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Pune vs Rupnagar vs Karauli – 2020', width=550, height=320) return chart " 7467,"Create a faceted bar chart showing top 15 states by average PM2.5 per year for 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year.isin([2020,2021,2022,2023])].copy() df['Year'] = df['Timestamp'].dt.year agg = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() top = agg.groupby('Year').apply(lambda x: x.nlargest(15,'PM2.5')).reset_index(drop=True) chart = alt.Chart(top).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Avg PM2.5'), y=alt.Y('state:N', sort='-x'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet(facet='Year:O', columns=2).properties(title='Top 15 States by PM2.5 per Year') return chart " 7468,"Show the top 5 states by average PM10 in 2020 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2020] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(5, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 5 States by Average PM10 in 2020', width=500, height=300) return chart " 7469,Create a ranked table of the 15 best-performing states by PM10 in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 7470,"Show the top 11 states by average PM10 in 2017 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2017] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(11, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 11 States by Average PM10 in 2017', width=500, height=300) return chart " 7471,Show the monthly average PM2.5 for Udaipur in 2024 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Udaipur') & (data['Timestamp'].dt.year == 2024)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Udaipur 2024', width=450, height=280) " 7472,Show a bar chart of the top 10 cities by median PM2.5 in 2019.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2019] df = df.groupby('city')['PM2.5'].median().reset_index().dropna() df = df.nlargest(10, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Median PM2.5 (µg/m³)'), y=alt.Y('city:N', sort='-x', title='City'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='inferno'), legend=None), tooltip=['city:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 10 Cities by Median PM2.5 in 2019', width=500, height=300) return chart " 7473,Tabulate the 5 worst states for average PM2.5 in 2023 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 7474,"Create a grouped bar chart comparing the average PM2.5 for Nagaland, Tamil Nadu, and West Bengal across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Nagaland', 'Tamil Nadu', 'West Bengal'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 7475,"Plot the yearly average PM2.5 trends for Uttar Pradesh, Gujarat, and Andhra Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttar Pradesh', 'Gujarat', 'Andhra Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Uttar Pradesh vs Gujarat vs Andhra Pradesh', width=550, height=320) return chart " 7476,Report which city possessed the peak average PM10 throughout the Post-Monsoon season of 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 7477,"Visualize the monthly average PM10 for Kerala, Andhra Pradesh, and Arunachal Pradesh in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Kerala', 'Andhra Pradesh', 'Arunachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Kerala, Andhra Pradesh, UP – 2021', width=550, height=320) return chart " 7478,Plot the rolling 30-day average PM2.5 for Puducherry in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Puducherry') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Puducherry 2023', width=600, height=300) " 7479,How many times did Karnataka surpass the Indian guideline for PM2.5 in 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 60.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 7480,Tabulate mean PM10 and land area for each state in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7481,Show a table of the 15 cleanest citys by average PM10 in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 7482,"On January 27, 2020, which station documented the third lowest PM10 level?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 7483,"In October 2019, which state registered the highest 25th percentile of PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 7484,"Create a grouped bar chart comparing the average PM2.5 for Nagaland, Tamil Nadu, and Karnataka across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Nagaland', 'Tamil Nadu', 'Karnataka'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 7485,"Visualize the monthly average PM10 for Chhattisgarh, Odisha, and Assam in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chhattisgarh', 'Odisha', 'Assam'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Chhattisgarh, Odisha, UP – 2021', width=550, height=320) return chart " 7486,Plot a heatmap of average PM10 by state (y-axis) and month (x-axis) for 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2021].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM10'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), title='Avg PM10'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='PM10 Heatmap by State and Month – 2021', width=500, height=400) return chart " 7487,"Create a grouped bar chart comparing the average PM2.5 for Mizoram, Punjab, and Arunachal Pradesh across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Mizoram', 'Punjab', 'Arunachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 7488,"Show the top 12 states by average PM10 in 2018 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2018] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(12, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 12 States by Average PM10 in 2018', width=500, height=300) return chart " 7489,List the average PM2.5 for Chandigarh broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Chandigarh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7490,Show a monthly bar chart of the number of days Mizoram exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Mizoram') & (data['Timestamp'].dt.year == 2023)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Mizoram Exceeded WHO PM2.5 Guideline per Month – 2023', width=500, height=300) return chart " 7491,Show a cumulative area chart of PM2.5 readings for Ballabgarh across 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ballabgarh') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Ballabgarh 2023', width=600, height=300) return chart " 7492,Identify the city with the 3rd lowest NCAP funding considering its 75th percentile of PM2.5 concentration in 2022 (FY 2021-22).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2022_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 7493,"Scatter plot PM2.5 vs PM10 for Jammu and Kashmir stations in 2021, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Jammu and Kashmir') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Jammu and Kashmir Stations 2021', width=450, height=350) " 7494,Plot the weekly average PM2.5 for Aurangabad in 2019 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Aurangabad') & (data['Timestamp'].dt.year == 2019)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Aurangabad 2019', width=600, height=300) return chart " 7495,"Plot the yearly average PM2.5 trends for Arunachal Pradesh, Kerala, and Uttar Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Arunachal Pradesh', 'Kerala', 'Uttar Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Arunachal Pradesh vs Kerala vs Uttar Pradesh', width=550, height=320) return chart " 7496,"In March 2024, report the station with the 3rd highest median PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 7497,Plot the weekly average PM2.5 for Perundurai in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Perundurai') & (data['Timestamp'].dt.year == 2024)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Perundurai 2024', width=600, height=300) return chart " 7498,Name the city showing the highest 75th percentile of PM10 for December 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 7499,"Which state (excluding Union Territories) possesses the 2nd smallest land area among the top 5 most polluted states, based on the standard deviation of PM2.5 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'std', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 5, 'ret': 'state'}}] " 7500,Report which state possessed the lowest 25th percentile of PM10 throughout the Post-Monsoon season of 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 7501,"Which state (excluding Union Territories) has the largest land area among the top 3 most polluted states, according to average PM2.5 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 3, 'ret': 'state'}}] " 7502,How many times did Bihar go above 90 µg/m³ of PM10 in the year 2017?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 90.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 7503,Plot the rolling 30-day average PM2.5 for Madhya Pradesh in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Madhya Pradesh') & (data['Timestamp'].dt.year == 2020)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Madhya Pradesh 2020', width=600, height=300) " 7504,Generate a city × month cross-tab of mean PM10 for Madhya Pradesh in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Bhopal', 'Dewas', 'Gwalior', 'Indore', 'Jabalpur', 'Katni', 'Maihar', 'Mandideep', 'Pithampur', 'Ratlam', 'Sagar', 'Satna', 'Singrauli', 'Ujjain']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7505,"Which union territory possesses the highest land area among the top 4 most polluted union territories, based on median PM10 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 4, 'ret': 'state'}}] " 7506,Which state recorded the highest median PM10 in September 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 7507,List average PM10 by month for Delhi in 2022 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Delhi'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7508,"Create a table of PM2.5, PM10 and station counts by state for 2021."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}, {'alias': 'Station Count', 'col': 'station', 'fn': 'nunique'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7509,Show a cumulative area chart of PM2.5 readings for Madikeri across 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Madikeri') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Madikeri 2021', width=600, height=300) return chart " 7510,Show the monthly average PM2.5 for Eloor in 2023 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Eloor') & (data['Timestamp'].dt.year == 2023)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Eloor 2023', width=450, height=280) " 7511,Create a table of state PM10 levels and geographic area for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7512,Which state recorded the third-most minimal 25th percentile of PM2.5 in February 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 7513,"In 2023, which state will rank with the third largest reduction in 75th percentile PM2.5 levels from October to December?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 7514,"Scatter plot PM2.5 vs PM10 for Himachal Pradesh stations in 2020, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Himachal Pradesh') & (data['Timestamp'].dt.year == 2020)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Himachal Pradesh Stations 2020', width=450, height=350) " 7515,List states with their PM2.5 violation count and rate (>100 µg/m³) in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7516,Show average PM10 per capita by state in 2020 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM10 per million', 'numerator': 'PM10', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'PM10 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7517,Generate a city × month cross-tab of mean PM10 for Maharashtra in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Aurangabad', 'Chandrapur', 'Nagpur', 'Nashik', 'Navi Mumbai', 'Solapur', 'Thane']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7518,"In 2019, which week experienced the second-highest 25th percentile for PM10 concentrations?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'week'}}] " 7519,"Visualize the monthly average PM10 for Manipur, Puducherry, and Bihar in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Manipur', 'Puducherry', 'Bihar'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Manipur, Puducherry, UP – 2022', width=550, height=320) return chart " 7520,Show the monthly average PM10 trend for Pithampur from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Pithampur'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Pithampur (2017–2022)', width=600, height=300) return chart " 7521,List the top 15 citys by average PM10 in 2024 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 7522,Generate a year-by-year summary table of PM10 readings for Nagaland.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Nagaland'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7523,Show the number of days each state exceeded a PM10 threshold of 100 µg/m³ in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7524,Create a table of PM2.5 exceedance frequency above 100 µg/m³ by state for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7525,Show the monthly average PM10 trend for Bikaner from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Bikaner'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Bikaner (2019–2024)', width=600, height=300) return chart " 7526,List the top 20 citys by PM2.5 in 2021 with both PM2.5 and PM10 averages.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 7527,Show PM2.5 exceedance count and rate (%) above 100 µg/m³ per state in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7528,Which city recorded the 3rd lowest median PM10 in the Monsoon season of 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 7529,Which city had the highest median PM2.5 in August 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 7530,Show the monthly average PM10 trend for Katihar from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Katihar'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Katihar (2017–2022)', width=600, height=300) return chart " 7531,Show the monthly average PM10 trend for Belgaum from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Belgaum'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Belgaum (2019–2024)', width=600, height=300) return chart " 7532,Plot the distribution of PM2.5 values in Telangana across all years using a histogram.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Telangana'].dropna(subset=['PM2.5']) df = df[['PM2.5']] chart = alt.Chart(df).mark_bar(color='steelblue', opacity=0.75).encode( x=alt.X('PM2\.5:Q', bin=alt.Bin(maxbins=40), title='PM2.5 (µg/m³)'), y=alt.Y('count()', title='Number of Observations'), tooltip=[alt.Tooltip('PM2\.5:Q', bin=True), 'count()'] ).properties(title='PM2.5 Distribution – Telangana (All Years)', width=500, height=300) return chart " 7533,"In May 2022, report the station with the highest average PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 7534,"Plot the yearly average PM2.5 trends for Delhi, Uttarakhand, and Telangana from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Delhi', 'Uttarakhand', 'Telangana'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Delhi vs Uttarakhand vs Telangana', width=550, height=320) return chart " 7535,Which 5 states had the lowest mean PM10 in 2020? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 7536,Show the monthly average PM10 trend for Kishanganj from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Kishanganj'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Kishanganj (2019–2024)', width=600, height=300) return chart " 7537,"Show descriptive statistics of PM10 (mean, median, std, min, max) per state in 2020."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7538,Show a monthly breakdown table of average PM2.5 for Nagaland in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Nagaland'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7539,How many times did Satna city surpass the WHO guideline for PM2.5 in 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 15.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 7540,Determine which state was granted the 5th lowest NCAP funding considering the standard deviation of its PM2.5 concentration in 2021 (FY 2020-21).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'std', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 7541,List the average PM2.5 for Hyderabad broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Hyderabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7542,"Create a faceted bar chart showing top 10 states by average PM2.5 per year for 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year.isin([2020,2021,2022,2023])].copy() df['Year'] = df['Timestamp'].dt.year agg = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() top = agg.groupby('Year').apply(lambda x: x.nlargest(10,'PM2.5')).reset_index(drop=True) chart = alt.Chart(top).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Avg PM2.5'), y=alt.Y('state:N', sort='-x'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet(facet='Year:O', columns=2).properties(title='Top 10 States by PM2.5 per Year') return chart " 7543,"Plot the yearly average PM2.5 trends for Jharkhand, Jharkhand, and Kerala from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Jharkhand', 'Kerala'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Jharkhand vs Jharkhand vs Kerala', width=550, height=320) return chart " 7544,"Visualize the monthly average PM10 for Jharkhand, Jharkhand, and Jharkhand in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Jharkhand', 'Jharkhand', 'Jharkhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Jharkhand, Jharkhand, UP – 2018', width=550, height=320) return chart " 7545,"Plot the yearly average PM2.5 trends for Haryana, Haryana, and Gujarat from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Haryana', 'Gujarat'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Haryana vs Haryana vs Gujarat', width=550, height=320) return chart " 7546,Which city had the lowest 75th percentile of PM10 in February 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 7547,List states ranked by PM10 concentration relative to their area in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM10 per km²', 'numerator': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)', 'PM10 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7548,Create a statistical summary table of PM2.5 readings by city for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7549,Create a ranked table of the 20 best-performing citys by PM2.5 in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 7550,Generate a year-by-year summary table of PM2.5 readings for Assam.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Assam'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7551,Show a table of the top 10 citys by average PM2.5 in 2023 including their PM10 levels too.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 7552,Report the state that had the highest median PM10 in November 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 7553,"Create a grouped bar chart comparing the average PM2.5 for Gujarat, Sikkim, and Haryana across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Gujarat', 'Sikkim', 'Haryana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 7554,Which station recorded the peak median PM10 in the Post-Monsoon season of 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 7555,"Create a grouped bar chart comparing the average PM2.5 for West Bengal, Chandigarh, and Meghalaya across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['West Bengal', 'Chandigarh', 'Meghalaya'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 7556,"Plot the yearly average PM2.5 trends for Sikkim, Odisha, and Jharkhand from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Sikkim', 'Odisha', 'Jharkhand'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Sikkim vs Odisha vs Jharkhand', width=550, height=320) return chart " 7557,"Plot the yearly average PM2.5 trends for Odisha, Rajasthan, and Madhya Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Odisha', 'Rajasthan', 'Madhya Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Odisha vs Rajasthan vs Madhya Pradesh', width=550, height=320) return chart " 7558,Which state displayed the highest average PM2.5 in May 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 7559,Report the state that had the 3rd highest median PM10 in March 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 7560,"Plot the yearly average PM2.5 trends for Tamil Nadu, Sikkim, and Uttarakhand from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Sikkim', 'Uttarakhand'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Tamil Nadu vs Sikkim vs Uttarakhand', width=550, height=320) return chart " 7561,Tabulate the monthly mean PM2.5 levels for Patna during 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Patna'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7562,Plot the weekly average PM2.5 for Bulandshahr in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bulandshahr') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Bulandshahr 2023', width=600, height=300) return chart " 7563,Create a summary table ranking the top 15 citys by PM10 concentration in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 7564,"Scatter plot PM2.5 vs PM10 for Karnataka stations in 2021, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Karnataka') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Karnataka Stations 2021', width=450, height=350) " 7565,Find the state with the lowest 75th percentile for PM10 in November 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 7566,Generate a year-by-year summary table of PM2.5 readings for Asansol.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Asansol'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7567,Create a table showing PM10 spread (min to max) and central tendency per city for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7568,"In April 2020, amidst the COVID-19 lockdown, which city recorded the highest PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 7569,"Visualize the monthly average PM10 for Delhi, Kerala, and Nagaland in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Delhi', 'Kerala', 'Nagaland'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Delhi, Kerala, UP – 2017', width=550, height=320) return chart " 7570,"Visualize the monthly average PM10 for Sikkim, Puducherry, and Madhya Pradesh in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Sikkim', 'Puducherry', 'Madhya Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Sikkim, Puducherry, UP – 2017', width=550, height=320) return chart " 7571,Tabulate average PM10 for each state across all months in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Delhi', 'Gujarat', 'Haryana', 'Jharkhand', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7572,Show the monthly average PM2.5 for Gwalior in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Gwalior') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Gwalior 2020', width=450, height=280) " 7573,"In December 2021, which city exhibited the 2nd highest average PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 7574,Show the monthly average PM2.5 for Bhilai in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bhilai') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Bhilai 2020', width=450, height=280) " 7575,"Visualize the monthly average PM10 for Bihar, Maharashtra, and Jammu and Kashmir in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Bihar', 'Maharashtra', 'Jammu and Kashmir'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Bihar, Maharashtra, UP – 2017', width=550, height=320) return chart " 7576,Show the monthly average PM2.5 for Nagapattinam in 2023 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Nagapattinam') & (data['Timestamp'].dt.year == 2023)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Nagapattinam 2023', width=450, height=280) " 7577,"Plot the yearly average PM2.5 trends for Madhya Pradesh, Gujarat, and Rajasthan from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Madhya Pradesh', 'Gujarat', 'Rajasthan'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Madhya Pradesh vs Gujarat vs Rajasthan', width=550, height=320) return chart " 7578,List citys with their PM2.5 violation count and rate (>100 µg/m³) in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7579,List the top 5 citys by average PM10 in 2022 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 7580,"In 2022, which city ranked with the third largest decrease in 75th percentile PM2.5 levels from October to December?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 7581,Identify the state that recorded the 3rd highest median PM2.5 value in July 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 7582,Show a cumulative area chart of PM2.5 readings for Muzaffarpur across 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Muzaffarpur') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Muzaffarpur 2023', width=600, height=300) return chart " 7583,Which station noted the 2nd maximum 25th percentile of PM2.5 in the Summer season of 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 7584,Create a statistical summary table of PM10 readings by state for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7585,"Across all recorded years, which April showed the second-lowest average PM2.5 concentration?"," [{'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'Timestamp'}}] " 7586,"Scatter plot PM2.5 vs PM10 for Gujarat stations in 2017, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Gujarat') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Gujarat Stations 2017', width=450, height=350) " 7587,Generate a year-by-year summary table of PM2.5 readings for Patna.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Patna'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7588,Tabulate the 5 citys with the least PM10 pollution in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 7589,Create a ranked table of the 15 best-performing states by PM2.5 in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 7590,Tabulate the top 15 states for PM2.5 in 2018 along with their corresponding PM10 values.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 7591,"Compare the monthly average PM2.5 of Delhi, Bhilai, and Dhule in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Delhi', 'Bhilai', 'Dhule'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Delhi vs Bhilai vs Dhule – 2023', width=550, height=320) return chart " 7592,Create a table showing annual mean PM2.5 levels for Maharashtra (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7593,"Plot the yearly average PM2.5 trends for Assam, Jammu and Kashmir, and Sikkim from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Assam', 'Jammu and Kashmir', 'Sikkim'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Assam vs Jammu and Kashmir vs Sikkim', width=550, height=320) return chart " 7594,"In 2020, which weekday experienced the maximum median PM2.5 pollution levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'Timestamp'}}] " 7595,"Show the top 15 states by average PM10 in 2021 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2021] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(15, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 15 States by Average PM10 in 2021', width=500, height=300) return chart " 7596,How many times did Karnataka city go above the WHO guideline for PM10 in 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 15.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 7597,Which city had the 2nd lowest 25th percentile of PM2.5 in July 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 7598,Which state exhibited the second smallest decrease in its 25th percentile PM2.5 levels between October and December of 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 7599,Show the monthly average PM2.5 for Bikaner in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bikaner') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Bikaner 2019', width=450, height=280) " 7600,Determine the station with the lowest average PM2.5 in July 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 7601,Create a heatmap showing the average PM2.5 by month (x-axis) and year (y-axis) for Uttarakhand.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Uttarakhand'].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Year:N', title='Year'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='Avg PM2.5'), tooltip=['Year:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Uttarakhand (Month × Year)', width=500, height=280) return chart " 7602,Create a table of state PM10 levels and geographic area for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7603,Show a monthly breakdown table of average PM2.5 for Hyderabad in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Hyderabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7604,"Plot the yearly average PM2.5 trends for Puducherry, Jammu and Kashmir, and Chhattisgarh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'Jammu and Kashmir', 'Chhattisgarh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Puducherry vs Jammu and Kashmir vs Chhattisgarh', width=550, height=320) return chart " 7605,"Visualize the monthly average PM10 for Haryana, Mizoram, and Nagaland in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Mizoram', 'Nagaland'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Haryana, Mizoram, UP – 2021', width=550, height=320) return chart " 7606,Plot the rolling 30-day average PM2.5 for Punjab in 2017 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Punjab') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Punjab 2017', width=600, height=300) " 7607,Identify the city that received the 5th lowest NCAP funding with respect to its average PM10 concentration in 2020 (FY 2019-20).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2020_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 7608,Which 20 citys had the lowest mean PM10 in 2017? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 7609,Determine the station exhibiting the 3rd lowest 25th percentile of PM2.5 in September 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 7610,Tabulate average PM10 for each city in Andhra Pradesh across all months of 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Tirupati']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7611,Show which states received the most NCAP funding in total.," [ {'op': 'SOURCE', 'params': {'table': 'ncap'}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'Total fund released', 'fn': 'sum'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Total fund released'}}, {'op': 'RENAME', 'params': {'map': {'Total fund released': 'Total Fund Released (Cr)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7612,Which station showed the 3rd highest 75th percentile for PM10 in the Monsoon season of 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 7613,Which state registered the 3rd highest median PM10 during June 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 7614,Which city had the 3rd lowest average PM10 in January 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 7615,"Compare the monthly average PM2.5 of Hyderabad, Kozhikode, and Araria in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Hyderabad', 'Kozhikode', 'Araria'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Hyderabad vs Kozhikode vs Araria – 2022', width=550, height=320) return chart " 7616,Plot the weekly average PM2.5 for Bengaluru in 2021 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bengaluru') & (data['Timestamp'].dt.year == 2021)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Bengaluru 2021', width=600, height=300) return chart " 7617,Show a monthly breakdown table of average PM2.5 for Madhya Pradesh in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7618,Generate a year-by-year summary table of PM2.5 readings for Gaya.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Gaya'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7619,"Visualize the monthly average PM10 for Mizoram, Chandigarh, and Odisha in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Mizoram', 'Chandigarh', 'Odisha'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Mizoram, Chandigarh, UP – 2024', width=550, height=320) return chart " 7620,Report the state with the highest average PM2.5 in March 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 7621,"Considering all New Year's Eves, which station had the third-lowest recorded PM2.5 levels?"," [{'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 7622,"On March 31, 2022, which state recorded the third-lowest average PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 7623,"Identify the state with the minimum 75th percentile for PM2.5 on March 31, 2020."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 7624,Show the monthly average PM10 trend for Thane from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Thane'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Thane (2019–2024)', width=600, height=300) return chart " 7625,"In October 2018, report the station with the 3rd lowest 25th percentile of PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 7626,Create a statistical summary table of PM2.5 readings by state for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'q25', 'median', 'q75']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7627,"Comparing December 2020 to October 2020, which state showed the least significant drop in average PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 7628,Show the monthly average PM2.5 for Jhalawar in 2024 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Jhalawar') & (data['Timestamp'].dt.year == 2024)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Jhalawar 2024', width=450, height=280) " 7629,Which state registered the 3rd minimum 25th percentile of PM10 during the Summer season of 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 7630,Tabulate daily PM2.5 exceedances (above 100 µg/m³) per state for 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7631,Show the monthly average PM2.5 for Chengalpattu in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Chengalpattu') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Chengalpattu 2020', width=450, height=280) " 7632,Create a table with mean and standard deviation of PM2.5 by city in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7633,Which city recorded the highest average PM2.5 in September 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 7634,Generate a city × month cross-tab of mean PM10 for Odisha in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Odisha'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Angul', 'Balasore', 'Barbil', 'Baripada', 'Bhubaneswar', 'Bileipada', 'Brajrajnagar', 'Byasanagar', 'Cuttack', 'Keonjhar', 'Nayagarh', 'Rairangpur', 'Rourkela', 'Suakati', 'Talcher', 'Tensa']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7635,List the bottom 15 citys with the lowest average PM10 in 2021 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 7636,Determine the state with the highest 25th percentile of PM10 in September 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 7637,Tabulate the 15 worst states for average PM2.5 in 2023 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 7638,Identify the state that registered the minimum PM2.5 level on 27 January 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 7639,Identify the state with the lowest median PM2.5 for March 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 7640,"For the period October to December 2022, which city had the third smallest decrease in 75th percentile PM2.5 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 7641,Which city had the 2nd lowest 75th percentile of PM10 in February 2022?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 7642,Tabulate average and median PM10 for all citys in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7643,Which state with NCAP funding exhibits the 2nd highest PM10 concentration?," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}] " 7644,Show the monthly average PM2.5 for Alwar in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Alwar') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Alwar 2020', width=450, height=280) " 7645,Show how average PM2.5 varied month by month for Muzaffarpur in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Muzaffarpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7646,Show the monthly average PM10 trend for Bhiwadi from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Bhiwadi'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Bhiwadi (2019–2024)', width=600, height=300) return chart " 7647,"Visualize the monthly average PM10 for Mizoram, Telangana, and Nagaland in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Mizoram', 'Telangana', 'Nagaland'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Mizoram, Telangana, UP – 2023', width=550, height=320) return chart " 7648,Which station registered the lowest 25th percentile of PM2.5 during June 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 7649,Plot the weekly average PM2.5 for Bihar Sharif in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bihar Sharif') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Bihar Sharif 2023', width=600, height=300) return chart " 7650,Show average PM2.5 per state in 2019 with area in km².," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7651,Tabulate average PM10 for each city in Andhra Pradesh across all months of 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Amaravati', 'Rajamahendravaram', 'Tirupati', 'Vijayawada', 'Visakhapatnam']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7652,Which state noted the 3rd maximum 25th percentile of PM10 during the Winter season of 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 7653,Tabulate the monthly mean PM10 levels for Telangana during 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Telangana'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7654,"Show mean, median, minimum, and maximum PM2.5 for each state in 2023 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7655,Show the monthly average PM10 trend for Baripada from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Baripada'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Baripada (2019–2024)', width=600, height=300) return chart " 7656,"Tabulate the distribution of PM10 per city in 2017 including mean, median, and std."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7657,Which city registered the peak median PM10 during the Post-Monsoon season of 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 7658,"Show a table of average PM2.5, population, and area for all states in 2021."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': { 'map': { 'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7659,Plot the rolling 30-day average PM2.5 for Andhra Pradesh in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Andhra Pradesh') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Andhra Pradesh 2023', width=600, height=300) " 7660,Tabulate average and median PM10 for all citys in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7661,Determine the state exhibiting the 3rd highest 25th percentile of PM2.5 in March 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 7662,Which state recorded the 2nd highest 75th percentile of PM2.5 in the Summer season of 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 7663,"Show the top 14 states by average PM10 in 2024 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2024] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(14, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 14 States by Average PM10 in 2024', width=500, height=300) return chart " 7664,Create a table showing annual mean PM10 levels for Gurugram (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Gurugram'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7665,Create a month-wise PM2.5 breakdown table across cities in Rajasthan for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Ajmer', 'Alwar', 'Bhiwadi', 'Jaipur', 'Jodhpur', 'Kota', 'Pali', 'Udaipur']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7666,"In 2019, which station ranked second for the smallest decrease in median PM10 levels from October to December?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 7667,Show annual average PM10 for Delhi as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Delhi'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7668,Report the city with the 3rd lowest median PM10 in August 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 7669,"Plot the yearly average PM2.5 trends for Haryana, Meghalaya, and Uttarakhand from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Meghalaya', 'Uttarakhand'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Haryana vs Meghalaya vs Uttarakhand', width=550, height=320) return chart " 7670,"Create a faceted bar chart showing top 14 states by average PM2.5 per year for 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year.isin([2021,2022,2023,2024])].copy() df['Year'] = df['Timestamp'].dt.year agg = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() top = agg.groupby('Year').apply(lambda x: x.nlargest(14,'PM2.5')).reset_index(drop=True) chart = alt.Chart(top).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Avg PM2.5'), y=alt.Y('state:N', sort='-x'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet(facet='Year:O', columns=2).properties(title='Top 14 States by PM2.5 per Year') return chart " 7671,Determine the state exhibiting the lowest 25th percentile of PM10 in October 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 7672,Tabulate the monthly mean PM2.5 levels for Kanpur during 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Kanpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7673,"Create a grouped bar chart comparing the average PM2.5 for West Bengal, Gujarat, and Uttarakhand across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['West Bengal', 'Gujarat', 'Uttarakhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 7674,Which 15 states had the lowest mean PM10 in 2020? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 7675,"Plot the yearly average PM2.5 trends for Punjab, Chhattisgarh, and Telangana from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Punjab', 'Chhattisgarh', 'Telangana'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Punjab vs Chhattisgarh vs Telangana', width=550, height=320) return chart " 7676,Create a ranked table of the 5 best-performing citys by PM2.5 in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 7677,Which state experienced the second most significant drop in its 25th percentile PM2.5 levels between October and December 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 7678,Plot the weekly average PM2.5 for Panipat in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Panipat') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Panipat 2023', width=600, height=300) return chart " 7679,Show a pivot table of monthly average PM2.5 by state for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Arunachal Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Chhattisgarh', 'Delhi', 'Gujarat', 'Haryana', 'Jammu and Kashmir', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Meghalaya', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7680,"Show a table of average PM2.5, population, and area for all states in 2022."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': { 'map': { 'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7681,"In August 2022, report the state with the 2nd lowest average PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 7682,"Compare the monthly average PM2.5 of Dhule, Bengaluru, and Kurukshetra in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Dhule', 'Bengaluru', 'Kurukshetra '] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Dhule vs Bengaluru vs Kurukshetra – 2022', width=550, height=320) return chart " 7683,List all citys with their average PM2.5 and PM10 levels in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7684,Which station showed the 3rd highest 75th percentile of PM2.5 in August 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 7685,Generate a descriptive stats table for PM2.5 grouped by city in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7686,Show how average PM10 varied month by month for Maharashtra in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7687,Tabulate area-adjusted PM10 (per km²) for each state in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM10 per km²', 'numerator': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)', 'PM10 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7688,Identify the state with the 2nd lowest average PM10 in December 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 7689,Show a cumulative area chart of PM2.5 readings for Srinagar across 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Srinagar') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Srinagar 2021', width=600, height=300) return chart " 7690,Create a month-wise PM2.5 breakdown table across cities in Maharashtra for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Chandrapur']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7691,Identify the station that recorded the most minimal average PM2.5 during the Post-Monsoon season of 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 7692,"Visualize the monthly average PM10 for Andhra Pradesh, Telangana, and Nagaland in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Telangana', 'Nagaland'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Andhra Pradesh, Telangana, UP – 2018', width=550, height=320) return chart " 7693,"Visualize the monthly average PM10 for Tamil Nadu, Maharashtra, and Delhi in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Maharashtra', 'Delhi'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Tamil Nadu, Maharashtra, UP – 2017', width=550, height=320) return chart " 7694,"Plot the yearly average PM2.5 trends for Bihar, Assam, and Meghalaya from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Bihar', 'Assam', 'Meghalaya'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Bihar vs Assam vs Meghalaya', width=550, height=320) return chart " 7695,"Scatter plot PM2.5 vs PM10 for Puducherry stations in 2018, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Puducherry') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Puducherry Stations 2018', width=450, height=350) " 7696,"Create a grouped bar chart comparing the average PM2.5 for West Bengal, Tamil Nadu, and Bihar across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['West Bengal', 'Tamil Nadu', 'Bihar'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 7697,"Visualize the monthly average PM10 for Delhi, Karnataka, and Assam in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Delhi', 'Karnataka', 'Assam'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Delhi, Karnataka, UP – 2021', width=550, height=320) return chart " 7698,Tabulate daily PM10 exceedances (above 100 µg/m³) per city for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7699,"Plot the yearly average PM2.5 trends for Tamil Nadu, Meghalaya, and Andhra Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Meghalaya', 'Andhra Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Tamil Nadu vs Meghalaya vs Andhra Pradesh', width=550, height=320) return chart " 7700,Tabulate the 5 states with the least PM10 pollution in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 7701,Identify the state that recorded the most minimal median PM2.5 during the Winter season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'winter', 'months': [12, 1, 2]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 7702,Identify the state with the lowest 25th percentile of PM2.5 in August 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 7703,Create a month-wise summary of average PM10 for Bengaluru in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Bengaluru'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7704,Report the station with the 2nd lowest average PM10 in March 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 7705,Show a cumulative area chart of PM2.5 readings for Bahadurgarh across 2019.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bahadurgarh') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Bahadurgarh 2019', width=600, height=300) return chart " 7706,List how many days each city breached the PM2.5 limit of 100 µg/m³ in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7707,Which city had the 2nd lowest average PM10 in January 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 7708,"Scatter plot PM2.5 vs PM10 for Arunachal Pradesh stations in 2018, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Arunachal Pradesh') & (data['Timestamp'].dt.year == 2018)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Arunachal Pradesh Stations 2018', width=450, height=350) " 7709,Show PM2.5 exceedances above the Indian standard (60 µg/m³) per year as a bar chart for Uttar Pradesh.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Uttar Pradesh'].dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 60].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby('Year')['Timestamp'].nunique().reset_index() df.columns = ['Year','Days Exceeded'] chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('Year:N', title='Year'), y=alt.Y('Days Exceeded:Q', title='Days PM2.5 > 60 µg/m³'), tooltip=['Year:N','Days Exceeded:Q'] ).properties(title='Days Uttar Pradesh Exceeded Indian PM2.5 Standard (60 µg/m³) per Year', width=450, height=300) return chart " 7710,Which state registered the 2nd highest average PM2.5 during February 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 7711,List the average PM10 for Maharashtra broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7712,Name the city that was second in terms of highest median PM2.5 for September 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 7713,"Visualize the monthly average PM10 for Sikkim, Meghalaya, and Andhra Pradesh in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Sikkim', 'Meghalaya', 'Andhra Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Sikkim, Meghalaya, UP – 2017', width=550, height=320) return chart " 7714,"Plot the yearly average PM2.5 trends for Assam, West Bengal, and Sikkim from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Assam', 'West Bengal', 'Sikkim'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Assam vs West Bengal vs Sikkim', width=550, height=320) return chart " 7715,"Plot the yearly average PM2.5 trends for Karnataka, Meghalaya, and Jammu and Kashmir from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Karnataka', 'Meghalaya', 'Jammu and Kashmir'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Karnataka vs Meghalaya vs Jammu and Kashmir', width=550, height=320) return chart " 7716,Determine the 2nd most polluted state based on per capita PM10 exposure during 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'per_capita_pm', 'numerator': 'PM10', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'per_capita_pm', 'ascending': False}}] " 7717,"Create a grouped bar chart comparing the average PM2.5 for Kerala, Sikkim, and Punjab across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Kerala', 'Sikkim', 'Punjab'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 7718,"Show descriptive statistics of PM2.5 (mean, median, std, min, max) per city in 2019."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7719,Tabulate daily PM2.5 exceedances (above 100 µg/m³) per city for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7720,"Create a grouped bar chart comparing the average PM2.5 for Chhattisgarh, Mizoram, and Himachal Pradesh across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chhattisgarh', 'Mizoram', 'Himachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 7721,Which state registered the minimum 75th percentile of PM2.5 in the Summer season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 7722,Which station noted the 3rd lowest average PM10 in the Monsoon season of 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 7723,Create a per-capita PM10 summary table by state for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM10 per million', 'numerator': 'PM10', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'PM10 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7724,Which state had the 3rd lowest 75th percentile of PM10 in July 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 7725,"Visualize the monthly average PM10 for Haryana, Manipur, and Kerala in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Manipur', 'Kerala'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Haryana, Manipur, UP – 2023', width=550, height=320) return chart " 7726,Show a table of the top 20 citys by average PM2.5 in 2023 including their PM10 levels too.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 7727,"Which union territory has the 2nd highest land area among the top 2 most polluted union territories, according to average PM10 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 2, 'ret': 'state'}}] " 7728,Create a ranked table of the 15 best-performing states by PM2.5 in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 7729,Show a heatmap of average PM2.5 for the top 15 most polluted states by month for 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(15).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 15 Polluted States by Month (2021)', width=500, height=300) return chart " 7730,Show how average PM10 varied month by month for Maharashtra in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7731,Show a monthly bar chart of the number of days Mizoram exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Mizoram') & (data['Timestamp'].dt.year == 2021)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Mizoram Exceeded WHO PM2.5 Guideline per Month – 2021', width=500, height=300) return chart " 7732,"Compare the monthly average PM2.5 of Agra, Rishikesh, and Visakhapatnam in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Agra', 'Rishikesh', 'Visakhapatnam'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Agra vs Rishikesh vs Visakhapatnam – 2023', width=550, height=320) return chart " 7733,"Scatter plot PM2.5 vs PM10 for Rajasthan stations in 2017, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Rajasthan') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Rajasthan Stations 2017', width=450, height=350) " 7734,Tabulate the 10 worst citys for average PM10 in 2024 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 7735,Tabulate the yearly average PM2.5 trend for Gaya across all years.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Gaya'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7736,List how many days each state breached the PM10 limit of 100 µg/m³ in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7737,"In Bileipada, which date in the previous two years had the highest PM10 concentration?"," [{'op': 'FILTER', 'params': {'field': 'yr_recent', 'value': 2}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'Timestamp'}}] " 7738,Show a cumulative area chart of PM2.5 readings for Narnaul across 2019.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Narnaul') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Narnaul 2019', width=600, height=300) return chart " 7739,Plot the rolling 30-day average PM2.5 for Jharkhand in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Jharkhand') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Jharkhand 2024', width=600, height=300) " 7740,List the top 15 states by average PM10 in 2024 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 7741,"Which union territory has the highest PM2.5 concentration per square kilometer, based on the variance of PM2.5 values?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'var', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_km2', 'numerator': 'PM2.5', 'denominator': 'area (km2)'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'pm_per_km2', 'ascending': False}}] " 7742,Tabulate daily PM10 exceedances (above 150 µg/m³) per state for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7743,"Show descriptive statistics of PM2.5 (mean, median, std, min, max) per state in 2018."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7744,Create a table of PM10 exceedance frequency above 100 µg/m³ by state for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7745,Report the station with the 2nd lowest median PM2.5 in May 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 7746,Create a month-wise PM2.5 breakdown table across cities in Odisha for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Odisha'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Brajrajnagar', 'Talcher']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7747,Visualize the bottom 12 states with the lowest average PM2.5 in 2022 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2022] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(12, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 12 States by Average PM2.5 in 2022', width=500, height=300) return chart " 7748,Show a heatmap of average PM2.5 for the top 14 most polluted states by month for 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(14).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 14 Polluted States by Month (2018)', width=500, height=300) return chart " 7749,List the bottom 20 states with the lowest average PM2.5 in 2024 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 7750,Show how average PM10 varied month by month for Kota in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Kota'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7751,"Show the variability of PM2.5 across states in 2021 using mean, median, and standard deviation."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'q25', 'median', 'q75']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7752,Which 5 states had the lowest mean PM2.5 in 2019? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 7753,Which city recorded the 3rd lowest 25th percentile of PM2.5 in May 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 7754,"Scatter plot PM2.5 vs PM10 for Kerala stations in 2020, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Kerala') & (data['Timestamp'].dt.year == 2020)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Kerala Stations 2020', width=450, height=350) " 7755,Show a table of average PM2.5 and PM10 for all states in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7756,"On January 27, 2018, which station had the peak PM2.5 level?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 7757,"Tabulate the distribution of PM10 per state in 2019 including mean, median, and std."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'min', 'max']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7758,"Create a table showing top 15 states ranked by PM2.5 in 2022, also showing PM10."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 7759,Identify the state that registered the second lowest 75th percentile of PM2.5 during the Summer season of 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'spring', 'months': [3, 4, 5]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 7760,"Create a grouped bar chart comparing the average PM2.5 for Chhattisgarh, Mizoram, and Nagaland across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chhattisgarh', 'Mizoram', 'Nagaland'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 7761,"Which state (excluding Union Territories) has the largest land area among the top 3 most polluted states, according to the variance of PM10 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'var', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 3, 'ret': 'state'}}] " 7762,"In June 2022, which station exhibited the lowest 75th percentile of PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 7763,Determine the state exhibiting the 2nd lowest 75th percentile of PM2.5 in March 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 7764,Show the monthly average PM2.5 for Haryana across each year from 2017 to 2024 as small multiples (faceted by year).," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Haryana'].copy() df['Year'] = df['Timestamp'].dt.year df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5'), tooltip=['Year:O','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).facet( facet=alt.Facet('Year:O', title='Year'), columns=4 ).properties(title='Monthly PM2.5 in Haryana by Year (2017–2024)') return chart " 7765,"Create a grouped bar chart comparing the average PM2.5 for Assam, Karnataka, and Meghalaya across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Assam', 'Karnataka', 'Meghalaya'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 7766,Identify the city with the 3rd lowest 25th percentile of PM10 for June 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 6}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 7767,Show a ranked table of the 5 most polluted citys by average PM2.5 in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 7768,How many times did Kalyan city go above the WHO guideline for PM2.5 in 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 15.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 7769,"Which state (excluding Union Territories) shows the minimum PM10 concentration per square kilometer, using the variance of PM10 values?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'var', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_km2', 'numerator': 'PM10', 'denominator': 'area (km2)'}}, {'op': 'SORT', 'params': {'col': 'pm_per_km2', 'ascending': True}}] " 7770,Show a pivot table of monthly average PM10 by city for Karnataka in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Bagalkot', 'Bengaluru', 'Chikkaballapur', 'Chikkamagaluru', 'Kolar', 'Mysuru', 'Ramanagara']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7771,List citys with their PM10 violation count and rate (>100 µg/m³) in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7772,Create a month-by-state breakdown table of mean PM2.5 for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Bihar', 'Delhi', 'Haryana', 'Karnataka', 'Maharashtra', 'Tamil Nadu', 'Telangana', 'Uttar Pradesh']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7773,"Compare the monthly average PM2.5 of Kaithal, Jaipur, and Kota in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Kaithal', 'Jaipur', 'Kota'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Kaithal vs Jaipur vs Kota – 2018', width=550, height=320) return chart " 7774,Which state registered the highest median PM10 during May 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 7775,"Identify the city that registered the highest PM10 levels on August 15, 2024."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 7776,Create a table of PM2.5 exceedance frequency above 100 µg/m³ by state for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7777,Which city had the lowest 25th percentile of PM2.5 in May 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 7778,"Compare the monthly average PM2.5 of Mandideep, Ankleshwar, and Hanumangarh in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Mandideep', 'Ankleshwar', 'Hanumangarh'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Mandideep vs Ankleshwar vs Hanumangarh – 2024', width=550, height=320) return chart " 7779,Plot the rolling 30-day average PM2.5 for Tamil Nadu in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Tamil Nadu') & (data['Timestamp'].dt.year == 2020)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Tamil Nadu 2020', width=600, height=300) " 7780,"In December 2021, identify the city with the 3rd highest median PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 7781,Show the monthly average PM10 trend for Gaya from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Gaya'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Gaya (2019–2024)', width=600, height=300) return chart " 7782,"Comparing December 2019 to October 2019, which station showed the third most significant drop in average PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 7783,Generate a year-by-year summary table of PM2.5 readings for Meghalaya.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Meghalaya'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7784,Tabulate daily PM10 exceedances (above 100 µg/m³) per city for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7785,"Scatter plot PM2.5 vs PM10 for Madhya Pradesh stations in 2024, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Madhya Pradesh') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Madhya Pradesh Stations 2024', width=450, height=350) " 7786,Identify the station that recorded the 2nd lowest 25th percentile of PM2.5 value in March 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 7787,Show a monthly breakdown table of average PM10 for Nagaland in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Nagaland'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7788,Determine the state that showed the 3rd highest 75th percentile of PM2.5 over the Post-Monsoon season of 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 7789,Generate a city × month cross-tab of mean PM2.5 for Punjab in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Amritsar', 'Bathinda', 'Jalandhar', 'Khanna', 'Ludhiana', 'Mandi Gobindgarh', 'Patiala', 'Rupnagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7790,Show the monthly average PM10 trend for Chengalpattu from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Chengalpattu'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Chengalpattu (2019–2024)', width=600, height=300) return chart " 7791,Which station possessed the 2nd lowest average for PM2.5 in the Monsoon season of 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 7792,Plot the rolling 30-day average PM2.5 for Tripura in 2019 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Tripura') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Tripura 2019', width=600, height=300) " 7793,"In November 2022, identify the station with the 3rd highest 75th percentile of PM2.5."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 7794,"Compare the monthly average PM2.5 of Bathinda, Hapur, and Maihar in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Bathinda', 'Hapur', 'Maihar'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Bathinda vs Hapur vs Maihar – 2022', width=550, height=320) return chart " 7795,"Plot the yearly average PM2.5 trends for Odisha, Nagaland, and Jharkhand from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Odisha', 'Nagaland', 'Jharkhand'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Odisha vs Nagaland vs Jharkhand', width=550, height=320) return chart " 7796,"Create a grouped bar chart comparing the average PM2.5 for Assam, Gujarat, and Haryana across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Assam', 'Gujarat', 'Haryana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 7797,"Which union territory has the largest land area among the top 2 most polluted union territories, according to the standard deviation of PM10 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'std', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': True}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 2, 'ret': 'state'}}] " 7798,Plot the rolling 30-day average PM2.5 for Uttar Pradesh in 2019 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Uttar Pradesh') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Uttar Pradesh 2019', width=600, height=300) " 7799,Show a cumulative area chart of PM2.5 readings for Charkhi Dadri across 2022.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Charkhi Dadri') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Charkhi Dadri 2022', width=600, height=300) return chart " 7800,List average PM10 by month for Ghaziabad in 2019 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Ghaziabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7801,Tabulate average PM10 for each city in Uttar Pradesh across all months of 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Agra', 'Baghpat', 'Bareilly', 'Bulandshahr', 'Firozabad', 'Ghaziabad', 'Gorakhpur', 'Greater Noida', 'Hapur', 'Jhansi', 'Kanpur', 'Khurja', 'Lucknow', 'Meerut', 'Moradabad', 'Muzaffarnagar', 'Noida', 'Prayagraj', 'Varanasi', 'Vrindavan']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7802,Determine the state with the lowest 25th percentile for PM10 in August 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 7803,List citys with their PM2.5 violation count and rate (>100 µg/m³) in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7804,"Visualize the monthly average PM10 for Kerala, West Bengal, and Uttarakhand in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Kerala', 'West Bengal', 'Uttarakhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Kerala, West Bengal, UP – 2022', width=550, height=320) return chart " 7805,Determine a week with Tiruchirappalli's 2nd highest PM10 levels over all these years.," [{'op': 'FILTER', 'params': {'field': 'city', 'value': 'Tiruchirappalli'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'week'}}] " 7806,Show a monthly bar chart of the number of days Tamil Nadu exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2017.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Tamil Nadu') & (data['Timestamp'].dt.year == 2017)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Tamil Nadu Exceeded WHO PM2.5 Guideline per Month – 2017', width=500, height=300) return chart " 7807,Plot the rolling 30-day average PM2.5 for Delhi in 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Delhi') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Delhi 2022', width=600, height=300) " 7808,Which 20 citys recorded the highest average PM10 levels in 2020? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 7809,Plot the rolling 30-day average PM2.5 for Manipur in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Manipur') & (data['Timestamp'].dt.year == 2020)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Manipur 2020', width=600, height=300) " 7810,List how many days each state breached the PM10 limit of 150 µg/m³ in 2023.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7811,List states with their PM2.5 violation count and rate (>100 µg/m³) in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7812,List the bottom 5 states with the lowest average PM2.5 in 2021 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 7813,Report the state that was granted the 3rd highest NCAP funding with respect to its median PM2.5 concentration in 2021 (FY 2020-21).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 7814,List the bottom 15 states with the lowest average PM10 in 2023 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 7815,Tabulate the yearly average PM2.5 trend for Gurugram across all years.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Gurugram'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7816,"Show the top 11 states by average PM10 in 2018 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2018] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(11, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 11 States by Average PM10 in 2018', width=500, height=300) return chart " 7817,Show a cumulative area chart of PM2.5 readings for Dharwad across 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Dharwad') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Dharwad 2024', width=600, height=300) return chart " 7818,Which city had the highest 25th percentile of PM10 in September 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'city'}}] " 7819,Which city was second in terms of highest median PM10 for August 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'city'}}] " 7820,Generate a city × month cross-tab of mean PM10 for Andhra Pradesh in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Amaravati', 'Rajamahendravaram', 'Tirupati', 'Visakhapatnam']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7821,Plot the distribution of PM2.5 values in Sikkim across all years using a histogram.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Sikkim'].dropna(subset=['PM2.5']) df = df[['PM2.5']] chart = alt.Chart(df).mark_bar(color='steelblue', opacity=0.75).encode( x=alt.X('PM2\.5:Q', bin=alt.Bin(maxbins=40), title='PM2.5 (µg/m³)'), y=alt.Y('count()', title='Number of Observations'), tooltip=[alt.Tooltip('PM2\.5:Q', bin=True), 'count()'] ).properties(title='PM2.5 Distribution – Sikkim (All Years)', width=500, height=300) return chart " 7822,"Visualize the monthly average PM10 for Odisha, Andhra Pradesh, and Uttar Pradesh in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Odisha', 'Andhra Pradesh', 'Uttar Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Odisha, Andhra Pradesh, UP – 2022', width=550, height=320) return chart " 7823,Report the city that was granted the highest NCAP funding with respect to its total PM10 concentration in 2021 (FY 2020-21).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'sum', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2021_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 7824,Tabulate the 20 citys with the least PM10 pollution in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 7825,Generate a table showing the 5 most polluted states based on mean PM10 for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 7826,Show a monthly bar chart of the number of days Assam exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Assam') & (data['Timestamp'].dt.year == 2024)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Assam Exceeded WHO PM2.5 Guideline per Month – 2024', width=500, height=300) return chart " 7827,"Compare the monthly average PM2.5 of Barbil, Agra, and Gaya in 2020 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Barbil', 'Agra', 'Gaya'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2020)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Barbil vs Agra vs Gaya – 2020', width=550, height=320) return chart " 7828,Determine the state with the 2nd highest 25th percentile of PM10 in February 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 7829,Plot the monthly average PM2.5 trend for Andhra Pradesh from 2017 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Andhra Pradesh'].copy() df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='steelblue').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly Average PM2.5 Trend – Andhra Pradesh (2017–2024)', width=600, height=300) return chart " 7830,Create a month-wise summary of average PM10 for Jaipur in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Jaipur'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7831,Show annual average PM2.5 for Madhya Pradesh as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7832,"On March 31, 2020, which state recorded the second-lowest 25th percentile of PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 7833,"Plot the yearly average PM2.5 trends for Delhi, Jharkhand, and Sikkim from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Delhi', 'Jharkhand', 'Sikkim'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Delhi vs Jharkhand vs Sikkim', width=550, height=320) return chart " 7834,"Compare the monthly average PM2.5 of Kaithal, Ernakulam, and Boisar in 2020 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Kaithal', 'Ernakulam', 'Boisar'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2020)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Kaithal vs Ernakulam vs Boisar – 2020', width=550, height=320) return chart " 7835,"Plot the yearly average PM2.5 trends for Haryana, Andhra Pradesh, and Bihar from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Haryana', 'Andhra Pradesh', 'Bihar'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Haryana vs Andhra Pradesh vs Bihar', width=550, height=320) return chart " 7836,Create a table showing annual mean PM2.5 levels for Moradabad (2017–2024).," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Moradabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7837,Create a table of NCAP funding and utilisation rate by state.," [ {'op': 'SOURCE', 'params': {'table': 'ncap'}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Total Fund (Cr)', 'col': 'Total fund released', 'fn': 'sum'}, {'alias': 'Utilised (Cr)', 'col': 'Utilisation as on June 2022', 'fn': 'sum'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': {'denominator': 'Total Fund (Cr)', 'new_col': 'Utilisation %', 'numerator': 'Utilised (Cr)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Total Fund (Cr)'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7838,Visualize the bottom 7 states with the lowest average PM2.5 in 2017 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2017] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(7, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 7 States by Average PM2.5 in 2017', width=500, height=300) return chart " 7839,Show the monthly average PM10 trend for Baripada from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Baripada'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Baripada (2017–2022)', width=600, height=300) return chart " 7840,Identify the station with the lowest average PM10 in July 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 7841,"In 2021, which season (Winter, Summer, Monsoon, Post-Monsoon) was associated with the second-lowest 25th percentile of PM10 concentrations?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'COMPUTE_SEASON', 'params': {}}, {'op': 'AGG', 'params': {'by': 'season', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'season'}}] " 7842,"Plot the yearly average PM2.5 trends for Andhra Pradesh, Uttarakhand, and Puducherry from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Uttarakhand', 'Puducherry'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Andhra Pradesh vs Uttarakhand vs Puducherry', width=550, height=320) return chart " 7843,Show a cumulative area chart of PM2.5 readings for Tumakuru across 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Tumakuru') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Tumakuru 2024', width=600, height=300) return chart " 7844,Show a ranked table of the 5 most polluted citys by average PM2.5 in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 7845,"Plot the yearly average PM2.5 trends for Andhra Pradesh, Delhi, and Gujarat from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Delhi', 'Gujarat'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Andhra Pradesh vs Delhi vs Gujarat', width=550, height=320) return chart " 7846,"Plot the yearly average PM2.5 trends for Tripura, Jharkhand, and Bihar from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tripura', 'Jharkhand', 'Bihar'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Tripura vs Jharkhand vs Bihar', width=550, height=320) return chart " 7847,"Visualize the monthly average PM10 for Chandigarh, Jharkhand, and Rajasthan in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chandigarh', 'Jharkhand', 'Rajasthan'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Chandigarh, Jharkhand, UP – 2022', width=550, height=320) return chart " 7848,Show how average PM2.5 varied month by month for Gandhinagar in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Gandhinagar'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7849,Generate a city × month cross-tab of mean PM2.5 for Karnataka in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Bagalkot', 'Bengaluru', 'Chamarajanagar', 'Chikkaballapur', 'Chikkamagaluru', 'Davanagere', 'Gadag', 'Hubballi', 'Koppal', 'Madikeri', 'Mysuru', 'Raichur', 'Ramanagara', 'Shivamogga', 'Vijayapura', 'Yadgir']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7850,Identify the state that recorded the 3rd highest 25th percentile of PM2.5 value in September 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 7851,Create a month-wise PM2.5 breakdown table across cities in Odisha for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Odisha'}}, {'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Brajrajnagar', 'Talcher']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7852,Report the state that had the second least increment in funding between FY 2019-20 and FY 2020-21.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'sum', 'col': 'change'}}, {'op': 'SORT', 'params': {'col': 'change', 'ascending': True}}] " 7853,Create a summary table ranking the top 20 states by PM2.5 concentration in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 7854,"Visualize the monthly average PM10 for Chandigarh, Rajasthan, and Sikkim in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Chandigarh', 'Rajasthan', 'Sikkim'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Chandigarh, Rajasthan, UP – 2024', width=550, height=320) return chart " 7855,Identify the station with the 2nd highest 25th percentile of PM10 for July 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 7856,Tabulate the yearly average PM2.5 trend for Puducherry across all years.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Puducherry'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7857,"Create a grouped bar chart comparing the average PM2.5 for Puducherry, Andhra Pradesh, and Chhattisgarh across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Puducherry', 'Andhra Pradesh', 'Chhattisgarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 7858,Which station recorded the 3rd highest average for PM10 in the Post-Monsoon season of 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 7859,Tabulate average PM2.5 for each state across all months in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Arunachal Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Chhattisgarh', 'Delhi', 'Gujarat', 'Haryana', 'Himachal Pradesh', 'Jammu and Kashmir', 'Jharkhand', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Manipur', 'Meghalaya', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh', 'Uttarakhand', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7860,Create a month-wise PM2.5 breakdown table across cities in Gujarat for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Gujarat'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': ['Ahmedabad', 'Ankleshwar', 'Gandhinagar', 'Nandesari', 'Vapi', 'Vatva']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7861,Generate a monthly average PM10 table for Delhi for the year 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Delhi'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7862,Determine the city that recorded the 3rd lowest average PM10 over the Monsoon season of 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 7863,Show the monthly average PM2.5 for Jalgaon in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Jalgaon') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Jalgaon 2017', width=450, height=280) " 7864,Generate a year-by-year summary table of PM2.5 readings for Ahmedabad.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Ahmedabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7865,Show a table of the 15 cleanest states by average PM10 in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 7866,Identify the state that received the 3rd highest NCAP funding with respect to its total PM2.5 concentration in 2020 (FY 2019-20).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'sum', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2020_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': False}}] " 7867,"Considering all years, which March registered the maximum 75th percentile for PM2.5 levels?"," [{'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'Timestamp'}}] " 7868,Which station recorded the 3rd highest median PM2.5 in January 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 7869,Tabulate mean PM2.5 alongside state population figures for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7870,Tabulate the 5 states with the least PM10 pollution in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 7871,List average PM2.5 by month for Tamil Nadu in 2022 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7872,Show a cumulative area chart of PM2.5 readings for Bileipada across 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bileipada') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Bileipada 2024', width=600, height=300) return chart " 7873,Show PM2.5 exceedance count and rate (%) above 100 µg/m³ per state in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7874,Plot the weekly average PM2.5 for Bengaluru in 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bengaluru') & (data['Timestamp'].dt.year == 2022)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Bengaluru 2022', width=600, height=300) return chart " 7875,"Compare the monthly average PM2.5 of Rajgir, Purnia, and Dharwad in 2024 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Rajgir', 'Purnia', 'Dharwad'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2024)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Rajgir vs Purnia vs Dharwad – 2024', width=550, height=320) return chart " 7876,Which station had the 2nd highest 75th percentile of PM10 in August 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 7877,"Compare the monthly average PM2.5 of Kolhapur, Maihar, and Muzaffarnagar in 2020 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Kolhapur', 'Maihar', 'Muzaffarnagar'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2020)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Kolhapur vs Maihar vs Muzaffarnagar – 2020', width=550, height=320) return chart " 7878,What was the third-lowest PM2.5 level measured in 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}] " 7879,Which 20 states recorded the highest average PM2.5 levels in 2022? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 7880,Show a cumulative area chart of PM2.5 readings for Siliguri across 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Siliguri') & (data['Timestamp'].dt.year == 2021)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Siliguri 2021', width=600, height=300) return chart " 7881,"Over all years, which August registered the minimum average PM10 concentration?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'Timestamp'}}] " 7882,Tabulate the yearly average PM2.5 trend for Chandigarh across all years.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Chandigarh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7883,Plot the weekly average PM2.5 for Indore in 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Indore') & (data['Timestamp'].dt.year == 2024)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Indore 2024', width=600, height=300) return chart " 7884,Show the monthly average PM2.5 for Ratlam in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ratlam') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Ratlam 2020', width=450, height=280) " 7885,Calculate the average PM2.5 level on Mondays in Delhi.," [{'op': 'FILTER', 'params': {'field': 'state', 'value': 'Delhi'}}] " 7886,"Visualize the monthly average PM10 for Delhi, Himachal Pradesh, and Mizoram in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Delhi', 'Himachal Pradesh', 'Mizoram'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Delhi, Himachal Pradesh, UP – 2017', width=550, height=320) return chart " 7887,"Show mean, median, minimum, and maximum PM10 for each city in 2019 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7888,"In November 2020, which station exhibited the lowest 75th percentile of PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 7889,Show a monthly bar chart of the number of days Bihar exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Bihar') & (data['Timestamp'].dt.year == 2023)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Bihar Exceeded WHO PM2.5 Guideline per Month – 2023', width=500, height=300) return chart " 7890,Plot the rolling 30-day average PM2.5 for Uttarakhand in 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Uttarakhand') & (data['Timestamp'].dt.year == 2022)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Uttarakhand 2022', width=600, height=300) " 7891,"Which state having a land area exceeding 50,000 km² registers the 2nd minimum PM2.5 level, based on its median PM2.5 level?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}] " 7892,Tabulate the 20 states with the least PM10 pollution in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 7893,"Show the mean, median and standard deviation of PM2.5 per state in 2021 as a table."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median']}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7894,List the average PM2.5 for Mumbai broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Mumbai'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7895,Show a ranked table of the 5 most polluted states by average PM10 in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 7896,"Identify the state (excluding UTs) with the 2nd smallest population among the top 3 most polluted states, based on median PM2.5 levels."," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 3, 'ret': 'state'}}] " 7897,Show a year-wise table of average PM2.5 for Lucknow from 2017 to 2024.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Lucknow'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7898,Create a heatmap showing the average PM2.5 by month (x-axis) and year (y-axis) for Arunachal Pradesh.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Arunachal Pradesh'].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Year:N', title='Year'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='Avg PM2.5'), tooltip=['Year:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Arunachal Pradesh (Month × Year)', width=500, height=280) return chart " 7899,Plot the weekly average PM2.5 for Karnal in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Karnal') & (data['Timestamp'].dt.year == 2020)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Karnal 2020', width=600, height=300) return chart " 7900,Report the station with the 3rd highest 25th percentile of PM2.5 in May 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 5}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 7901,"Show the variability of PM2.5 across states in 2017 using mean, median, and standard deviation."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7902,"Create a grouped bar chart comparing the average PM2.5 for Telangana, Kerala, and Madhya Pradesh across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Telangana', 'Kerala', 'Madhya Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 7903,Which station had the 2nd lowest 25th percentile of PM10 in December 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 7904,Create a per-capita PM10 summary table by state for 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, { 'op': 'COMPUTE', 'params': { 'denominator': 'population', 'new_col': 'PM10 per million', 'numerator': 'PM10', 'scale': 1000000}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per million'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per million'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'population', 'PM10 per million']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7905,Create a month-wise summary of average PM2.5 for Karnataka in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Karnataka'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7906,Which city had the 3rd lowest average PM10 in November 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 7907,List the top 20 states by average PM10 in 2020 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 7908,List average PM2.5 by month for Meerut in 2023 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Meerut'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7909,Tabulate average PM10 for each city in Uttar Pradesh across all months of 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Uttar Pradesh'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Bulandshahr', 'Ghaziabad', 'Greater Noida', 'Hapur', 'Meerut', 'Moradabad', 'Muzaffarnagar', 'Noida']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7910,"Compare the monthly average PM2.5 of Jaipur, Davanagere, and Bharatpur in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Jaipur', 'Davanagere', 'Bharatpur'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Jaipur vs Davanagere vs Bharatpur – 2023', width=550, height=320) return chart " 7911,Determine which city got the 2nd lowest NCAP funding with respect to its 75th percentile of PM2.5 concentration in 2020 (FY 2019-20).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'city', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2020_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 7912,"Create a grouped bar chart comparing the average PM2.5 for Delhi, Haryana, and Himachal Pradesh across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Delhi', 'Haryana', 'Himachal Pradesh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 7913,Which 15 citys recorded the highest average PM10 levels in 2019? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 7914,Report the state that had the 3rd highest median PM10 in April 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'state'}}] " 7915,"Create a grouped bar chart comparing the average PM2.5 for Gujarat, Delhi, and Assam across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Gujarat', 'Delhi', 'Assam'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 7916,Generate a city × month cross-tab of mean PM2.5 for Tamil Nadu in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tamil Nadu'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Ariyalur', 'Chengalpattu', 'Chennai', 'Coimbatore', 'Cuddalore', 'Gummidipoondi', 'Ooty', 'Palkalaiperur', 'Ramanathapuram', 'Tirupur', 'Vellore', 'Virudhunagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7917,"In 2020, which city ranked third for the smallest decrease in 25th percentile PM2.5 levels from October to December?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 7918,Generate a monthly average PM10 table for Aurangabad for the year 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Aurangabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7919,"In January 2020, identify the state with the highest 75th percentile of PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 7920,"Visualize the monthly average PM10 for Delhi, Karnataka, and Nagaland in 2022 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Delhi', 'Karnataka', 'Nagaland'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2022)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Delhi, Karnataka, UP – 2022', width=550, height=320) return chart " 7921,"On March 31, 2018, which state had the second-highest 25th percentile for PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 7922,Create a table of PM2.5 standard violations (>60 µg/m³) per state in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7923,Create a month-wise summary of average PM10 for Ahmedabad in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Ahmedabad'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7924,List average PM10 by month for Haryana in 2023 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Haryana'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7925,"Visualize the monthly average PM10 for Gujarat, Bihar, and Karnataka in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Gujarat', 'Bihar', 'Karnataka'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Gujarat, Bihar, UP – 2017', width=550, height=320) return chart " 7926,"Identify the state with the maximum PM10 level on January 27, 2020."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 7927,"Visualize the monthly average PM10 for Maharashtra, Maharashtra, and Tripura in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Maharashtra', 'Maharashtra', 'Tripura'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Maharashtra, Maharashtra, UP – 2023', width=550, height=320) return chart " 7928,Create a table of PM10 standard violations (>150 µg/m³) per city in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7929,"Plot the yearly average PM2.5 trends for Madhya Pradesh, West Bengal, and Manipur from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Madhya Pradesh', 'West Bengal', 'Manipur'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Madhya Pradesh vs West Bengal vs Manipur', width=550, height=320) return chart " 7930,Show a table of the top 15 citys by average PM2.5 in 2024 including their PM10 levels too.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'city'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 7931,"Comparing December 2019 to October 2019, which station showed the most significant drop in 75th percentile PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 7932,Create a table of PM2.5 exceedance frequency above 100 µg/m³ by state for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7933,"Scatter plot PM2.5 vs PM10 for Himachal Pradesh stations in 2017, with a regression trend line."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Himachal Pradesh') & (data['Timestamp'].dt.year == 2017)] df = df.groupby('station')[['PM2.5','PM10']].mean().reset_index().dropna() scatter = alt.Chart(df).mark_point(filled=True, size=80, color='steelblue').encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=['station:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('PM10:Q', format='.1f')] ) trend = scatter.transform_regression('PM2\.5','PM10').mark_line(color='firebrick', strokeDash=[5,3]) return (scatter + trend).properties(title='PM2.5 vs PM10 – Himachal Pradesh Stations 2017', width=450, height=350) " 7934,Report the city that had the 3rd lowest average PM2.5 in October 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 7935,"Visualize the monthly average PM10 for Uttarakhand, Haryana, and West Bengal in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Uttarakhand', 'Haryana', 'West Bengal'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Uttarakhand, Haryana, UP – 2017', width=550, height=320) return chart " 7936,Tabulate the yearly average PM10 trend for Himachal Pradesh across all years.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Himachal Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7937,Visualize the bottom 9 states with the lowest average PM2.5 in 2024 using a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2024] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nsmallest(9, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='greens'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Bottom 9 States by Average PM2.5 in 2024', width=500, height=300) return chart " 7938,Create a table of PM10 standard violations (>150 µg/m³) per state in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7939,Visualize NCAP city-level funding for FY 2021-22 as a horizontal bar chart for the top 14 cities.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = ncap_funding_data[['city','state','Amount released during FY 2021-22']].copy() df.columns = ['city','state','Amount (Cr)'] df = df.nlargest(14, 'Amount (Cr)') df['City_State'] = df['city'] + ', ' + df['state'] chart = alt.Chart(df).mark_bar().encode( x=alt.X('Amount (Cr):Q', title='Amount Released (Cr)'), y=alt.Y('City_State:N', sort='-x', title='City, State'), color=alt.Color('state:N', title='State'), tooltip=['city:N','state:N', alt.Tooltip('Amount (Cr):Q', format='.1f')] ).properties(title='Top 14 Cities by NCAP Funding – FY 2021-22', width=500, height=400) return chart " 7940,List the top 10 citys by average PM10 in 2020 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 7941,Identify the city with the lowest median PM2.5 in April 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 7942,Show a ranked table of the 5 most polluted citys by average PM2.5 in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 7943,Plot the yearly average PM2.5 for the top 13 most polluted states from 2017 to 2024 as a multi-line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top5 = data.groupby('state')['PM2.5'].mean().nlargest(13).index.tolist() df = data[data['state'].isin(top5)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends – Top 13 Most Polluted States', width=600, height=350) return chart " 7944,Show a table of the 5 cleanest citys by average PM10 in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 7945,Show annual average PM10 for Raipur as a table sorted by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Raipur'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7946,Which state registered the 2nd maximum median PM2.5 in the Post-Monsoon season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 7947,"Visualize the monthly average PM10 for Punjab, Meghalaya, and Haryana in 2017 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Punjab', 'Meghalaya', 'Haryana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Punjab, Meghalaya, UP – 2017', width=550, height=320) return chart " 7948,"Show a table of average PM2.5, population, and area for all states in 2024."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'population', 'value': 0}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'population'}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'population', 'area (km2)']}}, { 'op': 'RENAME', 'params': { 'map': { 'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)', 'population': 'Population'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7949,Show the monthly average PM2.5 for Buxar in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Buxar') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Buxar 2020', width=450, height=280) " 7950,List average PM10 by month for Jaipur in 2018 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Jaipur'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7951,Plot the weekly average PM2.5 for Sirsa in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Sirsa') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Sirsa 2023', width=600, height=300) return chart " 7952,Create a month-wise summary of average PM2.5 for Punjab in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7953,Which station had the lowest 75th percentile of PM10 in January 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'station'}}] " 7954,List average PM10 by month for Noida in 2022 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Noida'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7955,Tabulate daily PM2.5 exceedances (above 60 µg/m³) per state for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7956,Show the monthly average PM10 trend for Shivamogga from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Shivamogga'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Shivamogga (2019–2024)', width=600, height=300) return chart " 7957,List the bottom 15 citys with the lowest average PM10 in 2018 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 7958,How many times did Muzaffarpur city exceed 90 µg/m³ of PM2.5 in the year 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 90.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 7959,"In August 2024, identify the city with the 3rd lowest average PM10."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 7960,How many times did Aizawl exceed 30 µg/m³ of PM10 in 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 30.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 7961,Show a heatmap of average PM2.5 for the top 8 most polluted states by month for 2017.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(8).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2017)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 8 Polluted States by Month (2017)', width=500, height=300) return chart " 7962,"Create a table showing top 10 states ranked by PM2.5 in 2022, also showing PM10."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, { 'op': 'MULTI_AGG', 'params': {'aggs': [{'col': 'PM2.5', 'fn': 'mean'}, {'col': 'PM10', 'fn': 'mean'}], 'by': 'state'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 7963,Which city exhibited the lowest median PM10 in March 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 7964,"In 2024, which station ranked with the second smallest decrease in average PM10 levels from October to December?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 7965,Show the monthly average PM2.5 for Akola in 2022 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Akola') & (data['Timestamp'].dt.year == 2022)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Akola 2022', width=450, height=280) " 7966,How many times did Kanpur city go above 90 µg/m³ of PM10 in 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 90.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'Timestamp'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 7967,Plot the top 6 states by average PM2.5 in 2019 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2019] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(6, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 6 States by Average PM2.5 in 2019', width=500, height=300) return chart " 7968,Tabulate the 10 worst states for average PM10 in 2021 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 7969,Determine the state that has the 4th lowest 25th percentile of PM10 concentration in relation to its population density.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_capita', 'numerator': 'PM10', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'pm_per_capita', 'ascending': True}}] " 7970,Determine the state which was granted the lowest NCAP funding considering its median PM10 concentration in 2020 (FY 2019-20).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2020_fund', 'denominator': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 7971,Show a table of the 5 cleanest states by average PM2.5 in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 5}}] " 7972,"Create a grouped bar chart comparing the average PM2.5 for Madhya Pradesh, Assam, and Uttarakhand across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Madhya Pradesh', 'Assam', 'Uttarakhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 7973,List the average PM2.5 for Kolkata broken down by year.," [ {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Kolkata'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7974,Show the monthly average PM10 trend for Sikar from 2019 to 2024 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Sikar'].copy() df = df[(df['Timestamp'].dt.year >= 2019) & (df['Timestamp'].dt.year <= 2024)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Sikar (2019–2024)', width=600, height=300) return chart " 7975,"Visualize the monthly average PM10 for Telangana, Tamil Nadu, and Jharkhand in 2021 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Telangana', 'Tamil Nadu', 'Jharkhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2021)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Telangana, Tamil Nadu, UP – 2021', width=550, height=320) return chart " 7976,Report the state exhibiting the 5th lowest median PM2.5 concentration when considering population density.," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'COMPUTE', 'params': {'new_col': 'pm_per_capita', 'numerator': 'PM2.5', 'denominator': 'population'}}, {'op': 'SORT', 'params': {'col': 'pm_per_capita', 'ascending': True}}] " 7977,"Over all years, which September showed the third-lowest 25th percentile of PM10 concentration?"," [{'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'Timestamp'}}] " 7978,Determine the state that was second in terms of highest average PM10 for March 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 7979,Show PM10 density (µg/m³ per km²) by state for 2021 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'COMPUTE', 'params': {'denominator': 'area (km2)', 'new_col': 'PM10 per km²', 'numerator': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10 per km²'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10 per km²'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)', 'PM10 per km²']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7980,Show a monthly breakdown table of average PM2.5 for Gujarat in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Gujarat'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7981,Which 15 states recorded the highest average PM10 levels in 2021? Tabulate the results.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 15}}] " 7982,List the bottom 10 states with the lowest average PM2.5 in 2022 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 7983,Create a ranked table of the 20 best-performing citys by PM2.5 in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 7984,Identify the station exhibiting the third highest average PM10 during the Monsoon season of 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 7985,"On March 31, 2019, which city had the second-lowest 75th percentile of PM2.5?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 7986,Show the monthly average PM2.5 for Nandesari in 2024 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Nandesari') & (data['Timestamp'].dt.year == 2024)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Nandesari 2024', width=450, height=280) " 7987,Tabulate the monthly mean PM2.5 levels for Delhi during 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Delhi'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7988,Show a monthly bar chart of the number of days Telangana exceeded the WHO PM2.5 guideline (15 µg/m³) per year in 2021.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Telangana') & (data['Timestamp'].dt.year == 2021)] df = df.dropna(subset=['PM2.5']) df = df[df['PM2.5'] > 15] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['Timestamp'].nunique().reset_index() df.columns = ['Month','Days Exceeded'] month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_bar(color='crimson').encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Days Exceeded:Q', title='Days Exceeding WHO Limit'), tooltip=['MonthName:N','Days Exceeded:Q'] ).properties(title='Days Telangana Exceeded WHO PM2.5 Guideline per Month – 2021', width=500, height=300) return chart " 7989,Show the monthly average PM2.5 for Jaisalmer in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Jaisalmer') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Jaisalmer 2018', width=450, height=280) " 7990,Show the monthly average PM2.5 for Katihar in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Katihar') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Katihar 2018', width=450, height=280) " 7991,"Tabulate the distribution of PM2.5 per state in 2018 including mean, median, and std."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM2.5', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7992,"Which state (excluding UTs) possesses the 2nd smallest population among the top 3 most polluted states, determined by variance of PM10 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'var', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 3, 'ret': 'state'}}] " 7993,How many stations in Andhra Pradesh went above 90 µg/m³ of PM10 in the year 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'FILTER', 'params': {'field': 'PM10', 'comparison': 'gt', 'value': 90.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 7994,Plot the weekly average PM2.5 for Ramanagara in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ramanagara') & (data['Timestamp'].dt.year == 2023)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Ramanagara 2023', width=600, height=300) return chart " 7995,Report the city with the lowest 75th percentile of PM2.5 in April 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 7996,"Show the variability of PM10 across citys in 2021 using mean, median, and standard deviation."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'DESCRIBE', 'params': {'by': 'city', 'col': 'PM10', 'stats': ['mean', 'median', 'std', 'min', 'max']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7997,Show a pivot table of monthly average PM10 by state for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Delhi', 'Jharkhand', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Punjab', 'Rajasthan', 'Telangana', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7998,List citys with their PM2.5 violation count and rate (>60 µg/m³) in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 7999,"Create a grouped bar chart comparing the average PM2.5 for Mizoram, Uttar Pradesh, and Jharkhand across 2019, 2020, 2021, and 2022."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Mizoram', 'Uttar Pradesh', 'Jharkhand'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2019,2020,2021,2022]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2019–2022)', width=500, height=320) return chart " 8000,Identify the station with the highest median PM10 in September 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 8001,Tabulate the 20 citys with the least PM2.5 pollution in 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 8002,"Plot the yearly average PM2.5 trends for Nagaland, Uttarakhand, and Madhya Pradesh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Nagaland', 'Uttarakhand', 'Madhya Pradesh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Nagaland vs Uttarakhand vs Madhya Pradesh', width=550, height=320) return chart " 8003,Create a heatmap showing the average PM2.5 by month (x-axis) and year (y-axis) for Himachal Pradesh.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['state'] == 'Himachal Pradesh'].copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Year','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('Year:N', title='Year'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='Avg PM2.5'), tooltip=['Year:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Himachal Pradesh (Month × Year)', width=500, height=280) return chart " 8004,Identify the state with the highest 75th percentile of PM10 in October 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 8005,Show a cumulative area chart of PM2.5 readings for Ajmer across 2024.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Ajmer') & (data['Timestamp'].dt.year == 2024)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Ajmer 2024', width=600, height=300) return chart " 8006,Name the state with the lowest 75th percentile for PM2.5 in December 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 12}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 8007,"Plot the yearly average PM2.5 trends for West Bengal, Chandigarh, and Gujarat from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['West Bengal', 'Chandigarh', 'Gujarat'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: West Bengal vs Chandigarh vs Gujarat', width=550, height=320) return chart " 8008,Generate a table showing the 10 most polluted states based on mean PM10 for 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 8009,"Create a grouped bar chart comparing the average PM2.5 for Sikkim, Telangana, and Chandigarh across 2021, 2022, 2023, and 2024."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Sikkim', 'Telangana', 'Chandigarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2021,2022,2023,2024]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2021–2024)', width=500, height=320) return chart " 8010,Identify the station with the 3rd highest median PM2.5 in January 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 1}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 8011,"Between May 2019 and May 2020, which city saw the largest upswing in average PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 8012,Plot the weekly average PM2.5 for Bhiwani in 2021 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Bhiwani') & (data['Timestamp'].dt.year == 2021)].copy() df['Week'] = df['Timestamp'].dt.isocalendar().week.astype(int) df = df.groupby('Week')['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='purple').encode( x=alt.X('Week:O', title='Week of Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), tooltip=['Week:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Weekly Average PM2.5 – Bhiwani 2021', width=600, height=300) return chart " 8013,Generate a monthly average PM2.5 table for Madhya Pradesh for the year 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Madhya Pradesh'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 8014,Which station recorded the 3rd lowest 75th percentile of PM10 in the Post-Monsoon season of 2021?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 8015,Show the monthly average PM2.5 for Sri Ganganagar in 2018 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Sri Ganganagar') & (data['Timestamp'].dt.year == 2018)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Sri Ganganagar 2018', width=450, height=280) " 8016,Report which station possessed the 2nd highest median PM2.5 throughout the Monsoon season of 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'station'}}] " 8017,Report the state with the 3rd lowest median PM2.5 in October 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 10}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'state'}}] " 8018,Show how many times PM2.5 exceeded 100 µg/m³ per day across states in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 8019,Report which station documented the second most minimal stable PM10 level.," [{'op': 'AGG', 'params': {'by': 'station', 'fn': 'std', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 8020,Create a month-wise PM2.5 breakdown table across cities in Punjab for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Punjab'}}, { 'op': 'OR_FILTER', 'params': { 'field': 'city', 'values': [ 'Amritsar', 'Bathinda', 'Jalandhar', 'Khanna', 'Ludhiana', 'Mandi Gobindgarh', 'Patiala', 'Rupnagar']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 8021,List states with their average PM10 and area for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM10', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 8022,List the top 20 states by average PM10 in 2023 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 8023,Determine the station exhibiting the highest median PM2.5 in July 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 8024,Create a month-by-state breakdown table of mean PM2.5 for 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Arunachal Pradesh', 'Assam', 'Bihar', 'Chandigarh', 'Chhattisgarh', 'Delhi', 'Gujarat', 'Haryana', 'Himachal Pradesh', 'Jammu and Kashmir', 'Jharkhand', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Manipur', 'Meghalaya', 'Mizoram', 'Nagaland', 'Odisha', 'Puducherry', 'Punjab', 'Rajasthan', 'Tamil Nadu', 'Telangana', 'Tripura', 'Uttar Pradesh', 'Uttarakhand', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 8025,Which state noted the minimum average PM10 in the Monsoon season of 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 8026,Generate a table showing the 10 most polluted states based on mean PM10 for 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 8027,"Visualize the monthly average PM10 for Andhra Pradesh, Uttarakhand, and Haryana in 2018 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Uttarakhand', 'Haryana'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','state'])['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Month:O', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly PM10: Andhra Pradesh, Uttarakhand, UP – 2018', width=550, height=320) return chart " 8028,Which station recorded the peak median PM10 in the Post-Monsoon season of 2019?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'station'}}] " 8029,Identify the station exhibiting the third highest 75th percentile of PM2.5 during the Post-Monsoon season of 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 8030,How many stations in Jharkhand exceeded 45 µg/m³ of PM2.5 in the year 2017?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'FILTER', 'params': {'field': 'PM2.5', 'comparison': 'gt', 'value': 45.0}}, {'op': 'COUNT_UNIQUE', 'params': {'col': 'station'}}, {'op': 'SELECT', 'params': {'mode': 'scalar', 'ret': 'count'}}] " 8031,Determine the state with the 2nd highest 25th percentile of PM2.5 in March 2018.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 8032,"Identify the city with the second-lowest median PM10 on March 31, 2019."," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'city'}}] " 8033,Identify the city with the third-lowest mean PM10 concentration in November 2024.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'city'}}] " 8034,Show a heatmap of average PM2.5 for the top 6 most polluted states by month for 2018.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): top8 = data.groupby('state')['PM2.5'].mean().nlargest(6).index.tolist() df = data[(data['state'].isin(top8)) & (data['Timestamp'].dt.year == 2018)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['state','Month'])['PM2.5'].mean().reset_index().dropna() month_names = {1:'Jan',2:'Feb',3:'Mar',4:'Apr',5:'May',6:'Jun', 7:'Jul',8:'Aug',9:'Sep',10:'Oct',11:'Nov',12:'Dec'} df['MonthName'] = df['Month'].map(month_names) chart = alt.Chart(df).mark_rect().encode( x=alt.X('MonthName:N', sort=list(month_names.values()), title='Month'), y=alt.Y('state:N', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), title='PM2.5'), tooltip=['state:N','MonthName:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Heatmap – Top 6 Polluted States by Month (2018)', width=500, height=300) return chart " 8035,Generate a monthly average PM2.5 table for Pune for the year 2020.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Pune'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 8036,Show the monthly average PM2.5 for Rajsamand in 2017 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Rajsamand') & (data['Timestamp'].dt.year == 2017)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Rajsamand 2017', width=450, height=280) " 8037,Tabulate days with PM2.5 > 60 µg/m³ and exceedance percentage per city in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'city'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM2.5 > 60'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 8038,Identify the state where the 75th percentile of PM10 levels rose most significantly from September 2019 to September 2020.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 8039,"Plot a scatter chart of state-level average PM2.5 versus population for 2020, with point size representing area."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): pm = data[data['Timestamp'].dt.year == 2020].groupby('state')['PM2.5'].mean().reset_index().dropna() df = pm.merge(states_data, on='state') chart = alt.Chart(df).mark_point(filled=True, opacity=0.7).encode( x=alt.X('population:Q', title='Population', axis=alt.Axis(format='~s')), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), size=alt.Size('area (km2):Q', title='Area (km²)', scale=alt.Scale(range=[50,1000])), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('population:Q', format=','), 'area (km2):Q'] ).properties(title='PM2.5 vs Population (size=Area) – 2020', width=500, height=400) return chart " 8040,Show the monthly average PM10 trend for Kalyan from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Kalyan'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Kalyan (2017–2022)', width=600, height=300) return chart " 8041,"Plot the yearly average PM2.5 trends for Andhra Pradesh, Tripura, and Puducherry from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Andhra Pradesh', 'Tripura', 'Puducherry'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Andhra Pradesh vs Tripura vs Puducherry', width=550, height=320) return chart " 8042,Identify the state that recorded the 2nd highest median PM2.5 value in March 2023.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 8043,"Show the variability of PM10 across states in 2021 using mean, median, and standard deviation."," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'DESCRIBE', 'params': {'by': 'state', 'col': 'PM10', 'stats': ['mean', 'median', 'std']}}, {'op': 'DROPNA', 'params': {'col': 'std'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'mean'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 8044,Which city registered the 3rd highest average PM10 during February 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'city'}}] " 8045,Tabulate the monthly mean PM2.5 levels for Nashik during 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Nashik'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 8046,Which station had the 2nd lowest median PM2.5 in September 2024?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 9}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'station'}}] " 8047,Plot the rolling 30-day average PM2.5 for Gujarat in 2023 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Gujarat') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Gujarat 2023', width=600, height=300) " 8048,"Compare the monthly average PM2.5 of Kunjemura, Durgapur, and Mira-Bhayandar in 2023 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Kunjemura', 'Durgapur', 'Mira-Bhayandar'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2023)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Kunjemura vs Durgapur vs Mira-Bhayandar – 2023', width=550, height=320) return chart " 8049,Show a cumulative area chart of PM2.5 readings for Kanpur across 2019.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Kanpur') & (data['Timestamp'].dt.year == 2019)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Kanpur 2019', width=600, height=300) return chart " 8050,Show a monthly breakdown table of average PM2.5 for West Bengal in 2022.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'West Bengal'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 8051,Report which state possessed the 2nd highest 75th percentile of PM10 throughout the Post-Monsoon season of 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'autumn', 'months': [9, 10, 11]}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -2, 'ret': 'state'}}] " 8052,Which station registered the 3rd highest 25th percentile of PM10 during February 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 2}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'q25', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 8053,Which Indian state recorded the 2nd lowest PM2.5 levels for a single day in the past decade?," [{'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'count'}}, {'op': 'SORT', 'params': {'col': 'count', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'state'}}] " 8054,Show a cumulative area chart of PM2.5 readings for Nagaur across 2023.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Nagaur') & (data['Timestamp'].dt.year == 2023)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna().sort_values('Timestamp') df['Cumulative PM2.5'] = df['PM2.5'].cumsum() chart = alt.Chart(df).mark_area(color='teal', opacity=0.5).encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('Cumulative PM2\.5:Q', title='Cumulative PM2.5 (µg/m³)'), tooltip=[alt.Tooltip('Timestamp:T', format='%d %b'), alt.Tooltip('Cumulative PM2\.5:Q', format='.0f')] ).properties(title='Cumulative PM2.5 – Nagaur 2023', width=600, height=300) return chart " 8055,Tabulate daily PM2.5 exceedances (above 60 µg/m³) per state for 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM2.5', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 60}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM2.5 > 60', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM2.5', 'fn': 'count'}], 'by': 'state'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM2.5 > 60'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 8056,Which state had the highest average PM10 in August 2018?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 8}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'mean', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 8057,Show how average PM2.5 varied month by month for Maharashtra in 2018.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2018}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Maharashtra'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 8058,Which city exhibited the second smallest decrease in its 75th percentile PM2.5 levels between October and December of 2023?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2023}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 8059,Identify the state that recorded the highest 75th percentile of PM2.5 value in April 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 4}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -1, 'ret': 'state'}}] " 8060,"In July 2020, which city registered the lowest 75th percentile of PM10?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 7}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 8061,Generate a city × month cross-tab of mean PM2.5 for Andhra Pradesh in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Andhra Pradesh'}}, { 'op': 'OR_FILTER', 'params': {'field': 'city', 'values': ['Amaravati', 'Rajamahendravaram', 'Tirupati', 'Visakhapatnam']}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'city', 'value_col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 8062,"Plot the yearly average PM2.5 trends for Telangana, Sikkim, and Chhattisgarh from 2017 to 2024 on a single multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Telangana', 'Sikkim', 'Chhattisgarh'] df = data[data['state'].isin(states)].copy() df['Year'] = df['Timestamp'].dt.year df = df.groupby(['Year','state'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Year:O', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), tooltip=['state:N','Year:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Yearly PM2.5 Trends: Telangana vs Sikkim vs Chhattisgarh', width=550, height=320) return chart " 8063,Show the monthly average PM2.5 for Dhule in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Dhule') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Dhule 2019', width=450, height=280) " 8064,Show a monthly breakdown table of average PM2.5 for Rajasthan in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Rajasthan'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 8065,Show the monthly average PM2.5 for Boisar in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Boisar') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Boisar 2020', width=450, height=280) " 8066,Plot the top 13 states by average PM2.5 in 2022 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2022] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.nlargest(13, 'PM2.5') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Top 13 States by Average PM2.5 in 2022', width=500, height=300) return chart " 8067,"Create a grouped bar chart comparing the average PM2.5 for West Bengal, Sikkim, and Tamil Nadu across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['West Bengal', 'Sikkim', 'Tamil Nadu'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 8068,Report the state with the 2nd lowest 75th percentile of PM10 in March 2021.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 3}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'state'}}] " 8069,Show how many times PM10 exceeded 150 µg/m³ per day across citys in 2017.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2017}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 150}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 150', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'city'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 150'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 8070,Show the monthly average PM10 trend for Bhopal from 2017 to 2022 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['city'] == 'Bhopal'].copy() df = df[(df['Timestamp'].dt.year >= 2017) & (df['Timestamp'].dt.year <= 2022)] df['YearMonth'] = df['Timestamp'].dt.to_period('M').dt.to_timestamp() df = df.groupby('YearMonth')['PM10'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(color='darkorange').encode( x=alt.X('YearMonth:T', title='Month'), y=alt.Y('PM10:Q', title='Average PM10 (µg/m³)'), tooltip=[alt.Tooltip('YearMonth:T', title='Month', format='%b %Y'), alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Monthly Average PM10 Trend – Bhopal (2017–2022)', width=600, height=300) return chart " 8071,Show a scatter plot of total NCAP funding vs average PM2.5 (2023) per state.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): pm = data[data['Timestamp'].dt.year == 2023].groupby('state')['PM2.5'].mean().reset_index() funding = ncap_funding_data.groupby('state')['Total fund released'].sum().reset_index() df = pm.merge(funding, on='state').dropna() chart = alt.Chart(df).mark_point(filled=True, size=100).encode( x=alt.X('Total fund released:Q', title='Total NCAP Funding (Cr)'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 – 2023 (µg/m³)'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='reds'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f'), alt.Tooltip('Total fund released:Q', format='.1f')] ).properties(title='NCAP Funding vs Average PM2.5 by State (2023)', width=450, height=350) return chart " 8072,"In 2022, which state will rank with the third smallest reduction in median PM2.5 levels from October to December?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'OR_FILTER', 'params': {'field': 'month', 'values': [10, 12]}}, {'op': 'PIVOT_DIFF', 'params': {'index': 'state', 'col_source': 'month', 'month_a': 10, 'month_b': 12, 'new_col': 'diff'}}, {'op': 'DROPNA', 'params': {'col': 'diff'}}, {'op': 'SORT', 'params': {'col': 'diff', 'ascending': True}}] " 8073,Generate a monthly average PM2.5 table for Kota for the year 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Kota'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 8074,List states with their average PM2.5 and area for 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'comparison': 'gt', 'field': 'area (km2)', 'value': 0}}, {'op': 'DROPNA', 'params': {'col': 'area (km2)'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'SELECT_COLS', 'params': {'cols': ['state', 'PM2.5', 'area (km2)']}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'area (km2)': 'Area (km²)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 8075,Show a monthly breakdown table of average PM2.5 for Jodhpur in 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'city', 'value': 'Jodhpur'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'month', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'month'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'month': 'Month'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 8076,"In 2024, which week of the year was associated with the second-lowest median PM10 levels?"," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'week', 'fn': 'median', 'col': 'PM10'}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 1, 'ret': 'week'}}] " 8077,Which station had the 3rd highest median PM2.5 in November 2020?," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': -3, 'ret': 'station'}}] " 8078,Tabulate the yearly average PM2.5 trend for Tripura across all years.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Tripura'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 8079,"Which state (excluding Union Territories) has the 2nd minimum land area among the top 3 most polluted states, according to the 75th percentile of PM10 levels?"," [{'op': 'AGG', 'params': {'by': 'state', 'fn': 'q75', 'col': 'PM10'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'states'}}, {'op': 'FILTER_JOIN', 'params': {'field': 'isUnionTerritory', 'value': False}}, {'op': 'SORT', 'params': {'col': 'PM10', 'ascending': False}}, {'op': 'SELECT', 'params': {'mode': 'head', 'n': 3, 'ret': 'state'}}] " 8080,Determine the station with the 3rd lowest median PM2.5 in November 2019.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'FILTER', 'params': {'field': 'month', 'value': 11}}, {'op': 'AGG', 'params': {'by': 'station', 'fn': 'median', 'col': 'PM2.5'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 2, 'ret': 'station'}}] " 8081,Create a summary table ranking the top 20 states by PM2.5 concentration in 2024.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2024}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 8082,Plot the average PM2.5 across all states in February 2021 as a horizontal bar chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['Timestamp'].dt.year == 2021) & (data['Timestamp'].dt.month == 2)] df = df.groupby('state')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('PM2.5', ascending=False) chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM2\.5:Q', scale=alt.Scale(scheme='plasma'), legend=None), tooltip=['state:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Average PM2.5 by State – February 2021', width=500, height=400) return chart " 8083,Show the monthly average PM2.5 for Sri Ganganagar in 2019 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Sri Ganganagar') & (data['Timestamp'].dt.year == 2019)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Sri Ganganagar 2019', width=450, height=280) " 8084,Show the monthly average PM2.5 for Gandhinagar in 2020 as a line chart with area fill.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['city'] == 'Gandhinagar') & (data['Timestamp'].dt.year == 2020)] df['Month'] = df['Timestamp'].dt.month df = df.groupby('Month')['PM2.5'].mean().reset_index().dropna() area = alt.Chart(df).mark_area(opacity=0.3, color='teal').encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)') ) line = alt.Chart(df).mark_line(color='teal').encode( x='Month:O', y='PM2\.5:Q', tooltip=['Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ) return (area + line).properties(title='Monthly Average PM2.5 – Gandhinagar 2020', width=450, height=280) " 8085,List the bottom 20 states with the lowest average PM10 in 2019 as a table.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, {'op': 'AGG', 'params': {'by': 'state', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 20}}] " 8086,Create a summary table ranking the top 10 citys by PM2.5 concentration in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM2.5', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM2.5'}}, {'op': 'RENAME', 'params': {'map': {'PM2.5': 'Avg PM2.5 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] " 8087,"Create a grouped bar chart comparing the average PM2.5 for Tamil Nadu, Telangana, and Nagaland across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Telangana', 'Nagaland'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 8088,Plot the rolling 30-day average PM2.5 for Telangana in 2020 as a line chart.," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[(data['state'] == 'Telangana') & (data['Timestamp'].dt.year == 2020)] df = df.groupby('Timestamp')['PM2.5'].mean().reset_index().dropna() df = df.sort_values('Timestamp') df['Rolling30'] = df['PM2.5'].rolling(30, min_periods=1).mean() raw = alt.Chart(df).mark_line(opacity=0.3, color='steelblue').encode( x=alt.X('Timestamp:T', title='Date'), y=alt.Y('PM2\.5:Q', title='PM2.5 (µg/m³)') ) smooth = alt.Chart(df).mark_line(color='firebrick', strokeWidth=2).encode( x='Timestamp:T', y='Rolling30:Q', tooltip=[alt.Tooltip('Timestamp:T', format='%d %b %Y'), alt.Tooltip('Rolling30:Q', format='.1f', title='30-day avg')] ) return (raw + smooth).properties(title='30-Day Rolling Average PM2.5 – Telangana 2020', width=600, height=300) " 8089,Determine the city exhibiting the most minimal average PM2.5 over the Monsoon season of 2022.," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'FILTER', 'params': {'field': 'season', 'value': 'summer', 'months': [6, 7, 8]}}, {'op': 'AGG', 'params': {'by': 'city', 'fn': 'mean', 'col': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'PM2.5', 'ascending': True}}, {'op': 'SELECT', 'params': {'mode': 'rank', 'rank': 0, 'ret': 'city'}}] " 8090,Show PM10 exceedance count and rate (%) above 100 µg/m³ per state in 2021.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2021}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'ADD_FLAG', 'params': {'col': 'PM10', 'comparison': 'gt', 'new_col': 'exceeds', 'value': 100}}, { 'op': 'MULTI_AGG', 'params': { 'aggs': [ {'alias': 'Days PM10 > 100', 'col': 'exceeds', 'fn': 'sum'}, {'alias': 'Total Days', 'col': 'PM10', 'fn': 'count'}], 'by': 'state'}}, { 'op': 'ADD_RATE', 'params': { 'denominator': 'Total Days', 'new_col': 'Exceedance Rate (%)', 'numerator': 'Days PM10 > 100'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Days PM10 > 100'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 8091,Tabulate the yearly average PM10 trend for Delhi across all years.," [ {'op': 'FILTER', 'params': {'field': 'state', 'value': 'Delhi'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'AGG', 'params': {'by': 'year', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'SORT', 'params': {'ascending': True, 'col': 'year'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)', 'year': 'Year'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 8092,"Show the top 10 states by average PM10 in 2018 as a bar chart, sorted in descending order."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): df = data[data['Timestamp'].dt.year == 2018] df = df.groupby('state')['PM10'].mean().reset_index().dropna() df = df.nlargest(10, 'PM10') chart = alt.Chart(df).mark_bar().encode( x=alt.X('PM10:Q', title='Average PM10 (µg/m³)'), y=alt.Y('state:N', sort='-x', title='State'), color=alt.Color('PM10:Q', scale=alt.Scale(scheme='oranges'), legend=None), tooltip=['state:N', alt.Tooltip('PM10:Q', format='.1f')] ).properties(title='Top 10 States by Average PM10 in 2018', width=500, height=300) return chart " 8093,"Create a grouped bar chart comparing the average PM2.5 for Tamil Nadu, Chandigarh, and Mizoram across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Tamil Nadu', 'Chandigarh', 'Mizoram'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 8094,"Compare the monthly average PM2.5 of Saharsa, Solapur, and Fatehabad in 2020 as a multi-line chart."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): cities = ['Saharsa', 'Solapur', 'Fatehabad'] df = data[(data['city'].isin(cities)) & (data['Timestamp'].dt.year == 2020)].copy() df['Month'] = df['Timestamp'].dt.month df = df.groupby(['Month','city'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_line(point=True).encode( x=alt.X('Month:O', title='Month'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('city:N', title='City'), tooltip=['city:N','Month:O', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='Monthly PM2.5 Comparison: Saharsa vs Solapur vs Fatehabad – 2020', width=550, height=320) return chart " 8095,"Create a grouped bar chart comparing the average PM2.5 for Manipur, Jharkhand, and Delhi across 2017, 2018, 2019, and 2020."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Manipur', 'Jharkhand', 'Delhi'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2017,2018,2019,2020]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2017–2020)', width=500, height=320) return chart " 8096,"Create a grouped bar chart comparing the average PM2.5 for Delhi, Rajasthan, and Chandigarh across 2020, 2021, 2022, and 2023."," import pandas as pd import altair as alt def get_chart(data: pd.DataFrame, states_data: pd.DataFrame, ncap_funding_data: pd.DataFrame): states = ['Delhi', 'Rajasthan', 'Chandigarh'] df = data[(data['state'].isin(states)) & (data['Timestamp'].dt.year.isin([2020,2021,2022,2023]))] df = df.copy() df['Year'] = df['Timestamp'].dt.year.astype(str) df = df.groupby(['state','Year'])['PM2.5'].mean().reset_index().dropna() chart = alt.Chart(df).mark_bar().encode( x=alt.X('Year:N', title='Year'), y=alt.Y('PM2\.5:Q', title='Average PM2.5 (µg/m³)'), color=alt.Color('state:N', title='State'), xOffset='state:N', tooltip=['state:N','Year:N', alt.Tooltip('PM2\.5:Q', format='.1f')] ).properties(title='PM2.5 Grouped by State and Year (2020–2023)', width=500, height=320) return chart " 8097,Identify the state with the 5th lowest NCAP funding considering its 25th percentile of PM2.5 concentration in 2022 (FY 2021-22).," [{'op': 'FILTER', 'params': {'field': 'year', 'value': 2022}}, {'op': 'AGG', 'params': {'by': 'state', 'fn': 'q25', 'col': 'PM2.5'}}, {'op': 'JOIN', 'params': {'on': 'state', 'source': 'ncap'}}, {'op': 'COMPUTE', 'params': {'new_col': 'funding_per_pm', 'numerator': 'fy2022_fund', 'denominator': 'PM2.5'}}, {'op': 'SORT', 'params': {'col': 'funding_per_pm', 'ascending': True}}] " 8098,Show PM10 averages in a state × month matrix for 2019.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2019}}, { 'op': 'OR_FILTER', 'params': { 'field': 'state', 'values': [ 'Andhra Pradesh', 'Delhi', 'Haryana', 'Jharkhand', 'Karnataka', 'Kerala', 'Madhya Pradesh', 'Maharashtra', 'Odisha', 'Punjab', 'Rajasthan', 'Telangana', 'Uttar Pradesh', 'West Bengal']}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, { 'op': 'PIVOT', 'params': { 'add_row_summary': True, 'col_source': 'month', 'fn': 'mean', 'index': 'state', 'value_col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'Annual Avg'}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': -1}}] " 8099,Tabulate the 10 worst citys for average PM10 in 2020 sorted by pollution level.," [ {'op': 'FILTER', 'params': {'field': 'year', 'value': 2020}}, {'op': 'AGG', 'params': {'by': 'city', 'col': 'PM10', 'fn': 'mean'}}, {'op': 'DROPNA', 'params': {'col': 'PM10'}}, {'op': 'SORT', 'params': {'ascending': False, 'col': 'PM10'}}, {'op': 'RENAME', 'params': {'map': {'PM10': 'Avg PM10 (µg/m³)'}}}, {'op': 'SELECT', 'params': {'mode': 'table', 'n': 10}}] "