9

data

Hi, can anyone help me with this? I want to delete the column "FIPS" and "Admin2", and keep the dataset as the original. How would I do this?

data = Import[
  "C:\\Users\\49176\\OneDrive\\Desktop\\time_series_covid19_confirmed_\
US(2).csv", "Dataset", HeaderLines -> 1]

Code is here, and the csv file is downloaded from https://github.com/CSSEGISandData/COVID-19/tree/master/csse_covid_19_data/csse_covid_19_time_series

mjf88530
  • 101
  • 7

2 Answers2

18

You can use KeyDrop:

picture = Import["https://i.stack.imgur.com/p7ax0.jpg"];

table = Transpose[Partition[TextRecognize[picture, "Word"], 9] /. "Long_" -> "Long"];

ds = Dataset[AssociationThread[First @ table, #] & /@ Rest[table]]

enter image description here

KeyDrop[{"FIPS", "Admin2"}] @ ds

enter image description here

We also get the same result using any of the following:

ds[KeyDrop[{"FIPS", "Admin2"}]]

Query[KeyDrop[{"FIPS", "Admin2"}]] @ ds

ds[All, Delete[{{"FIPS"}, {"Admin2"}}]]

ds[All, Delete[{{1}, {2}}]]

kglr
  • 394,356
  • 18
  • 477
  • 896
3
list = {
   <|"a" -> 1, "b" -> "b1", "c" -> {1}, "d" -> 1, "e" -> {1}, 
    "f" -> 1|>,
   <|"a" -> 2, "b" -> "b2", "c" -> {2}, "d" -> 2, "e" -> {2}, 
    "f" -> 2|>,
   <|"a" -> 3, "b" -> "b3", "c" -> {3}, "d" -> 3, "e" -> {3}, 
    "f" -> 3|>,
   <|"a" -> 4, "b" -> "b4", "c" -> {4}, "d" -> 4, "e" -> {4}, 
    "f" -> 4|>,
   <|"a" -> 5, "b" -> "b5", "c" -> {5}, "d" -> 5, "e" -> {5}, 
    "f" -> 5|>,
   <|"a" -> 6, "b" -> "b6", "c" -> {6}, "d" -> 6, "e" -> {6}, 
    "f" -> 6|>};
list // Dataset
list[[All, 3 ;; 6]] // Dataset

enter image description here

cvgmt
  • 72,231
  • 4
  • 75
  • 133