'How to access a cell and add it to another dataframe in Pandas [duplicate]
my question is: How to access a cell and add it to another dataframe in Pandas This is my dataframe:
new = marker_df.describe()
new
acceleration seconds seconds_diff revolutions_per_second count 3.000000 3.000000 2.000000 2.000000 mean 10116.666667 0.398737 0.301705 3.314497 std 245.980352 0.301705 0.000447 0.004906 min 9833.000000 0.096926 0.301389 3.311027 25% 10039.500000 0.247937 0.301547 3.312762 50% 10246.000000 0.398947 0.301705 3.314497 75% 10258.500000 0.549642 0.301863 3.316231 max 10271.000000 0.700337 0.302021 3.317966
and here another dataframe:
first_df = pd.DataFrame()
And now I want to access a cell from new and add it to first_df
I did this:
acc = new.at["count",'acceleration']
first_df = first_df.join(float(acc))
first_df
And got this error:
TypeError: 'float' object is not iterable
now help me please! :)
Solution 1:[1]
You can use:
first_df = pd.DataFrame({'col':[acc]})
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | jezrael |
