I can't figure out how to display a the headers for a DataFrame in SwiftUI.
According to this post, I am only able to display rows in SwiftUI. Or am I completely wrong? Is there a way to convert the headers from a DataFrame to an String Array [String]? e.g.,
dataframe.columns.map { col in col.name }
Is there a way to convert the headers from a
DataFrame
to an String Array[String]
?
Sure. The code you posted does exactly that. For example:
import Foundation
import TabularData
func main() {
let csv = """
Word,Popularity
Hello,17
Cruel,42
World,5
"""
let df = try! DataFrame(csvData: Data(csv.utf8))
let names = df.columns.map { col in col.name }
print(names)
// prints: ["Word", "Popularity"]
}
main()
Is that not sufficient? If not, can you explain why?
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"