I got this CSV File and it look like this:
Country/Region Confirmed Deaths Recovered
0 Andorra 862 54 803
1 Angola 452 24 124
...
The CSV File is in a alphabetical order.
Here is my Code how to try select specific Columns:
csv_df = pd.read_csv(adsf.csv)
csv.head()
csv_df.loc[csv_df["Country/Region"] == "China"]
Here shows only the column "China"
Country/Region Confirmed Deaths Recovered
China 85246 4644 78228
But my Goal is to filter a specific amount of Country/Regions
It should look like this:
Country/Region Confirmed Deaths Recovered
32 China 85246 4644 78228
42 France 13743 321 13334
97 Spain 35311 2134 4532
These Numbers arent real. This is just an Exampel of Numbers.
There are many ways to do this,
csv_df = pd.read_csv("adsf.csv")
custom_df=csv_df[["column_name1","column_name2"]]
custom_df.head() # this show chosen columns
csv_df=pd.read_csv("adsf.csv",usecols=["column_name1","column_name2"])
csv_df.head()
Is this what you need?
csv_df = pd.read_csv(adsf.csv) csv.head()
filter_by_country = csv_df["Country/Region"] == "China"
filter_by_country.head()
The output should be filtered out by the country/region column.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.