私はJupyter Notebookにデータフレームを提示しています。データフレームの初期データ型はfloatです。私は、印刷された表の行1 & 3を整数として、行2 & 4をパーセンテージとして提示したいと思います。それ、どうやったら出来るの?ここでJupyterノートブックデータフレーム出力の特定の行のフォーマット
#Creating the table
clms = sales.columns
indx = ['# of Poeple','% of Poeple','# Purchased per Activity','% Purchased per Activity']
basic_stats = pd.DataFrame(data=np.nan,index=indx,columns=clms)
basic_stats.head()
#Calculating the # of people who took part in each activity
for clm in sales.columns:
basic_stats.iloc[0][clm] = int(round(sales[sales[clm]>0][clm].count(),0))
#Calculating the % of people who took part in each activity from the total email list
for clm in sales.columns:
basic_stats.iloc[1][clm] = round((basic_stats.iloc[0][clm]/sales['Sales'].count())*100,2)
#Calculating the # of people who took part in each activity AND that bought the product
for clm in sales.columns:
basic_stats.iloc[2][clm] = int(round(sales[(sales[clm] >0) & (sales['Sales']>0)][clm].count()))
#Calculating the % of people who took part in each activity AND that bought the product
for clm in sales.columns:
basic_stats.iloc[3][clm] = round((basic_stats.iloc[2][clm]/basic_stats.iloc[0][clm])*100,2)
#Present the table
basic_stats
印刷テーブルの: Output table of 'basic_stats' data frame in Jupyter Notebook
可能性のある重複した[列のフォーマット文字列を使用してfloatのパンダのデータフレームを表示するには?](http://stackoverflow.com/questions/20937538/how-to-display-pandas-dataframe-of- floats-using-a-format-string-for-columns) – IanS
テーブルを転置し、提案された複製にソリューションを適用してから、転置して表示することをお勧めします。 – IanS