Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

count duplicate rows in python

import pandas as pd

#print how many duplicate rows in the dataframe
print(df.duplicated().sum())
Comment

how to duplicate a row in python

import pandas as pd

In [603]: df = pd.DataFrame({'col1':list("abc"),'col2':range(3)},index = range(3))

In [604]: df
Out[604]: 
  col1  col2
0    a     0
1    b     1
2    c     2

In [605]: pd.concat([df]*3, ignore_index=True) # Ignores the index
Out[605]: 
  col1  col2
0    a     0
1    b     1
2    c     2
3    a     0
4    b     1
5    c     2
6    a     0
7    b     1
8    c     2

In [606]: pd.concat([df]*3)
Out[606]: 
  col1  col2
0    a     0
1    b     1
2    c     2
0    a     0
1    b     1
2    c     2
0    a     0
1    b     1
2    c     2
Comment

PREVIOUS NEXT
Code Example
Python :: get length from variable python 
Python :: cannot unpack non-iterable int object when using python dicitonary 
Python :: what is repr function in python 
Python :: positive and negative number in python 
Python :: create login user django command 
Python :: rabbitmq python 
Python :: max of a list in python 
Python :: how to do the sum of list in python 
Python :: python os.walk 
Python :: shape function python 
Python :: while loop in python for do you want to continue 
Python :: how to find gcd of two numbers in python 
Python :: use of self in pythonic class 
Python :: on_delete django options 
Python :: how to learn regex pyton 
Python :: python tkinter scrollbar 
Python :: python string operations 
Python :: numpy sign method 
Python :: ten minute mail 
Python :: set index pandas 
Python :: python bigquery example 
Python :: receipt ocr python 
Python :: code optimization in python 
Python :: python infinite loop 
Python :: how to print the 3erd character of an input in python 
Python :: Following Links in Python 
Python :: fro flask import Flask, request, render_template, url_for, redirect, session 
Python :: significant figures on axes plot matplotlib 
Python :: how to count categories in a csv command line 
Python :: ftplib tqdm 
ADD CONTENT
Topic
Content
Source link
Name
3+6 =