**Index date colum1 column2**
0 20200705 a 1.1%
1 20200706 b 78%
2 20200707 f 10%
3 20200707 g 59%
4 20200708 a 69%
Consider the name of the above data frame as 'df
'.
I want to delete the data for the particular date
I tired the options below
dates =['20200707']
df= df[~df['date'].isin(dates)] (1st try)
df.drop(df[df['date'].isin(dates)].index, inplace = True) (2nd try)
The data in those corresponding rows gets deleted but I'm ending up with the data frame as below
Index date column1 column2
0 20200705 a 1.1%
1 20200706 b 78%
2 0.0%
3 0.0%
4 20200708 a 69%
I don't know why that happens and I didn't find any source to fix this kind of issue. So I have deleted Column2
and performed the same operation and I ended up with the data frame as below
Index date column1
0 20200705 a
1 20200706 b
2
3
4 20200708 a
Note: I'm importing the data from Google sheet by using .get_all_records()
method and converting that to a data frame
df= sheet.worksheet('work_sheet').get_all_records()
df= pd.DataFrame(df)
After the above operation, I tried sorting the data, expecting that empty rows gets deleted
df.sort_values(by='date')
but ended up with
**Index date colum1 **
2
3
0 20200705 a
1 20200706 b
4 20200708 a
I even tried by using dropna
df.dropna(inplace=True)
But there is no change in the result
I want that empty rows to be removed please help me
I tried everything, I tried to explain below please let me know incase of any questions
The strangest part is the empty lines where the data gets deleted after df= df[~df['date'].isin(dates)]
operation are stored as str
type and ' '
empty space as cell,
I wonder creating a dataframe out of data imported from Google sheet is causing me problems