0

Hi kind of new to pandas. I am currently trying to copy a row based on an index from one dataframe to a second dataframe at a specified column within it. It successfully copies the column with all data, however it is missing the first value. I am unsure why the first value does not appear and was wondering if someone had insight on it. Here is my code below

import fileinput, sys, re, time, os
import pandas as pd
import numpy as np

"Create a blank dataframe with necessary column headers"
columnNames = ["Settings 1 Values", "Settings 2 Values", "CPU Address", "FPGA Address", "Delta", "Register Name", "R/W Status"]
output = pd.DataFrame(columns = columnNames)
print(output)

"Fill values from first settings into output dataframe"
df1 = pd.read_csv("50MHzWholeFPGA.csv")
output.loc["Settings 1 Values"] = df1.iloc[:, 0]

The output is as follows

       Settings 1 Values  Settings 2 Values  ...  Register Name R/W Status
0                     46                 16  ...            NaN        NaN
1                   9047                 46  ...            NaN        NaN
2                   9047               9047  ...            NaN        NaN
3                  31168               9047  ...            NaN        NaN
4                      8              31168  ...            NaN        NaN
                 ...                ...  ...            ...        ...
49146               9047               9047  ...            NaN        NaN
49147               9047               9047  ...            NaN        NaN
49148               9047               9047  ...            NaN        NaN
49149               9047               9047  ...            NaN        NaN
49150               9047               9047  ...            NaN        NaN

As you can see in the settings 1 column, it starts at 46, where the first value is actually 16 like in the settings 2 column

parzival
  • 23
  • 4
  • 1
    could you provide your data in a pastebin or other format? – Allentro Oct 21 '21 at 17:54
  • Should be `output.loc[:, "Settings 1 Values"] = df1.iloc[:, 0]` I'm fairly certain. A sample of data and expected output would really help make this question more answerable. [How to make good reproducible pandas examples](https://stackoverflow.com/q/20109391/15497888) – Henry Ecker Oct 21 '21 at 18:04

1 Answers1

0

Try:

output.loc["Settings 1 Values"] = df1.iloc[:, 0].to_numpy()
Muhammad Hassan
  • 4,079
  • 1
  • 13
  • 27