Programming

python code snippets - cheat sheet

Python Cheat Sheet for Data Science Practitioners

These are some python code snippets that I use very often. Pandas DataFrame Manipulation Ensure a data frame column is a float type column df[‘column_name’] = df[‘column_name’].astype(float) Group by a column and keep the column afterwards df.groupby([‘column_name’]).aggregate_function().reset_index() Convert a list of lists into a pandas data frame df=pd.DataFrame(list(your_list_of_lists),columns=[‘column 1′,’column 2′,’column3’]) Convert a data frame to …

Python Cheat Sheet for Data Science Practitioners Read More »