solving nested renamer is not supported with dynamic arguments

Advertisements if cat_vars: df["static_cat"] = ( df.groupby("group_col") .agg({i: "first" for i in cat_vars}) .values.tolist() ) Error: packages\pandas\core\groupby\generic.py in aggregate(self, func, *args, **kwargs) 926 func = _maybe_mangle_lambdas(func) 927 –> 928 result, how = self._aggregate(func, *args, **kwargs) 929 if how is None: 930 return result packages\pandas\core\base.py in _aggregate(self, arg, *args, **kwargs) 355 obj.columns.intersection(keys) 356 ) != len(keys):… Read More solving nested renamer is not supported with dynamic arguments

How to groupby multiple columns in pandas based on name?

Advertisements I want to create a new dataframe with columns calculated as means of columns with similar names from this dataframe: B6_i B6_ii B6_iii … BXD80_i BXD80_ii BXD81_i data … Cd38 0.598864 -0.225322 0.306926 … -0.312190 0.281429 0.424752 Trim21 1.947399 2.920681 2.805861 … 1.469634 2.103585 0.827487 Kpnb1 -0.458240 -0.417507 -0.441522 … -0.314313 -0.153509 -0.095863 Six1… Read More How to groupby multiple columns in pandas based on name?

RegEx- first character should not contain special characters and subsequent characters should not contain few special characters

Advertisements I have a specific validation scenario. The first character of the string should not contain special characters which I can achieve using /^[!@#$%^&*()_+\-=\[\]{};’:"\\|,.<>\/?]+$/, but subsequent characters should not contain specific special characters, which are !@$%^*+=\[\]{};:\\|<>? I tried that using regex /^[!@#$%^&*()_+\-=\[\]{};’:"\\|,.<>\/?][!@$%^*+=\[\]{};:\\|<>?]+$/ and negating the result but its not working. I want to allow all… Read More RegEx- first character should not contain special characters and subsequent characters should not contain few special characters

How can I remove a specific role from everyone that has it in Discord.js v13

Advertisements I want my bot to remove a specific role from everyone that has it when a message is sent in a channel client.on(‘messageCreate’, async message => { if(message.channel.id === ‘954375143965216869’){ //counting message.guild.roles.get(‘944674567811645472′).members.map(m=>m.member.id).delete(); } }) I’m using discord.js v13 and node.js v16.4.2 >Solution : This should work, it’ll fetch all the members in the guild… Read More How can I remove a specific role from everyone that has it in Discord.js v13

(Python) Transform dataframe: parse rows if more than one value is given and add to corresponding given rows of dataframe

Advertisements Sample dataset I have looks like this: Language Count Russian 1000 English 1500 Spanish 500 Arabic,Russian, English, Spanish 2 Arabic, English 15 I want it to transform so that the result looks like this: Language Count Russian 1002 English 1517 Spanish 502 Arabic 17 So what happened is that, I parsed rows that contained… Read More (Python) Transform dataframe: parse rows if more than one value is given and add to corresponding given rows of dataframe