0

When I try to drop NaN values from this dataset, It results in None I cannot understand what is wrong with this. Is this something about dataset ? I inspected the dataset, there are definitely rows that don't contain NaN values. And of course it prints out if I don't do dropna.

https://www.kaggle.com/mczielinski/bitcoin-historical-data

import numpy as np
import pandas as pd
from datetime import datetime
from sklearn.model_selection import train_test_split

df  = pd.read_csv('D:\BTC_price history.csv')
df['Timestamp'] = pd.to_datetime(df['Timestamp'],unit='s') #converted to date utc

df = df.dropna(inplace = True)
print(df)
  • if you remove the line ```df['Timestamp'] = pd.to_datetime(df['Timestamp'],unit='s')```, does still ```df``` is None after dropna? If it is working without that line, then this line cause the problem: you get NaN in all Timestamp column – Roim May 13 '20 at 20:03

1 Answers1

1

df.dropna(inplace = True) does not return anything, it drops in place

Do this:

df.dropna(inplace=True)

or

df = df.dropna()
NYC Coder
  • 7,424
  • 2
  • 11
  • 24