简体   繁体   中英

pivot_table values missing

在此处输入图片说明

I just simply reshape the dataframe as my wish. index is userid, and columns are subgameID, filled with rating as values. But all values become missing data.

Just for the record - if you only check 2 columns like that, why don't you use pd.crosstab?

pd.crosstab(ratings_data.userID, ratings_data.subgameId, margins=True)

If you need pivot_table, then try to add argument fillna = 0 .

You can also try to do it on small subsample of the data - maybe the NaNs are properly introduced (many userID belonged to only small subset of subgameID)?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM