Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi All,
String indices must be integers
This is my code :
This code output :
What i need is....,
I need to fetch the ticker values from the output in the ticker_sentiment json format values that is in the below.
[{ticker=MSFT, ticker_sentiment_label=Somewhat-Bullish, ticker_sentiment_score=0.163239, relevance_score=0.04028}, {ticker=NVDA, ticker_sentiment_label=Somewhat-Bullish, ticker_sentiment_score=0.235239, relevance_score=0.48854}, {ticker=VMW, ticker_sentiment_label=Neutral, ticker_sentiment_score=0.056248, relevance_score=0.04028}, {ticker=AVGO, ticker_sentiment_label=Somewhat-Bullish, ticker_sentiment_score=0.274491, relevance_score=0.520477}]
I need output is MSFT. So,
I Witten this code : print(news_json_1["json_object"]["ticker_sentiment"][0])
this code output is : [
so, I written this code : print(news_json_1["json_object"]["ticker_sentiment"]["ticker"])
this code got error : TypeError Traceback (most recent call last)
print(news_json_1["json_object"]["time_published"])
print(news_json_1["json_object"]["url"])
---> print(news_json_1["json_object"]["ticker_sentiment"][0]["ticker"])
TypeError: string indices must be integers
How to fetch the first ticker?
Please help me.
Thanks in advance.
I need to fetch the ticker value from the output.
The value of ticker_sentiment is a string, not an array. You will need to parse that string again as JSON before you can access the first item in the array.
Thanks for your reply.
Here, I already convert into json. But, I don't know why the value of ticker_sentiment is still string.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
9 | |
8 | |
4 | |
2 | |
2 |
User | Count |
---|---|
4 | |
4 | |
3 | |
3 | |
2 |