Dropping rows in a dataframe - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: Dropping rows in a dataframe (/thread-6704.html) |
Dropping rows in a dataframe - sobrio1 - Dec-03-2017 Hi, I'm trying to delete a couple rows from a dataframe so I don't have unwanted text/values import numpy as np import pandas as pd #Saving a copy of the original values temp['Sales_Orig']=temp['Sales'] #Log-transform Sales temp['Sales']=np.log(temp['Sales']) temp.tail() I couldn't figure out how to directly delete those last 2 rows, so I tried copying to a new dataframe and leaving off the last couple rows:new_df = temp[:105] new_df['Sales']=np.log(new_df['Sales']) new_df.tail()...however here I got the following message I don't really care how they get deleted - I just want to know how to do it cleanly and consistently.Any help is appreciated. Thanks! |