0xsegfault
0xsegfault

Reputation: 3161

Deduplication of Dataframe returning empty object

I have 2 csv files with similar columns. I am reading and concatenating them with the following code:

One = pd.read_csv("/Users/xxx/Documents/Domains/Malaysia - MAR.csv" )
Two = pd.read_csv("/Users/xxx/Documents/Domains/Malaysia - CR.csv" )


links_webtrends_my = pd.concat([One,Two])

links_webtrends_my = links_webtrends_my['Page']

links_webtrends_my = links_webtrends_my.to_frame(name='Page')

I then use this line to drop duplicates

links_webtrends_my = links_webtrends_my.drop_duplicates(keep='first', inplace=True)

When I do this, it deletes everthing in it. When I call links_webtrends_my afterwards, it doesnt return anything. I will appreciate guidance on this.

Upvotes: 4

Views: 1248

Answers (1)

Scott Boston
Scott Boston

Reputation: 153460

When using inplace=True the return object is NoneType. Remove the assignment back to the variable when using inplace=True.

links_webtrends_my.drop_duplicates(keep='first', inplace=True)

OR remove the inplace=True parameter.

links_webtrends_my = links_webtrends_my.drop_duplicates(keep='first')

Upvotes: 3

Related Questions