Wikipedia:Reference desk/Archives/Computing/2021 March 27
Computing desk | ||
---|---|---|
< March 26 | << Feb | March | Apr >> | March 28 > |
Welcome to the Wikipedia Computing Reference Desk Archives |
---|
The page you are currently viewing is a transcluded archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages. |
March 27
editPython: What is the difference between df.info() and df.info ?
editimport pandas as pd
data = [["Mark", 55, "Italy", 4.5, "Europe"],
["John", 33, "USA", 6.7, "America"],
["Tim", 41, "USA", 3.9, "America"],
["Jenny", 12, "Germany", 9.0, "Europe"]
];
df = pd.DataFrame(data=data, columns=["name", "age", "country", "score", "continent"],
index=[1001, 1000, 1002, 1003]);
print(df.info());
print("---------------Separation line------------------");
print(df.info);
Output:
<class 'pandas.core.frame.DataFrame'>
Int64Index: 4 entries, 1001 to 1003
Data columns (total 5 columns):
# Column Non-Null Count Dtype
--- ------ -------------- -----
0 name 4 non-null object
1 age 4 non-null int64
2 country 4 non-null object
3 score 4 non-null float64
4 continent 4 non-null object
dtypes: float64(1), int64(1), object(3)
memory usage: 192.0+ bytes
None
---------------Separation line------------------
<bound method DataFrame.info of name age country score continent
1001 Mark 55 Italy 4.5 Europe
1000 John 33 USA 6.7 America
1002 Tim 41 USA 3.9 America
1003 Jenny 12 Germany 9.0 Europe>
My question is that why do df.info()
and df.info
return different results? Thanks. Stringent Checker [bargaining] 10:13, 27 March 2021 (UTC)
info
is a method that prints information about a DataFrame.print(df.info())
calls the methodinfo
, which prints the information, then passes its return value (which isNone
) toprint
, soNone
is printed after the information.print(df.info)
takes the methodinfo
and, instead of calling the method, passes the method itself toprint
, thus printing<bound method DataFrame.info of [. . .]>
. --116.86.4.41 (talk) 12:51, 27 March 2021 (UTC)
- Thank you so much for the provided information!! I am managing to absorb it! Stringent Checker [bargaining] 13:06, 27 March 2021 (UTC)
Additional discovery: parentheses () in python pandas
edit
I found that with or without a pair of parentheses did make a difference. It seems to be of some general rules of Python that I haven't figured out. I am new to Python Pandas_(software). @@
I substituted pandas for Python because the working memory just reminded me that I didn't seem to have encountered such an issue over the past month of learning Python. I have recently started learning to use pandas with Python.
# "reset_index" turns the index into a column,
# replacing the index with the default index.
import pandas as pd
data = [["Mark", 55, "Italy", 4.5, "Europe"],
["John", 33, "USA", 6.7, "America"],
["Tim", 41, "USA", 3.9, "America"],
["Jenny", 12, "Germany", 9.0, "Europe"]
];
df = pd.DataFrame(data=data, columns=["name", "age", "country", "score", "continent"],
index=[1001, 1000, 1002, 1003]);
print(df);
df.index.name = "user_id";
print("\n", df);
df.reset_index();
print("\n", df);
df = df.reset_index();
print("\n", df);
Output:
name age country score continent
1001 Mark 55 Italy 4.5 Europe
1000 John 33 USA 6.7 America
1002 Tim 41 USA 3.9 America
1003 Jenny 12 Germany 9.0 Europe
name age country score continent
user_id
1001 Mark 55 Italy 4.5 Europe
1000 John 33 USA 6.7 America
1002 Tim 41 USA 3.9 America
1003 Jenny 12 Germany 9.0 Europe
name age country score continent
user_id
1001 Mark 55 Italy 4.5 Europe
1000 John 33 USA 6.7 America
1002 Tim 41 USA 3.9 America
1003 Jenny 12 Germany 9.0 Europe
user_id name age country score continent
0 1001 Mark 55 Italy 4.5 Europe
1 1000 John 33 USA 6.7 America
2 1002 Tim 41 USA 3.9 America
3 1003 Jenny 12 Germany 9.0 Europe
Stringent Checker [bargaining] 12:34, 27 March 2021 (UTC)
Linux system update broke mouse cursor
editI recently ran a system update on my Fedora 32 Linux system, which updated the kernel from 5.10.18-100 to 5.11.7-100. When I rebooted and the new kernel started, my mouse cursor turned into a complete mess. Everything else worked OK. I rebooted again back to the old kernel, and the mouse cursor is all OK now. Did the kernel update somehow break the mouse cursor? And if so, why? Has this happened for anyone else? JIP | Talk 20:24, 27 March 2021 (UTC)
- You mean the cursor was displayed as garbage? This is likely an issue with the driver for your graphics adapter. Drivers go in the kernel (either built-in or loaded as kernel modules), so that would explain why it happened. I guess the first step would be to check whether anyone else has reported this issue. If not, it's a bug that should be reported. Try a Web search for something like "fedora check graphics driver" if you don't know how to find out your driver. --47.155.96.47 (talk) 22:49, 31 March 2021 (UTC)
Image burned into monitor?
editJust today evening, I was using my Fedora 32 system with a HP 24w monitor when I saw the image on the screen had developed weird vertical stripes and was flashing. I moved a few windows around and saw that the old windows remained on the screen as ghost images. They remained there when I logged off, and even remained when I restarted the whole system. What was even weirder was that when I disconnected the whole video cable, the screen still showed the ghost image of the Linux system even though it wasn't receiving any input any more.
As time passed, the ghost image started to fade away, and after a couple of hours, disappeared entirely and the screen is working all OK now.
What could have caused this? JIP | Talk 21:47, 27 March 2021 (UTC)
- I know nothing about HP monitors, but I'm guessing this is a case of image persistence (though the relevant article does say that "the effects are... often not visible without close inspection," which sounds far milder than your case). — TheHardestAspectOfCreatingAnAccountIsAlwaysTheUsername: posted at 09:28, 28 March 2021 (UTC)
- Anecdotally, I've seen that vertical striping and severe image persistence happen on aging TFT-LCD based monitors a few times. Just a symptom of them getting old, I suspect. 72.89.120.120 (talk) 09:42, 28 March 2021 (UTC)
- @JIP: Your monitor seems to be a standard IPS panel with LED backlight.[1] It is possible that the capacitors on the controller board/power supply are going bad. If it happens again, you might consider trying a replacement board - could be as little as £10-20, and if you get a local PC shop to do it, it shouldn't be more than an hour's work. Otherwise it might be time to start looking for a new monitor. MinorProphet (talk) 23:19, 28 March 2021 (UTC)
- Anecdotally, I've seen that vertical striping and severe image persistence happen on aging TFT-LCD based monitors a few times. Just a symptom of them getting old, I suspect. 72.89.120.120 (talk) 09:42, 28 March 2021 (UTC)
I remember the days of monitors with TV tubes when you might have WordStar burned into the screen. Bubba73 You talkin' to me? 06:08, 29 March 2021 (UTC)