Group Abstract Group Abstract

Message Boards Message Boards

0
|
4.4K Views
|
3 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Assigning keys to columns of Dataset while importing?

Posted 4 years ago

I am new to Mathematica and was looking for some help.

I have successfully imported an excel sheet as a dataset, however, I wanted to manipulate the dataset but realised I need a key to do so. When I imported them, the two columns of data appeared as a dataset, however, with no key. How can I assign a key to each column? It is not possible to directly assign this as there are hundreds of rows of data.

Is there a way to assign the key when importing the data or even to do this after?

Attachment

Attachments:
POSTED BY: Antonia Duncan
3 Replies
Posted 4 years ago

If the Excel file has column headers use

Import[<file>, {"Dataset", 1}, HeaderLines -> 1]

If it does not then after the import

headers = {"Date", "Cases"};
ds[All, AssociationThread[headers, #] &]

where ds is the imported Dataset.

POSTED BY: Rohit Namjoshi
Posted 4 years ago
POSTED BY: Eric Rimbey

Welcome to Wolfram Community! Please make sure you know the rules: https://wolfr.am/READ-1ST

The rules explain how to format your code properly. Posting code Images doesn't help other members to copy your code. Please EDIT your post and make sure code blocks start on a new paragraph and look framed and colored like this.

int = Integrate[1/(x^3 - 1), x];
Map[Framed, int, Infinity]

You can also embed notebook or attach notebook.

enter image description here

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