Skip to contentBrand Logo
Tech CommunityCommunity Hubs
Products
Topics
BlogsEvents
Skills-Hub
Community
RegisterSign In
  1. Microsoft Community Hub
  2. CommunitiesProducts
  3. .NET
  4. Machine Learning and AI

Forum Widgets

Latest Discussions

Most RecentNewest TopicsMost ViewedMost RepliesMost LikesNo Replies YetNo Solutions YetSolutions
Tagged:
  • chrisxfire's avatar

    Best practice to fill one column with manipulated values from another (DataFrame)?

    C# 10 / .NET 6 / Microsoft.Data.Analysis Given a Microsoft.Data.Analysis DataFrame with two columns, what is the idiomatic way to take values from one column, manipulate them, then use the resulting value to fill the rows of the second column element-wise? // Create a DateTime column. PrimitiveDataFrameColumn<DateTime> dateTimeCol = new("Dates", 0); // Fill it. dateTimeCol.Append(DateTime.Now + TimeSpan.FromDays(1)); dateTimeCol.Append(DateTime.Now + TimeSpan.FromDays(2)); dateTimeCol.Append(DateTime.Now + TimeSpan.FromDays(3)); // Create a Ticks column. PrimitiveDataFrameColumn<long> ticksCol = new("Ticks", dateTimeCol.Length); // Create a DataFrame of the above two columns. DataFrame df = new(); df.Columns.Add(dateTimeCol); df.Columns.Add(ticksCol); At this point, what I want to do is df["Ticks"] = df["Dates"].Ticks. Of course, this doesn't work. I could do this: for (int i = 0; i < df.Rows.Count; i++) { DateTime tempDate = (DateTime) df[i, df.Columns.IndexOf("Dates")]; df[i, df.Columns.IndexOf("Ticks")] = tempDate.Ticks; } But... is there a better way?
    Solved
    chrisxfire
    Copper Contributor
    Apr 27, 2022
    ML.NET
    2.7KViews
    0likes
    4Comments

Tags

  • ML.NET24 Topics
  • .NET for Apache Spark2 Topics

Share this page

What's new
  • Surface Pro
  • Surface Laptop
  • Surface Laptop Studio 2
  • Copilot for organizations
  • Copilot for personal use
  • AI in Windows
  • Explore Microsoft products
  • Windows 11 apps
Microsoft Store
  • Account profile
  • Download Center
  • Microsoft Store support
  • Returns
  • Order tracking
  • Certified Refurbished
  • Microsoft Store Promise
  • Flexible Payments
Education
  • Microsoft in education
  • Devices for education
  • Microsoft Teams for Education
  • Microsoft 365 Education
  • How to buy for your school
  • Educator training and development
  • Deals for students and parents
  • AI for education
Business
  • Microsoft AI
  • Microsoft Security
  • Dynamics 365
  • Microsoft 365
  • Microsoft Power Platform
  • Microsoft Teams
  • Microsoft 365 Copilot
  • Small Business
Developer & IT
  • Azure
  • Microsoft Developer
  • Microsoft Learn
  • Support for AI marketplace apps
  • Microsoft Tech Community
  • Microsoft Marketplace
  • Marketplace Rewards
  • Visual Studio
Company
  • Careers
  • About Microsoft
  • Company news
  • Privacy at Microsoft
  • Investors
  • Diversity and inclusion
  • Accessibility
  • Sustainability
California Consumer Privacy Act (CCPA) Opt-Out IconYour Privacy Choices
  • Sitemap
  • Contact Microsoft
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Safety & eco
  • Recycling
  • About our ads
  • © Microsoft
  • Share to LinkedInShare on LinkedIn
  • Share to FacebookShare on Facebook
  • Share to XShare on X
  • Share to RedditShare on Reddit
  • Share to Blue SkyShare on Bluesky
  • Subscribe to RSSShare on RSS
  • Share to EmailShare on Email