Group Abstract Group Abstract

Message Boards Message Boards

0
|
2.7K Views
|
4 Replies
|
1 Total Like
View groups...
Share
Share this post:

How can I select a list of countries from a dataset

Posted 3 years ago

I have a dataset with a list of all countries in the world and some other attributes from 1945 to 1990, I want to extract only these countries (please see below) from the dataset from 1970 upwards. I tried the code but it doesn't work. Do you have any suggestions?

Query[Select[#year >=
1970&& #country == {"Ethiopia", "Venezuela", "Canada",
"Finland", "Brazil", "China", "Greece", "Italy",
"Netherlands", "Norway", "Kenya", "Sweden"} &]]@dataset11
POSTED BY: Tobi Babatunde
4 Replies
Posted 3 years ago

POSTED BY: Eric Rimbey
Posted 3 years ago

Ohhhh I understand now. It worked! Thanks a lot.

POSTED BY: Tobi Babatunde
Posted 3 years ago

This part of your expression,

#country == {"Ethiopia", "Venezuela", "Canada","Finland", "Brazil", "China", "Greece", "Italy","Netherlands", "Norway", "Kenya", "Sweden"}

will cause the query to look for a value in the country column that is literally that list. You might want to try MemberQ instead.

POSTED BY: Eric Rimbey
Posted 3 years ago

Thanks, Eric. MemberQ only tests the list and returns a True/False output, what I'm trying to do is extract from the dataset any row that contains the stated countries.

POSTED BY: Tobi Babatunde
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard