Melting a List in column to multiple rows in dataframe - python-3.x

What I am trying to do is, I have a list of star_cast and list of a genre for a single movie entity. I want to melt this list down as a repeating entity in data frame so that I can store it in a database system.
director_name = ['chris','guy','bryan']
genre = [['mystery','thriller'],['comedy','crime'],['action','adventure','sci -fi']]
gross_vlaue = [2544,236544,265888]
imdb_ratings = [8.5,5.4,3.2]
metascores = [80.0,55.0,64.0]
movie_names = ['memento','snatch','x-men']
runtime = [113.0,102.0,104.0]
star_cast = [['abc','ced','gef'],['aaa','abc'],['act','cst','gst','hhs']]
votes = [200,2150,2350]
sample_data = pd.DataFrame({"movie_names":movie_names,
"imdb_ratings":imdb_ratings,
"metscores":metascores,
"votes":votes,
"runtime":runtime,
"genre":genre,
"director_name": director_name,
"star_cast": star_cast,
"gross_value":gross_vlaue
})
The above will generate a Data Frame sample I have.
director_name = ['chris','chris','chris','chris','chris','chris','guy','guy','guy','guy','bryan','bryan','bryan','bryan','bryan','bryan','bryan','bryan','bryan','bryan','bryan','bryan']
genre = ['mystery','thriller','mystery','thriller','mystery','thriller','comedy','crime','comedy','crime','action','adventure','sci -fi','action','adventure','sci -fi','action','adventure','sci -fi','action','adventure','sci -fi']
gross_vlaue = [2544,2544,2544,2544,2544,2544,236544,236544,236544,236544,265888,265888,265888,265888,265888,265888,265888,265888,265888,265888,265888,265888]
imdb_ratings = [8.5,8.5,8.5,8.5,8.5,8.5,5.4,5.4,5.4,5.4,3.2,3.2,3.2,3.2,3.2,3.2,3.2,3.2,3.2,3.2,3.2,3.2]
metascores = [80.0,80.0,80.0,80.0,80.0,80.0,55.0,55.0,55.0,55.0,64.0,64.0,64.0,64.0,64.0,64.0,64.0,64.0,64.0,64.0,64.0,64.0]
movie_names = ['memento','memento','memento','memento','memento','memento','snatch','snatch','snatch','snatch','x-men','x-men','x-men','x-men','x-men','x-men','x-men','x-men','x-men','x-men','x-men','x-men']
runtime = [113.0,113.0,113.0,113.0,113.0,113.0,102.0,102.0,102.0,102.0,104.0,104.0,104.0,104.0,104.0,104.0,104.0,104.0,104.0,104.0,104.0,104.0]
star_cast = ['abc','ced','gef','abc','ced','gef','aaa','abc','aaa','abc','act','cst','gst','hhs','act','cst','gst','hhs','act','cst','gst','hhs']
votes = [200,200,200,200,200,200,2150,2150,2150,2150,2350,2350,2350,2350,2350,2350,2350,2350,2350,2350,2350,2350]
sample_result = pd.DataFrame({"movie_names":movie_names,
"imdb_ratings":imdb_ratings,
"metscores":metascores,
"votes":votes,
"runtime":runtime,
"genre":genre,
"director_name": director_name,
"star_cast": star_cast,
"gross_value":gross_vlaue
})
This will generate the format I want to conver my data into.
I tried using melt() but no luck there. Please help, as to how it can be achieved in an effective way. My dataset is fairly large, using for loops will be very slow. Is there any other way around solving this?

Related

Featuretools - LookupError: Time index not found in dataframe

I have a input dataframe which I have split up into 3 entities based on the attributes. When I try to generate features using featuretools I get the above mentioned error
input dataframe in_df = ['UniqueID', 'disbursed_amount', 'asset_cost', 'ltv', 'branch_id', 'supplier_id', 'manufacturer_id', 'Current_pincode_ID', 'Date.of.Birth', 'Employment.Type', 'DisbursalDate', 'State_ID', 'Employee_code_ID', 'MobileNo_Avl_Flag', 'Aadhar_flag', 'PAN_flag', 'VoterID_flag', 'Driving_flag', 'Passport_flag', 'PERFORM_CNS.SCORE', 'PERFORM_CNS.SCORE.DESCRIPTION', 'PRI.NO.OF.ACCTS', 'PRI.ACTIVE.ACCTS', 'PRI.OVERDUE.ACCTS', 'PRI.CURRENT.BALANCE', 'PRI.SANCTIONED.AMOUNT', 'PRI.DISBURSED.AMOUNT', 'SEC.NO.OF.ACCTS', 'SEC.ACTIVE.ACCTS', 'SEC.OVERDUE.ACCTS', 'SEC.CURRENT.BALANCE', 'SEC.SANCTIONED.AMOUNT', 'SEC.DISBURSED.AMOUNT', 'PRIMARY.INSTAL.AMT', 'SEC.INSTAL.AMT', 'NEW.ACCTS.IN.LAST.SIX.MONTHS', 'DELINQUENT.ACCTS.IN.LAST.SIX.MONTHS', 'AVERAGE.ACCT.AGE', 'CREDIT.HISTORY.LENGTH', 'NO.OF_INQUIRIES', 'loan_default']
I have split this up into 3 entities based on the information available on the dataset:
cust_cols = ['UniqueID','Current_pincode_ID', 'Employment.Type', 'State_ID', 'MobileNo_Avl_Flag', 'branch_id',
'Aadhar_flag', 'PAN_flag', 'VoterID_flag', 'Driving_flag', 'Passport_flag', 'asset_cost', 'Date.of.Birth']
customers_df = df_raw_train[cust_cols]
loan_info_cols = ['UniqueID', 'disbursed_amount', 'asset_cost', 'ltv', 'branch_id', 'supplier_id', 'manufacturer_id',
'Employee_code_ID', 'loan_default', 'DisbursalDate']
loan_info_df = df_raw_train[loan_info_cols]
bureau_cols = ['UniqueID','PERFORM_CNS.SCORE', 'PERFORM_CNS.SCORE.DESCRIPTION', 'PRI.NO.OF.ACCTS', 'PRI.ACTIVE.ACCTS',
'PRI.OVERDUE.ACCTS', 'PRI.CURRENT.BALANCE', 'PRI.SANCTIONED.AMOUNT', 'PRI.DISBURSED.AMOUNT',
'SEC.NO.OF.ACCTS', 'SEC.ACTIVE.ACCTS', 'SEC.OVERDUE.ACCTS', 'SEC.CURRENT.BALANCE', 'SEC.SANCTIONED.AMOUNT',
'SEC.DISBURSED.AMOUNT', 'PRIMARY.INSTAL.AMT', 'SEC.INSTAL.AMT', 'NEW.ACCTS.IN.LAST.SIX.MONTHS',
'DELINQUENT.ACCTS.IN.LAST.SIX.MONTHS', 'NO.OF_INQUIRIES']
bureau_df = df_raw_train[bureau_cols]
customers_df.set_index(['UniqueID', 'branch_id'],inplace = True, append = True)
loan_info_df.set_index(['UniqueID', 'branch_id'], inplace = True, append = True)
entities = {"customers" : (customers_df, "UniqueID", "branch_id"), "loans" : (loan_info_df, "UniqueID", "branch_id"),
"bureau" : (bureau_df, "UniqueID")
}
relationships = [("loans", "UniqueID", "bureau", "UniqueID"),
("customers", "branch_id", "loans", "branch_id")]
feature_matrix_customers, features_defs = ft.dfs(entities=entities, relationships=relationships, target_entity="customers")
I am getting the error" LookupError: Time index not found in dataframe
Can someone help on why is there an error as the featuretools docs does not mention any need to specify the timeindex?
Got this resolved by creating entity sets from dataframes.

Value error in assigning to dataframe

