Pandas Dataframe - Move Rows From One Dataframe To Another
I have a python pandas dataframe that has 3 rows in it: Name Time count AAA 5:45 5 BBB 13:01 8 CCC 11:16 3 I am trying to loop through this dataframe and if the count is
Solution 1:
You can use boolean indexing
only, as Edchum mentioned in comment:
import pandas as pd
df4 = pd.DataFrame({'Name': {0: 'AAA', 1: 'BBB', 2: 'CCC'},
'Time': {0: '5:45', 1: '13:01', 2: '11:16'},
'count': {0: 5, 1: 8, 2: 3}})
print (df4)
Name Time count
0 AAA 5:45 5
1 BBB 13:01 8
2 CCC 11:16 3
res = pd.DataFrame(columns=('MachineName', 'DateTime', 'Occurences'))
res = pd.concat([res, df4[df4['count'] >= 5]])
print (res)
DateTime MachineName Name Occurences Time count
0 NaN NaN AAA NaN 5:45 5.0
1 NaN NaN BBB NaN 13:01 8.0
Post a Comment for "Pandas Dataframe - Move Rows From One Dataframe To Another"