Closed ngunhaSO closed 6 years ago
Do you have an example of pivot_table? Maybe a blog post you like that shows how to use it in Pandas?
I might have to implement it for you if the functionality doesn't exist yet.
I watched an AI course on Lynda.com, and the instructor converted a dataframe read from csv to a matrix.
This is the code that he used in the video.
raw_training_dataset_df = pd.read_csv('movie_ratings_data_set_training.csv') ratings_training_df = pd.pivot_table(raw_training_dataset_df, index='user_id', columns='movie_id', aggfunc=np.max)
So it will convert the data from this: user_id movie_id value 0 97 30 5
into a matrix like this
value
movie_id 1 2 3 4 5 6 7 8 9 10
user_id
1 NaN NaN NaN NaN NaN NaN NaN
Ok thanks.
My attention is currently on launching the new TypeScript version of DataForge: https://github.com/data-forge/data-forge-ts
Once that's out of the way I'll sort out the pivot function for you. Sorry for the delay.
Hi there,
I've updated the Data-Forge pivot function to work like Pandas. I'd love to get your feedback on it.
Please make sure you use the latest version of Data-Forge from npm.
Also please note that the repository has moved to here https://github.com/data-forge/data-forge-ts. That's where you'll need to log new issues.
See here for examples of pivot: https://github.com/data-forge/data-forge-ts/blob/master/src/test/dataframe.pivot-example.test.ts
Examples where adapted from here: https://chrisalbon.com/python/data_wrangling/pandas_pivot_tables/
What is the equivalent function of python pandas pivot_table? I see that you have pivot(columns, values), but it doesn't seem to do the same as as python pandas pivot_table one.