I am assigning different data to one dataframe. And I had the following
ValueError: If using all scalar values, you must pass an index
I follow the question post by other Here
But it did not work out.
The following is my code. All you have to do is copy and paste the code to IDE.
import pandas as pd
import numpy as np
#Loading Team performance Data (ExpG (Home away)) For and against
epl_1718 = pd.read_csv("http://www.football-data.co.uk/mmz4281/1718/E0.csv")
epl_1718 = epl_1718[['HomeTeam','AwayTeam','FTHG','FTAG']]
epl_1718 = epl_1718.rename(columns={'FTHG': 'HomeGoals', 'FTAG': 'AwayGoals'})
Home_goal_avg = epl_1718['HomeGoals'].mean()
Away_goal_avg = epl_1718['AwayGoals'].mean()
Home_team_goals = epl_1718.groupby(['HomeTeam'])['HomeGoals'].sum()
Home_count = epl_1718.groupby(['HomeTeam'])['HomeTeam'].count()
Home_team_avg_goal = Home_team_goals/Home_count
Home_team_concede = epl_1718.groupby(['HomeTeam'])['AwayGoals'].sum()
EPL_Home_average_score = epl_1718['HomeGoals'].mean()
EPL_Home_average_conc = epl_1718['HomeGoals'].mean()
Home_team_avg_conc = Home_team_concede/Home_count
Away_team_goals = epl_1718.groupby(['AwayTeam'])['AwayGoals'].sum()
Away_count = epl_1718.groupby(['AwayTeam'])['AwayTeam'].count()
Away_team_avg_goal = Away_team_goals/Away_count
Away_team_concede = epl_1718.groupby(['AwayTeam'])['HomeGoals'].sum()
EPL_Away_average_score = epl_1718['AwayGoals'].mean()
EPL_Away_average_conc = epl_1718['HomeGoals'].mean()
Away_team_avg_conc = Away_team_concede/Away_count
Home_attk_sth = Home_team_avg_goal/EPL_Home_average_score
Home_attk_sth = Home_attk_sth.sort_index().reset_index()
Home_def_sth = Home_team_avg_conc/EPL_Home_average_conc
Home_def_sth = Home_def_sth .sort_index().reset_index()
Away_attk_sth = Away_team_avg_goal/EPL_Away_average_score
Away_attk_sth = Away_attk_sth .sort_index().reset_index()
Away_def_sth = Away_team_avg_conc/EPL_Away_average_conc
Away_def_sth = Away_def_sth.sort_index().reset_index()
Home_def_sth
HomeTeam = epl_1718['HomeTeam'].drop_duplicates().sort_index().reset_index().set_index('HomeTeam')
AwayTeam = epl_1718['AwayTeam'].drop_duplicates().sort_index().reset_index().sort_values(['AwayTeam']).set_index(['AwayTeam'])
#HomeTeam = HomeTeam.sort_index().reset_index()
Team = HomeTeam.append(AwayTeam).drop_duplicates()
Data = pd.DataFrame({"Team":Team,
"Home_attkacking":Home_attk_sth,
"Home_def": Home_def_sth,
"Away_Attacking":Away_attk_sth,
"Away_def":Away_def_sth,
"EPL_Home_avg_score":EPL_Home_average_score,
"EPL_Home_average_conc":EPL_Home_average_conc,
"EPL_Away_average_score":EPL_Away_average_score,
"EPL_Away_average_conc":EPL_Away_average_conc},
columns =['Team','Home_attacking','Home_def','Away_attacking','Away_def',
'EPL_Home_avg_score','EPL_Home_avg_conc','EPL_Away_avg_score','EPL_Away_average_conc'])
In this code, what I am trying to do is to get average goal score per team per game, average goals conceded per team per game.
And then I am calculating other performance factors such as attacking strength, defensive strenght etc.
I have to paste the code as if i use example, creating data frame would work.
Thanks for understanding.
Thanks in advance for the advice too.
The format (or the columns) of final data frame will look like as follow:
Team Home Attacking Home Defensive Away attacking away defensive
and so on as mentioned in the data frame.
It means, there will be only 20 teams under team columns
The shape of dataframe will be ( 20,9)
Regards,
Zep
Here main idea is remove reset_index for Series with index by teams, so variable Team is not necessary and is created as last step by reset_index. Also be carefull with columns names in DataFrame constructor, if there are changed like EPL_Home_average_conc in dictionary and then EPL_Home_avg_conc get NaNs columns:
Home_team_goals = epl_1718.groupby(['HomeTeam'])['HomeGoals'].sum()
Home_count = epl_1718.groupby(['HomeTeam'])['HomeTeam'].count()
Home_team_avg_goal = Home_team_goals/Home_count
Home_team_concede = epl_1718.groupby(['HomeTeam'])['AwayGoals'].sum()
EPL_Home_average_score = epl_1718['HomeGoals'].mean()
EPL_Home_average_conc = epl_1718['HomeGoals'].mean()
Home_team_avg_conc = Home_team_concede/Home_count
Away_team_goals = epl_1718.groupby(['AwayTeam'])['AwayGoals'].sum()
Away_count = epl_1718.groupby(['AwayTeam'])['AwayTeam'].count()
Away_team_avg_goal = Away_team_goals/Away_count
Away_team_concede = epl_1718.groupby(['AwayTeam'])['HomeGoals'].sum()
EPL_Away_average_score = epl_1718['AwayGoals'].mean()
EPL_Away_average_conc = epl_1718['HomeGoals'].mean()
Away_team_avg_conc = Away_team_concede/Away_count
#removed reset_index
Home_attk_sth = Home_team_avg_goal/EPL_Home_average_score
Home_attk_sth = Home_attk_sth.sort_index()
Home_def_sth = Home_team_avg_conc/EPL_Home_average_conc
Home_def_sth = Home_def_sth .sort_index()
Away_attk_sth = Away_team_avg_goal/EPL_Away_average_score
Away_attk_sth = Away_attk_sth .sort_index()
Away_def_sth = Away_team_avg_conc/EPL_Away_average_conc
Away_def_sth = Away_def_sth.sort_index()
Data = pd.DataFrame({"Home_attacking":Home_attk_sth,
"Home_def": Home_def_sth,
"Away_attacking":Away_attk_sth,
"Away_def":Away_def_sth,
"EPL_Home_average_score":EPL_Home_average_score,
"EPL_Home_average_conc":EPL_Home_average_conc,
"EPL_Away_average_score":EPL_Away_average_score,
"EPL_Away_average_conc":EPL_Away_average_conc},
columns =['Home_attacking','Home_def','Away_attacking','Away_def',
'EPL_Home_average_score','EPL_Home_average_conc',
'EPL_Away_average_score','EPL_Away_average_conc'])
#column from index
Data = Data.rename_axis('Team').reset_index()
print (Data)

