In [2]:
# there seems to be '-' in some fields instead of NAs...
# let's remove the carets and check if the datatype of the column changed...
import pandas as pd
import numpy as np
df = pd.read_csv("input/input.csv")
df.head()
Out[2]:
Action_id
TypeAction
Page_name
Feed_message
User_name
CommentsForItem_message
Sentiment
Action_created_time_qvdate
0
Comment/1364017066952510_1364097753611108
Comment
Resident Evil
[UK ONLY] To celebrate the release of Resident...
Ronald Briand
Muy buena :) (Y)
0.9880
1/5/2017
1
Comment/10154797365350629_10154797373500629
Comment
Bandai Namco
We continue our Tales Of look back with Tales ...
Jon Imboden
I may be in the minority here, but I LOVE the ...
0.9540
12/27/2016
2
Comment/1365217000165850_1365754593445424
Comment
Resident Evil
Are you afraid of the dark? Because you should...
Claudia Alejandra Olguín
mira Roberto Zeballos, para probar en tu PEQU...
0.9527
1/7/2017
3
Comment/1364017066952510_1364061950281355
Comment
Resident Evil
[UK ONLY] To celebrate the release of Resident...
David Lawrence
Sarah Amadeus :O
0.9402
1/5/2017
4
Comment/1365217000165850_1225502404193085
Comment
Resident Evil
Are you afraid of the dark? Because you should...
Leandro Guilherme
Aeee Paulo Lucas vou te dar de presente no seu...
0.9382
1/8/2017
In [10]:
for column in df.columns.values:
df.loc[df[column] == '-', column] = np.nan
df.head()
Out[10]:
Action_id
TypeAction
Page_name
Feed_message
User_name
CommentsForItem_message
Sentiment
Action_created_time_qvdate
0
Comment/1364017066952510_1364097753611108
Comment
Resident Evil
[UK ONLY] To celebrate the release of Resident...
Ronald Briand
Muy buena :) (Y)
0.9880
1/5/2017
1
Comment/10154797365350629_10154797373500629
Comment
Bandai Namco
We continue our Tales Of look back with Tales ...
Jon Imboden
I may be in the minority here, but I LOVE the ...
0.9540
12/27/2016
2
Comment/1365217000165850_1365754593445424
Comment
Resident Evil
Are you afraid of the dark? Because you should...
Claudia Alejandra Olguín
mira Roberto Zeballos, para probar en tu PEQU...
0.9527
1/7/2017
3
Comment/1364017066952510_1364061950281355
Comment
Resident Evil
[UK ONLY] To celebrate the release of Resident...
David Lawrence
Sarah Amadeus :O
0.9402
1/5/2017
4
Comment/1365217000165850_1225502404193085
Comment
Resident Evil
Are you afraid of the dark? Because you should...
Leandro Guilherme
Aeee Paulo Lucas vou te dar de presente no seu...
0.9382
1/8/2017
In [11]:
df.to_csv("output/data_cleaned.csv")
Content source: HelainSchoonjans/fantastic-eureka
Similar notebooks: