I haven't been able to find much on this topic, so I would really like some help with the actual code to achieve this task. Preferably, use Pandas for the data structure and Python for the language. Assume a list of first names(Sally, Mike, etc) is inputted and you want to query this list from a database of first and last names(Sally Smith, Mike Miller, etc). Based upon last names already given, we want to modify this text file to only include the first names that are present in the other database.
-
Can you be more specific as to your input? This sounds like a network programming task...warship– warship2015-06-16 02:16:10 +00:00Commented Jun 16, 2015 at 2:16
-
Can you please edit your question to include information regarding what your input looks like... I assume that you want to load a Pandas dataframe but then query that dataframe based on some sort of list. Please supply info...warship– warship2015-06-16 02:17:30 +00:00Commented Jun 16, 2015 at 2:17
-
explain in more, what you want exactly?N J– N J2015-06-16 02:19:28 +00:00Commented Jun 16, 2015 at 2:19
-
It sounds like the user wants to query based on keys and valueswarship– warship2015-06-16 02:20:43 +00:00Commented Jun 16, 2015 at 2:20
-
It sounds like the OP wants to basically filter out the list of first names so that he can toss any first names that are not present in the list of first and last names.warship– warship2015-06-16 02:25:43 +00:00Commented Jun 16, 2015 at 2:25
|
Show 1 more comment
1 Answer
Without information about the type of DB you are using, I'm assuming it accepts SQL queries and you can connect from Python.
If those two conditions are satisfied, I would suggest trying Pandas' built-in query:
http://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_sql.html