Merging data frames by date in python

I have a 8 dataframes which contain date and a stock return. They are of different length (some 5 years, some 8, etc.). Some of them are randomly non-defined (depends on what the user do before - which countries she chooses). What I want to do, is to merge by date only those dataframes which have data and to find correlation between the columns. Please, advise me this issue. I use
the command below to merge data frames, but because some of them do not exist (this is random) I can not merge them.
merged =pd.concat([germany_return, france_return, usa_return, hongkong_return, india_return, japan_return, england_return, china_return], axis=1)
Below I present the last part of the code:
#Define Stock Price colum
stock_germany = data_germany['Settle']
stock_france = data_france['Settle']
stock_usa = data_usa['Value']
stock_hongkong = data_hongkong['Last Traded']
stock_india = data_india['Close']
stock_japan = data_india['Close']
stock_england = data_england['Settle']
stock_china = data_china['Value']
#Calculate Monthly returns
germany_return = stock_germany.pct_change(21)
france_return = stock_france.pct_change(21)
usa_return = stock_usa.pct_change(21)
hongkong_return = stock_hongkong.pct_change(21)
india_return = stock_india.pct_change(21)
japan_return = stock_japan.pct_change(21)
england_return = stock_england.pct_change(21)
china_return = stock_china.pct_change(21)
merged =pd.concat([germany_return, france_return, usa_return, hongkong_return, india_return, japan_return, england_return, china_return], axis=1)

(Python/Pygame) Best way to load a LOT of images at the same time?

I have a function to load sounds, but not one for loading images. This is how my image loading is layed out currently:
if os.path.exists("themes/voltorb"):
vgui = pygame.image.load("themes/voltorb/gui.png")
voptions = pygame.image.load("themes/voltorb/options.png")
vachievements = pygame.image.load("themes/voltorb/achievements.png")
voverlay = pygame.image.load("themes/voltorb/overlay.png")
vconfirm = pygame.image.load("themes/voltorb/confirm.png")
vboom = pygame.mixer.Sound("themes/voltorb/boom.mp3")
vcoin = pygame.mixer.Sound("themes/voltorb/coin.mp3")
vtheme = {"gui":vgui,"options":voptions,"achievements":vachievements,"overlay":voverlay,"confirm":vconfirm,"coin":vcoin,"boom":vboom,"music":vmusic}
themedb.update({"v":vtheme})
if os.path.exists("themes/fluttershy"):
fcoin = pygame.mixer.Sound("themes/fluttershy/coin.mp3")
fgui = pygame.image.load("themes/fluttershy/gui.png")
foptions = pygame.image.load("themes/fluttershy/options.png")
fachievements = pygame.image.load("themes/fluttershy/achievements.png")
foverlay = pygame.image.load("themes/fluttershy/overlay.png")
ftheme = {"gui":fgui,"options":foptions,"achievements":fachievements,"overlay":foverlay,"confirm":fconfirm,"coin":vcoin,"boom":vboom,"music":vmusic}
themedb.update({"f":ftheme})
if os.path.exists("themes/mario"):
mgui = pygame.image.load("themes/mario/gui.png")
moptions = pygame.image.load("themes/mario/options.png")
machievements = pygame.image.load("themes/mario/achievements.png")
moverlay = pygame.image.load("themes/mario/overlay.png")
mtheme = {"gui":mgui,"options":moptions,"achievements":machievements,"overlay":moverlay,"confirm":mconfirm,"coin":vcoin,"boom":vboom,"music":vmusic}
themedb.update({"m":mtheme})
if os.path.exists("%appdata%/KWScripts/Voltorb/themes/secret1"):
s1gui = pygame.image.load("%appdata%/KWScripts/Voltorb/themes/secret1/gui.png")
s1options = pygame.image.load("%appdata%/KWScripts/Voltorb/themes/secret1/options.png")
s1achievements = pygame.image.load("%appdata%/KWScripts/Voltorb/themes/secret1/achievements.png")
s1overlay = pygame.image.load("%appdata%/KWScripts/Voltorb/themes/secret1/overlay.png")
s1theme = {"gui":s1gui,"options":s1options,"achievements":s1achievements,"overlay":s1overlay,"confirm":s1confirm,"coin":vcoin,"boom":vboom,"music":vmusic}
themedb.update({"s1":s1theme})
if os.path.exists("%appdata%/KWScripts/Voltorb/themes/secret2"):
s2gui = pygame.image.load("%appdata%/KWScripts/Voltorb/themes/secret2/gui.png")
s2options = pygame.image.load("%appdata%/KWScripts/Voltorb/themes/secret2/options.png")
s2achievements = pygame.image.load("%appdata%/KWScripts/Voltorb/themes/secret2/achievements.png")
s2overlay = pygame.image.load("%appdata%/KWScripts/Voltorb/themes/secret2/overlay.png")
s2theme = {"gui":s2gui,"options":s2options,"achievements":s2achievements,"overlay":s2overlay,"confirm":s2confirm,"coin":s2coin,"boom":s2boom,"music":s2music}
themedb.update({"s2":s2theme})
if os.path.exists("%appdata%/KWScripts/Voltorb/themes/secret3"):
s3gui = pygame.image.load("%appdata%/KWScripts/Voltorb/themes/secret3/gui.png")
s3options = pygame.image.load("%appdata%/KWScripts/Voltorb/themes/secret3/options.png")
s3achievements = pygame.image.load("%appdata%/KWScripts/Voltorb/themes/secret3/achievements.png")
s3overlay = pygame.image.load("%appdata%/KWScripts/Voltorb/themes/secret3/overlay.png")
s3theme = {"gui":s3gui,"options":s3options,"achievements":s3achievements,"overlay":s3overlay,"confirm":s3confirm,"coin":s3coin,"boom":s3boom,"music":s3music}
themedb.update({"s3":s3theme})
I'm not sure if there's any easy way to do this, but I have the most difficult way typed already. If anyone has an idea of how to shorten this, then thanks!
Take all your images and put them in a dict, where the key is the variable you were using, and the value is the path:
vimages = {'vgui': "themes/voltorb/gui.png", 'voptions': "themes/voltorb/options.png", 'vachievements': "themes/voltorb/achievements.png"} # and so on...
Then, iterate through vimages, checking for the existence of each individual file, then calling pygame.image.load() on it, and store the result in your already-existing dict (vtheme, in this case).
This way, you don't need to keep writing out pygame.image.load() over and over again.

What is the maximum number of parameters I can use in a subsonic 2.1+ 'IN' statment?

