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

select first n items of a list without using a loop.
when I initiate second button click -> AttributeError: Application instance has no attribute 'readfile'
Python 3.4 with an older Python script for use in Blender, TypeErrors
error when installing numpy for pypy2.2.1
How to find out in which locale it was encoded to?
alembic revision - multiple heads (due branching) error
Python set value multiindex Pandas
Multiplication table for double digit numbers using nested loops in Python
pandas time_range does not start from start date
Django How about my method to solve anti spam post request? Is there better solutions?
How can I write a csv file with multiple header lines with pandas to_csv()?
Connect to RDS from EC2 instance with Python
Make a function that extract value from a list and use it to match with another list that has a tuple in it
Memory address when function handle called in Python
Overwrite Property
Share file stream between Python and C

Categories

HOME
payment-gateway
elixir
textwatcher
nuxeo
visual-studio-2013
safari
javamail
iis-7.5
tizen-wearable-sdk
jpanel
gimp
hashicorp-vault
sign
cairo
grub2
google-people
jpeg2000
prestodb
thumbnails
nmake
ghost-inspector
rworldmap
npm-install
cep
spring-data-neo4j
classpath
vcard
frp
dpi
freebase
web-audio-api
mapguide
recurrence-relation
rhino
honeysql
passenger
haskell-pipes
delphi-10.1-berlin
parent
intellij-idea-2016
xbim
paho
proof
nstouchbar
sapui
broadcast
spring-data-hadoop
cdk
system.web.ui.webcontrols
typhoon
windows-azure-pack
rstudio-server
gitweb
tomcat5
radians
gradle-eclipse
fortran90
brackets-shell
android-recyclerview
test-class
sonarqube5.3
persistence.xml
visual-studio-code
mogrify
team-build
guzzle6
subversion-edge
musl
magento-1.12
django-1.6
viewflipper
cloudpebble
mser
google-admin-audit-api
emma
visualstatemanager
opendata
va-list
swrl
carddav
mailcore
vertical-scrolling
sametime
attachevent
linkedhashset
cadisplaylink
text-services-framework
signals2
law-of-demeter
maven-ant-tasks
driving-directions
flexicious
ou
nemerle
paintcomponent
noir
.app
mvvm-foundation

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