this is my data: [ 0 500 1000 1500 2000 2500 3000 3500 4000 4500 ... \ codonpos ... 0…
- User
this is my data:
[ 0 500 1000 1500 2000 2500 3000 3500 4000 4500 ...
codon_pos ...
0 48.0 27.0 32.0 26.0 45.0 63.0 45.0 17.0 63.0 61.0 ...
1 56.0 18.0 43.0 21.0 37.0 54.0 54.0 19.0 64.0 79.0 ...
2 55.0 21.0 34.0 13.0 39.0 46.0 39.0 21.0 74.0 63.0 ...code55500 56000 56500 57000 57500 58000 58500 59000 59500 \codon_pos
0 561.0 514.0 638.0 684.0 689.0 617.0 531.0 594.0 588.0
1 506.0 469.0 594.0 621.0 635.0 541.0 478.0 518.0 519.0
2 584.0 525.0 634.0 681.0 710.0 606.0 534.0 580.0 589.0some dfs does not have the complete number of columns (some of them lack the column "2000" for example). I want to calculate the mean of each column at each row. for all dfs. If a df does not have that column, it does not sum anything and is not counted for the mean.
- Assistant
To calculate the mean of each column for each row across different dataframes, taking into account the presence of missing columns in some dataframes, you can follow these steps in Python, using the
pandaslibrary:-
Perform an initial check to confirm all dataframes have the same index, denoted as 'codon_pos' in your case.
-
- User
how can I make the pandas plots to be included in the plot:
fig, ax = plt.subplots(2,2, figsize=(12,3))
ax[0,0].plot(n_muts) ax[0,0].set_title("Mutations in all populations") ax[0,0].set_ylabel("Mut[n]", fontsize=13)
ax[0,1].plot(n_muts[NONMUTATORS]) ax[0,1].set_title("Mutations in non-mutator populations")
ax[0,1].set_xticks(range(0, len(n_muts['m4']), 15)) ax[0,1].set_xticks(range(0, len(n_muts['m4']), 15))
ax[0,0].tick_params(axis='both', which='major', labelsize=12) ax[0,1].tick_params(axis='both', which='major', labelsize=12)
ax[1,0] = final_df_codon.transpose().plot() ax[1,0].tick_params(axis='both', which='major', labelsize=12)
ax[1,1] = final_df_dirs.transpose().plot() ax[1,1].tick_params(axis='both', which='major', labelsize=12)
- Assistant