AI and DS Skills

 View Only
  • 1.  Pandas Data Frames

    Posted Thu February 24, 2022 12:44 PM
    Hello. i am working on this problem where I am supposed to create a new column to an already existing data frame, yet the content of this this data should be this vector [5.0, 3.1, 2.1, 0.6] for each row. I have been stuck for hours. What is a correct way of doing so. thank you :)

    ------------------------------
    katia Oussar
    ------------------------------

    #AIandDSSkills
    #DataandAILearning


  • 2.  RE: Pandas Data Frames

    Posted Fri February 25, 2022 07:59 AM
    Doesn't this work?

    df = pd.DataFrame({'A':[[1,2,3],[4,5,6],[7,8,9]]})
    In other words, put wrap your vectors into another list, then put it into your dataframe (or I have created a dataframe with just the one column above. But if you already had a dataframe, just do this)

    df['A'] = [[1,2,3],[4,5,6],[7,8,9]]


    ------------------------------
    Michael Zalewski
    Lake Hiawatha NJ
    NA
    ------------------------------