Issue
What is simplest way to choose two different rows of a dataframe?
tx_df is the original dataset, and toy_df is the subset which is supposed to contain only two rows of the original dataset.
toy_df = tx_df.loc[tx_df['CustomerID'] == (14566) ]
toy_df = tx_df.loc[tx_df['CustomerID'] == (17844) ]
Thank you
Solution
tx_df.set_index('CustomerID').loc[[14566, 17844]]
tx_df[tx_df.CustomerID.isin([14566, 17844])]
tx_df.query('CustomerID == 14566 or CusromerID == 17844')
P.S. I think that in this case the easiest way to locate records by CustomerID would be to use the latter as an index (see the first line in the code above).
Answered By - Vitalizzare Answer Checked By - Pedro (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.