I think i am hitting a limit. I have two IN statements in the SQL generated by subsonic. Or am I hitting the varchar ( 8000 ) limit?
When I send i fewer parameters, the statement returns results, when I send in more, the result set comes back blank.
Below is what I am catching in SQL Profiler:
exec sp_executesql N'/* GetDataSet() */
SELECT
[dbo].[QuoteDBAll].[quote_id],
[dbo].[conn_quote_result].[product_category_name],
part_number,
quote_result_special_price * ( quote_result_quantity + quote_result_quantity_spare) AS Total,
company_name
FROM [dbo].[QuoteDBAll]
INNER JOIN [dbo].[conn_quote_result]
ON [dbo].[QuoteDBAll].[quote_number] = [dbo].[conn_quote_result].[quote_number]
INNER JOIN [dbo].[conn_company]
ON [dbo].[QuoteDBAll].[company_id] = [dbo].[conn_company].[company_id]
GROUP BY [dbo].[QuoteDBAll].[quote_id],
[dbo].[conn_quote_result].[product_category_name],
[dbo].[conn_quote_result].[part_number],
[dbo].[conn_quote_result].[quote_result_quantity],
[dbo].[conn_quote_result].[quote_result_quantity_spare],
[dbo].[conn_quote_result].[quote_result_special_price],
[dbo].[QuoteDBAll].[quote_status_id],
company_name
HAVING (quote_status_id = #quote_status_id0)
AND (company_name IN
(#in1,#in2,#in3,#in4,#in5,#in6,#in7,#in8,#in9,#in10,
#in11,#in12,#in13,#in14,#in15,#in16,#in17,#in18,#in19,#in20,
#in21,#in22,#in23,#in24,#in25,#in26,#in27,#in28,#in29,#in30,#in31))
AND ([dbo].[conn_quote_result].[product_category_name] IN
(#in1,#in2,#in3,#in4,#in5,#in6,#in7,#in8,#in9,#in10,
#in11,#in12,#in13,#in14,#in15,#in16,#in17,#in18,#in19,#in20,
#in21,#in22,#in23,#in24,#in25,#in26,#in27,#in28,#in29,#in30,
#in31,#in32,#in33,#in34,#in35,#in36,#in37,#in38))',
N'#quote_status_id0 varchar(1),### varchar(8000),#in1 varchar(15),#in2 varchar(22),
#in3 varchar(21),#in4 varchar(13),#in5 varchar(5),#in6 varchar(6),#in7 varchar(13),
#in8 varchar(25),#in9 varchar(8),#in10 varchar(14),#in11 varchar(9),#in12 varchar(11),
#in13 varchar(16),#in14 varchar(12),#in15 varchar(14),#in16 varchar(16),
#in17 varchar(11),#in18 varchar(15),#in19 varchar(6),#in20 varchar(12),
#in21 varchar(12),#in22 varchar(10),#in23 varchar(15),#in24 varchar(15),
#in25 varchar(15),#in26 varchar(11),#in27 varchar(16),#in28 varchar(20),
#in29 varchar(6),#in30 varchar(16),#in31 varchar(17),#in32 varchar(11),
#in33 varchar(18),#in34 varchar(23),#in35 varchar(14),#in36 varchar(19),
#in37 varchar(12),#in38 varchar(14)',
#quote_status_id0 = '1', ### = NULL, #in1 = 'Widget1', #in2 = 'Widget2',
#in3 = 'Widget3', #in4 = 'Widget4', #in5 = 'Widget5', #in6 = 'Widget6', #in7 = 'Widget7',
#in8 = 'Widget7', #in9 = 'Widget7', #in10 = 'Widget8', #in11 = 'Widget9', #in12 = 'Widget10',
#in13 = 'Widget11', #in14 = 'Widget12', #in15 = 'Widget13', #in16 = 'Widget14',
#in17 = 'Widget15', #in18 = 'Widget16', #in19 = 'Widget17', #in20 = 'Widget18',
#in21 = 'DWidget19', #in22 = 'Widget20', #in23 = 'Widget21', #in24 = 'Widget22',
#in25 = 'Widget23', #in26 = 'Widget24', #in27 = 'Widget25', #in28 = 'Widget26',
#in29 = 'Widget27', #in30 = 'Widget28', #in31 = 'Widget29', #in32 = 'Widget30',
#in33 = 'Widget31', #in34 = 'Widget32', #in35 = 'Widget33', #in36 = 'Widget34',
#in37 = 'Widget35', #in38 = 'Widget36'
If you have to ask this question, you should probably use a temp table. Insert your parameters to the temp table and either JOIN your main table to it, or use an IN() predicate against a subquery of the temp table.
In most cases when you have 30+ parameters in an IN() predicate, you're going to find that you need more periodically. Using a temp table allows you to keep increasing the number of values without having to rewrite your query.
And it avoids any possibility of hitting a limit of the number of parameters or a limit on query length.

Resources