Last active
August 20, 2019 18:43
-
-
Save gchavez2/b8f4d798ff9f47ec60ea88fbae8aae2a to your computer and use it in GitHub Desktop.
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 characters
nme = ["aparna", "pankaj", "sudhir", "Geeku"] | |
deg = ["MBA", "BCA", "M.Tech", "MBA"] | |
scr = [90, 40, 80, 98] | |
# New from dictionary | |
dict = {'name': nme, 'degree': deg, 'score': scr} | |
df = pd.DataFrame(dict) | |
clean_df.to_csv(OUTPUT_FILENAME, index=False) | |
# New dataframe from subset of pandas dataframe | |
clean_df = df.loc[idx_list] | |
clean_df.to_csv(OUTPUT_FILENAME, index=False) | |
# New from head | |
OUTPUT_FILENAME='./smaller_df.csv' | |
ndf = df.head() | |
ndf.to_csv(OUTPUT_FILENAME, sep=',', encoding='utf-8', index=False) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment