I have a dataframe DF1, that has 4 distinct one word named columns, and one identifier column, tz:
Tz, Population, Citibike, Residential, Taxi
Initially, I want to create a dictionary preserving the elements index:
for name in len(DF1.columns):
name = {tz:DF1.name[tz] for tz in DF1.index}
But this produces error either of int object not iterable if I put len(SMdata.columns) or that Dataframe has no object name if I remove the len function from the for loop.
I also have another data frame DF2, to which I am trying to add columns from the first dataframe but most importantly using mapping function on it's column "LocationID".
To do this I tried writing this code:
for name in list(DF1.columns):
Key = name
DF2[name] = DF2.LocationID.map(key)
However, I keep running into "TypeError: 'str' object is not callable"
I am confused as to why is this approach not working!
EDIT: Is it possible to create a loop for getting entries from a column, performing math operation on all values, and adding new val into new column. Basically a loop application for this code:
Df["log_column_name"] = np.log[Df[column_name]]