I am working on a script and using the pandas
lib. I am new to the pandas lib so the question may be silly. I've imported my data from a csv
into a pandas.dataframe
. My data frame looks like below:
set1 set2 set3 set4
0 744110.0 507121.0 790001.0 785693.0
1 744107.0 507126.0 791002.0 788107.0
2 744208.0 535214.0 791103.0 788108.0
3 744210.0 534195.0 790116.0 784170.0
I am facing 2 problems:
Problem 1
The values in the csv
are integer I don't know why or how is that .0
popping up, I don't want that to happen.
I create my dataFrame
with the below code line:
df = pd.read_csv(file_path)
Problem 2
I want to do a search through the sets and get the name of the set that contains a value, for example: if I pass in the value 791103
the output should be name set3
as a string.
How can I achieve this in pandas
Please Note: different columns may have different number of items for example, set1 may have 500 total values while, set2 may just have 40
.to_dict('list')
output:
{'set1': [744110.0, 744107.0, 744208.0, 744210.0], 'set2': [507121.0, 507126.0, 535214.0, 534195.0], 'set3': [790001.0, 791002.0, 791103.0, 790116.0], 'set4': [785693.0, 788107.0, 788108.0, 788170.0]}