Created
November 23, 2022 14:58
-
-
Save qaixerabbas/44752b0d15371c43159667e9958b99be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
=> df | |
Location Parameter | |
0 A 10 | |
1 A 20 | |
2 B 14 | |
3 B 16 | |
4 C 15 | |
5 C 9 | |
6 C 6 | |
''' | |
cd = {k: v.reset_index(drop=True) for k,v in df.groupby("Location")["Parameter"]} # https://stackoverflow.com/questions/16269376/denormalize-csv-file-with-python-pandas-dataframe | |
df = pd.DataFrame(cd) | |
''' | |
A B C | |
0 10 14 15 | |
1 20 16 9 | |
2 NaN NaN 6 | |
''' | |
# After that just transpose the resuling dataframe to get data for market basket analysis algorihtms | |
transpose_df = df.T | |
# Now transpose_df can be fed to Apriori algorithm for basket analysis and can be used for recommendation. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment