"pandas mean of n columns" Code Answer's
You're definitely familiar with the best coding language Whatever that developers use to develop their projects and they get all their queries like "pandas mean of n columns" answered properly. Developers are finding an appropriate answer about pandas mean of n columns related to the Whatever coding language. By visiting this online portal developers get answers concerning Whatever codes question like pandas mean of n columns. Enter your desired code related query in the search bar and get every piece of information about Whatever code related question on pandas mean of n columns.
pandas mean of n columns
N = 9
df['new'] = df['col2'].shift(-N+1)
df.loc[0, 'new'] = df.iloc[:N, df.columns.get_loc('col2')].mean()
print (df)
col2 desired_output new
0 14.375 14.261111 14.261111
1 14.350 14.175000 14.175000
2 14.300 14.125000 14.125000
3 14.350 14.150000 14.150000
4 14.300 13.974000 13.974000
5 14.225 14.074000 14.074000
6 14.175 14.099000 14.099000
7 14.150 13.949000 13.949000
8 14.125 13.899000 13.899000
9 14.175 13.849000 13.849000
10 14.125 13.749000 13.749000
11 14.150 13.774000 13.774000
12 13.974 NaN NaN
13 14.074 NaN NaN
14 14.099 NaN NaN
15 13.949 NaN NaN
16 13.899 NaN NaN
17 13.849 NaN NaN
18 13.749 NaN NaN
19 13.774 NaN NaN
Source: stackoverflow.com
All those coders who are working on the Whatever based application and are stuck on pandas mean of n columns can get a collection of related answers to their query. Programmers need to enter their query on pandas mean of n columns related to Whatever code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about pandas mean of n columns for the programmers working on Whatever code while coding their module. Coders are also allowed to rectify already present answers of pandas mean of n columns while working on the Whatever language code. Developers can add up suggestions if they deem fit any other answer relating to "pandas mean of n columns". Visit this developer's friendly online web community, CodeProZone, and get your queries like pandas mean of n columns resolved professionally and stay updated to the latest Whatever updates.