python


pandas(dataframe) select data


Hello guys,
I use dataframe to create two tables(A and B) and both have the same columns.
(1st column is 'ID' and one table might have more than one row with same ID)
I want to create a new table(C) based on A and some rows from B.
If the ID in table B also occur in A then add this row into C.
My code:
from pandas import DataFrame
A_ID = [1,2,3,1,2]
A_place = [1,2,3,2,1]
B_ID = [4,2,6]
B_place = [2,2,3]
A_data = {'ID':A_ID,'place':A_place}
A_table = DataFrame(A_data)
B_data = {'ID':B_ID,'place':B_place}
B_table = DataFrame(B_data)
C_table = A_table
for n in range(len(B_table)):
if B_table['ID'][n] in list(A_table['ID']):
C_table = C_table.append(B_table[n:n+1])
Question:
My question is that is there any other way to do it without using for loop?
I will deal with million's of data and for loop wastes lots of time.
By the way, are there other tools better than pandas to deal with big data?
Thanks your help!!

Related Links

Why is honcho forking recursively?
Using IFNULL in sqlalchemy core
Python - Iterate through, and extract, elements of a dictionary type list
Keeping track of dropped indices when dropping elements from numpy array
send data while redirect to view in django
Are there some light-weight python libraries to play music segments with poloyphony?
Python3: Client-Server communication
XML Parsing to .txt file Python
Is this Python unicode escape error?
Adding a variable number of sub-plots in a loop. add_subplot
Project Euler 36 Double-base Palindrome Python 3
CSV File filtering using django(python)
Inserting data into mysql using python
Win32api's keybd_event() function problems
How can you move data from column b and append to the end of column a using Python?
NLTK classification probability estimate with n-grams

Categories

HOME
plsql
semantic-ui
npm
freepascal
warnings
transparent
phpstorm
rfc
avl-tree
netflix-feign
google-plus
xamarin-studio
android-source
cortex-a
intellij-plugin
netezza
session-timeout
redux-observable
aptana
atlassian-plugin-sdk
flat-file
linq-to-sql
scalaz7
cocoa-touch
searchbar
onesignal
widevine
solidworks
reply
cortex-m3
red-black-tree
roundcube
referenceerror
rowcount
stocks
edb
fabric-digits
.net-assembly
haskell-pipes
web-development-server
context-free-language
ajp
dimple.js
gd
google-maps-ios
dts
amf
soda
achievements
gradle-release-plugin
sun-codemodel
servlet-3.0
acm
anythingslider
persistence.xml
xjc
multipleselection
c++-actor-framework
lexicographic
line-numbers
gyroscope-framework
iostream
facebook-wall
logentries
bigint
sslexception
astyanax
javascriptmvc
dig
grunt-contrib-compass
adomd.net
objcmongodb
template-haskell
gdataxml
concurrent-programming
separation-of-concerns
emacs23
ajax.beginform
.app
clients
chdatastructures
webrat

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App