Python Forum
Search Results
Post Author Forum Replies Views Posted [asc]
    Thread: Add a row per group and depending of values
Post: Add a row per group and depending of values

Hello, I have this dataframe (see capture 1). And I 'd like to add one row per group of the Var_1 such as I have a new value Var_2=3. And the value in var_4 would be equal to (Var_5 value of the gro...
Menthix General Coding Help 0 508 Mar-20-2023, 11:20 AM
    Thread: plt.bar on two different Y axis
Post: plt.bar on two different Y axis

Hello, I have this data set : Age Var 1 Var 2 17-31 ans 19565 11178 32-44 ans 19757 24011 45-54 ans 23885 45895 55-64 ans 29622 6...
Menthix General Coding Help 1 925 Jun-20-2022, 03:32 PM
    Thread: Check if a value is present in each group
Post: RE: Check if a value is present in each group

(May-16-2022, 10:24 AM)Pedroski55 Wrote: Haha, what a wonderful thing the Internet is: instant answers I could never have got to this on my own! df['Result'] = df['Type'].isin(df.loc[df['Var1'].eq...
Menthix General Coding Help 8 2,698 May-16-2022, 12:25 PM
    Thread: Check if a value is present in each group
Post: RE: Check if a value is present in each group

(May-16-2022, 01:01 AM)Pedroski55 Wrote: Caveat: I practically never use pandas, so my answer may not be too great. I recently created some online polls to keep the students occupied. The csv file ...
Menthix General Coding Help 8 2,698 May-16-2022, 08:27 AM
    Thread: Check if a value is present in each group
Post: RE: Check if a value is present in each group

I tried two things : 1) df['Result'] = df.groupby(df['ID']).apply(lambda x: np.where(df['Var1']==3,0,1)) It keeps running, but i'm pretty sure it won't work 2) df['Result'] = df['Var1'].groupby(df['...
Menthix General Coding Help 8 2,698 May-16-2022, 08:03 AM
    Thread: Check if a value is present in each group
Post: RE: Check if a value is present in each group

Any idea ? Thank you by advance for your responses
Menthix General Coding Help 8 2,698 May-15-2022, 10:39 PM
    Thread: Check if a value is present in each group
Post: RE: Check if a value is present in each group

I havn't tried much... I 'd like to combine df.groupby('ID') and np.where(df['V1']==3, 1, 0) but I don't think it's possible...
Menthix General Coding Help 8 2,698 May-13-2022, 03:58 PM
    Thread: Check if a value is present in each group
Post: Check if a value is present in each group

Hi, I have a dataframe with two columns : an 'ID' column and a column 'V1' with different values between 1 and 3. I'd like to mark each ID with 1 if value 3 is present for this group and 0 otherwise...
Menthix General Coding Help 8 2,698 May-13-2022, 03:42 PM
    Thread: Plot several graphs on the same row
Post: Plot several graphs on the same row

Hello, Here is a code that I use to plot multiple boxplots at the same time : for year in [2016,2017,2018,2019,2020,2021] : plt.figure(figsize=(5,10)) sns.boxplot( data=CR, x...
Menthix General Coding Help 1 1,031 Mar-18-2022, 09:19 AM
    Thread: NaN when creating a new column...
Post: RE: NaN when creating a new column...

(Mar-14-2022, 05:36 PM)menator01 Wrote: This link may help https://stackoverflow.com/questions/2023...das-series Sorry but it doesn't help. It doesn't match with my issue.
Menthix General Coding Help 2 1,172 Mar-15-2022, 08:40 AM
    Thread: NaN when creating a new column...
Post: NaN when creating a new column...

Hi, I'm trying to create a new column on a dataframe which counts the number of distinct elements of a variable (VAR2) according to the values of another (VAR1). Like this : df.groupby('VAR1')['VAR2'...
Menthix General Coding Help 2 1,172 Mar-14-2022, 05:32 PM
    Thread: .format function
Post: RE: .format function

But i want to create 3 different DataFrame, exactly like the example i gave : Table_2016=pd.read_pickle("./0_DATA/0_raw/Table_PM_2016.pkl") Table_2017=pd.read_pickle("./0_DATA/0_raw/Table_PM_2017.pk...
Menthix General Coding Help 6 1,672 Mar-10-2022, 05:03 PM
    Thread: .format function
Post: RE: .format function

I don't get it, how do I refer to the new tables. What are their names ? tables2016, tables2017, tables2018 ? In that case, it doesn't seem to work
Menthix General Coding Help 6 1,672 Mar-10-2022, 04:36 PM
    Thread: .format function
Post: .format function

Hello, I'm trying to create 3 different tables on this model : Table_2016=pd.read_pickle("./0_DATA/0_raw/Table_PM_2016.pkl") Table_2017=pd.read_pickle("./0_DATA/0_raw/Table_PM_2017.pkl") Table_201...
Menthix General Coding Help 6 1,672 Mar-10-2022, 03:56 PM
    Thread: Plot 3 variables
Post: RE: Plot 3 variables

Any answer ?? What Paul suggested is not what i want at all. I think you are a good guy Paul but it 's not what i'd like. But you seem nice tho.
Menthix General Coding Help 3 2,111 Nov-13-2021, 02:47 PM
    Thread: Plot 3 variables
Post: RE: Plot 3 variables

(Nov-08-2021, 04:50 PM)paul18fr Wrote: "matplotlib 3d bar plot" on google will help you Nota: comédie Française (don't forget the last "e" **wink** ) Thanks for your reply Paul. Although, it's not...
Menthix General Coding Help 3 2,111 Nov-08-2021, 05:08 PM
    Thread: Plot 3 variables
Post: Plot 3 variables

Hello, I would like to make a plot according to 3 variables. I have a database that includes several theatrical performances at the Comédie-Français. The three variables in question are 'acts' (number...
Menthix General Coding Help 3 2,111 Nov-08-2021, 01:50 PM
    Thread: Subplot - Plotting 4 plots on the same row
Post: Subplot - Plotting 4 plots on the same row

Hello ! I'd like to plot 4 plots on the same raw but I don't know how... I tried the command : plt.subplot(1,4,) but it doesn't seem to work. You'll find the notebook on my GitHub (https://github....
Menthix General Coding Help 1 1,417 Nov-07-2021, 02:54 PM
    Thread: Find the highest value of a list
Post: RE: Find the highest value of a list

(Oct-29-2021, 10:38 AM)Gribouillis Wrote: When you write for x in [0, len(L)-1], x takes only two values: 0 and len(L)-1. Thank you, the issue definitly came from here ! Works better now.
Menthix General Coding Help 4 1,876 Oct-29-2021, 02:32 PM
    Thread: Find the highest value of a list
Post: Find the highest value of a list

Hello, I'm trying to build a small program to find the highest value of a list. I tried this : def nb_max(L): maxi = L[0] for x in [0,len(L)-1]: if maxi<=L[x]: maxi=...
Menthix General Coding Help 4 1,876 Oct-29-2021, 10:25 AM

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020