Last active
January 20, 2023 10:10
-
-
Save Tech-49/5bb4449d8eff6a1e2076aed695afa09b to your computer and use it in GitHub Desktop.
Revisions
-
Tech-49 revised this gist
Jan 20, 2023 . 1 changed file with 5 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -36,4 +36,8 @@ df.loc[:, ['col_1', 'col_2']] X[X['cluster_2'].isin([0])].reset_index() # Sum of rows df = df.sum(axis = 1) # Create dataframe from dictionary (Key as columns) a={'b':100,'c':300} pd.DataFrame(coefs, index=[0,]) -
Tech-49 revised this gist
Dec 12, 2022 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -33,4 +33,7 @@ df.iloc[[index]] df.loc[:, ['col_1', 'col_2']] # Filter rows in dataframe where cluster_2 is 0 X[X['cluster_2'].isin([0])].reset_index() # Sum of rows df = df.sum(axis = 1) -
Tech-49 revised this gist
Nov 14, 2022 . 1 changed file with 4 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -30,4 +30,7 @@ df.copy(deep=True) df.iloc[[index]] # Fetch multiple columns. df.loc[:, ['col_1', 'col_2']] # Filter rows in dataframe where cluster_2 is 0 X[X['cluster_2'].isin([0])].reset_index() -
Tech-49 revised this gist
Nov 14, 2022 . 2 changed files with 33 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ ------------------- Pandas ------------------- # Create dataframe from dictionary df = pd.DataFrame.from_dict(data["trainData"]) # Convert entire dataframe values to numeric type. df = df.apply(pd.to_numeric, errors='ignore') # Remove missing value. df = df.dropna() # Create a new column named "new_col" with value "2" if cluster_id column has value 1, else 0. df.insert(loc=0, column=new_col, value=np.where(cluster_id == 1, 2, 0)) # Create a new column named "new_col" with value of df["log2_livable"] if cluster_id is 1, else 0. df.insert(loc=0, column=new_col, value=np.where(cluster_id == 1, df["log2_livable"], 0)) # Change date format of entire column. effective_date = pd.to_datetime(df["effective_date"], format='%Y-%m-%d') # Re-order dataframe by columns (A-Z) df = df[sorted(df.columns)] # Clone dataframe df.copy(deep=True) # Fetch the row based on given index. df.iloc[[index]] # Fetch multiple columns. df.loc[:, ['col_1', 'col_2']] This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,8 +0,0 @@ -
Tech-49 created this gist
Nov 14, 2022 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ # Create dataframe from dictionary df = pd.DataFrame.from_dict(data["trainData"]) # Convert to numeric type. df = df.apply(pd.to_numeric, errors='ignore') # Remove missing value. df = df.dropna()