Skip to content
Advertisement

Reading a text file using Pandas accurately in Python

I am trying to read B.txt using pandas. It prints the value of B but not as a list. I present the current and expected outputs.

JavaScript

The current output is

JavaScript

The expected output is

JavaScript

Advertisement

Answer

Add squeeze = True for Series, so ouput is B = ['B=3'], select first value and split, select second value and convert to int:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement